Commit Graph

225 Commits

Author SHA1 Message Date
Jason Michalski 05e00575bb Only send stream update events to clients that need them
Stream name and descriptions updates were being sent to all of the
active users on a realm. They are now only send to users who would have
information about that stream.

(imported from commit 2621ee8029f7356bf44ec493d7b5361bd546a8f5)
2014-01-28 17:12:15 -05:00
Steve Howell 1dd674c7ae Make import statements take less vertical space.
(imported from commit 4d5901491d6c8c21fe045ac9751bc80613f94a59)
2014-01-28 17:04:51 -05:00
Steve Howell 80af0b8134 Move AuthedTestCase to test_helpers.py
(imported from commit bdaf63c5ed4e8d7c19e9c19f79151e8e7885c53e)
2014-01-28 17:04:51 -05:00
Steve Howell a8f2ecf48c Move context managers to zerver/lib/test_helpers.py
(imported from commit f57678fcb68aecdbb70ad86cd02cc5441695aaf5)
2014-01-28 17:04:50 -05:00
Steve Howell 8aaf1cf8c2 Add API for removing default streams from a realm.
(imported from commit 06433126e31b372dff8a23eb8bbea14515138c85)
2014-01-28 14:30:37 -05:00
Steve Howell af9a1e967f Add API for adding default streams to a realm.
(imported from commit 0f48f722dd618c0d054aafdf3d931ef014a5c3ee)
2014-01-28 14:30:02 -05:00
Steve Howell 4cf677eb6d Add do_remove_default_stream().
(imported from commit 559dcd93ca43f4ffba58119fe429df3f6843fd63)
2014-01-28 14:28:51 -05:00
Steve Howell 38668adcec Extract DefaultStreamTest.get_default_stream_names().
(imported from commit e51ca97ca820778c161e24f4309517fc5f991dda)
2014-01-28 14:28:51 -05:00
Steve Howell 4ed661ca71 Add do_add_default_stream().
(imported from commit 34c96bdc3f5c2f7f119d2efe1606316878d34d03)
2014-01-28 14:28:51 -05:00
Steve Howell b5e0eb35be Add test_set_default_streams().
(imported from commit 359132c6c31c6de7524df3e9f34dff22273a61bc)
2014-01-28 14:28:50 -05:00
Tim Abbott 3fddc11cc2 Process message events more similarly to how other events are handled.
(imported from commit 5ebcd7a10fe54a8ecafb9550348a1e0418d4cbda)
2014-01-28 13:42:50 -05:00
Tim Abbott 98e4d7aeb3 tests: Change tornado event capture code to a better hook.
(imported from commit b3ef0ba2108ea8d6d7df31cab72b43a10bdeab93)
2014-01-28 11:01:29 -05:00
Tim Abbott 01dedb67f4 tests: Add assert_length helper function for query count asserts.
This way, when one of these asserts fails, the relevant failure will
be printed so that we can look at it.

(imported from commit c0dfe602b987174d151981c083c66fdfdeb01253)
2014-01-28 11:01:29 -05:00
Leo Franchi 5441409044 Consolidate emoji tests and test on frontend as well
(imported from commit 3244a93209b56b655b80633713a3f58ae46d06ff)
2014-01-27 12:07:48 -05:00
Steve Howell 6fff91493c Fix bug in apply_events() for removing subscribers.
To mutate the state for removing subscribers, the previous
code was essentially adding in event['subscriptions'] to
state['unsubscribed'], but that was a naive approach, since
the event object only has the name of the subscriber, and not
the full subscription info.

We instead effectively copy records over from state['subscriptions']
to state['unsubscribed'], and we also do surgery on the subscribers
that made me need to add the user_profile parameter to apply_events().

With the code apparently working now, I was able to remove the
match_except() test helper and use a more thorough matcher in
the test on do_remove_subscription().

Part of fixing the "remove" case was cleaning up the "add" case,
since they aren't quite symmetric opposites of each other, although
under this refactoring they now share the new name() helper.

(imported from commit 0deab67d0c7b08b3ad962493efae3762a835fd29)
2014-01-27 10:41:29 -05:00
Tim Abbott da90d63046 Split out zerver/lib/notifications.py from actions.py.
(imported from commit 784b82834ee4fcb4431e77f8fb1c526f8eec82ad)
2014-01-24 17:33:56 -05:00
Steve Howell cf16d95437 Move some imports in tests.py to the top of the file.
(imported from commit 588c38cb94161092b517848839977d45325633b4)
2014-01-24 16:47:20 -05:00
Steve Howell 1d95812770 Add is_admin to page_params.
Because full_name and is_admin changes go through many similar,
generic codepaths, it is almost more work at this point to keep
is_admin out of page_params as it is to just put it in.  So
I put it in.  This should pave the path for showing admins in
the GUI.

This commit actually starting by my adding a test
that calling apply_events() with the notification you get
when calling do_change_is_admin() updates
state['realm_users'] to be similar to what you would get
out of fetch_initial_state_data().  We didn't have test coverage
there before.  Making that test pass forced my hand to
either add is_admin to page_params or to special-case
apply_events() not to update page_params with is_admin.  I
chose the former approach.

(imported from commit 1e49d59c66540014284529c29d5007224be6a0c6)
2014-01-24 16:34:12 -05:00
Jason Michalski 1f98c4f4ce Add support for updating the stream description
The stream description can now be updated, but the UI is not yet updated
on success.

(imported from commit f45e0a9d5138d828ae98d6d49645ab3ddc966704)
2014-01-24 14:47:44 -05:00
Jason Michalski 1184a4f824 Update GetOldMessagesTest to get recipient ids from the database
The natural order of a query in bulk_create_streams will change when the
Stream model changes. We now query the database for the expected values
so the tests will continue to pass after schema changes.

(imported from commit 410739adde1077bf066df29a11544a627607481a)
2014-01-24 14:47:44 -05:00
Jessica McKellar c01c7285db Add a test for !modal_link.
(imported from commit fac5adf7d596eaca4ea8ed860ddaceb496e72c7a)
2014-01-23 17:06:29 -05:00
Leo Franchi aee127cdbe Share bugdown test data across frontend and backend tests
(imported from commit b278a60b5899cd336840e71d8e632e2b31338d82)
2014-01-23 16:50:29 -05:00
Jason Michalski 6d332151d2 Fix confusion of type_id and type in tests
test_successful_subscriptions_notifies_pm and
test_successful_subscriptions_notifies_stream were both asserting
type_id and not type with the Recipient.PERSONAL and Recipient.STREAM
values.

(imported from commit 26492f9c725c278ac81570a135dc9cc203213cbd)
2014-01-23 14:58:53 -05:00
Steve Howell 2283aa52cb Use "stream" as our type for updates to Stream.name.
(imported from commit 2eedbff5fac77b9e654ba88900167048573e4056)
2014-01-23 13:27:11 -05:00
Steve Howell bc6da3717f Fix obscure bug with page_params.is_bot.
If a name change event arrived during the call to
fetch_initial_state_data(), we would call apply_events() to
update the data structure that eventually becomes page_params.
Our update code, instead of surgically updating the fields, was
just overwriting the record, which led to is_bot being taken
out of the record when only full_name was in the event.

Apart from fixing the "update" case to do the right thing,
this commit also does a bit of cleanup on the code handling
"realm_user" events to make it more generic in how it does
add/remove/update.  If we could standardize our events a bit
more, this could eventually lead to DRYing up some of the
apply_events() code.

(imported from commit 772e2fcd6a5605ccb6e8d1bc499b5f336934cf3c)
2014-01-23 13:01:04 -05:00
Steve Howell 10533291e9 Clean up EventsRegisterTest.do_test().
Use var names hybrid_state, normal_state, and action, and DRY
up the calls to matcher/self.assertEqual.

(imported from commit 6e537e54a9ba85a4711311fdab0a3ba3db9de972)
2014-01-23 13:01:04 -05:00
acrefoot d8b15f4202 Improve Backend for Github integration
Refactor github webhook to handle multiple payload verions
split github fixtures into v1 and v2 versions

Group together all realm-specific logic. When v2 becomes available, we can
ask someone in each org to make the changes via the Github Hook configuration, and
slowly remove the special cases.

TODO: when our pull request for github-services gets merged, the integrations page
should say to look for Zulip instead of Humbug

(imported from commit 4790a730010b37186640f9996291afa6e8f96c2b)
2014-01-22 16:44:34 -05:00
Steve Howell 90ba39d02e Use do_change_is_admin() in the tests.
Call the action method instead of the lower level
assign_perm and remove_perm methods.

(imported from commit 8728fdb2ebfcfc0eacabfd242b229c32a27da2eb)
2014-01-22 14:43:29 -05:00
Steve Howell 3b12e63d8d Send notifications for is_admin changes.
(The client doesn't do anything with them yet.)

(imported from commit df2f406644fe271af53e32a6b3521752b6a1ac41)
2014-01-22 14:43:28 -05:00
Jason Michalski f05d817fb4 Fix building subscribe buttons for realms with a notification stream
Add a test sending new stream notifications to realms with a
notification stream and fix a bug in building the subscribe button
markdown.

(imported from commit 37985d8c0603ae206bef34b9522231c00bc8c572)
2014-01-22 13:08:41 -05:00
Jason Michalski c30a411c10 Add custom markdown tag to render a stream subscribe button
When new streams are created we now send a message with a custom
markdown tag that renders a subscribe button.

(imported from commit 9dfba280b3b4ff4f32f6431ef9227867c8bf4b40)
2014-01-22 11:28:31 -05:00
Steve Howell 6c6d1ee474 Use "synchronized" (past tense) in github webhook.
Normally github gives us a past tense version of the action, but
not for "synchronize," so we fix up the tense.

This also adds zerver.GithubHookTests.test_pull_request_synchronize

(imported from commit ef69467ed4a02dbfa94c8215fb9043b668d1dec9)
2014-01-21 18:18:24 -05:00
Steve Howell 3dbc7d3524 Fix "closers" of github issues/PRs in our webhook.
When folks closed issues or pull requests on github, we were
using the wrong field from the github payload.  Now we
correctly use the "sender" as the person doing the action.

(imported from commit 82989ab19b32f8e3f0bbff9b305a7cb2673d99e9)
2014-01-17 17:48:13 -05:00
Jason Michalski 4c90392261 [schema] Add an per-user option to disable notification on new streams
Added a default_desktop_notifications boolean to userprofile with a UI
in Zulip Labs. This flag is used to default the notification flag on new
subscriptions.

(imported from commit a25223cc5ecf09980cf877991e25034bb3fd4046)
2014-01-16 20:13:34 -05:00
Leo Franchi 607274c0ba Show who updated a ticket in pivotal integration
(imported from commit 005f71222d23f424b57fb84c9f20778836157a51)
2014-01-17 10:32:35 -05:00
Steve Howell 8bf9068d0b Add back end support to restrict creation of streams.
Note that this doesn't actually restrict anybody yet, but it
makes it so that UserProfile.can_create_streams must return True
for a user to create a stream.  We can modify that in the future
to have special behavior for realms that want more restrictions.

(imported from commit 432e85b1ca86aaee4a6bd1d4a6d0b2c78ecb0863)
2014-01-16 14:43:56 -05:00
Steve Howell fd5fd7e61b Have /json/users return is_admin flag.
(imported from commit 49b5c621510c47656f92c38bc5b9b1b6381d5c21)
2014-01-16 13:41:53 -05:00
Steve Howell e837f8bf8b Add back end for admins to assign/remove admin.
Add back end for admins to assign/remove admin permissions for other users.
The /json/users/<email> endpoint allows you to PATCH is_admin.

(imported from commit bb5e6d44d759274cc2a7cb27e479ae96b2f271b5)
2014-01-16 13:41:53 -05:00
Zev Benjamin f015d27d31 Disable historical search whenever the 'is' operator is present
Previously we only disabled it for 'is:starred'.  This caused a backtrace when
someone searched for, say 'stream:test is:mentioned', because we weren't joining
on zerver_usermessage, which meant the flag wasn't available to filter on.

(imported from commit ba19f8a74b21d60b89dfc8dbe9c8458ed86b423b)
2014-01-15 16:07:20 -05:00
Zev Benjamin d8d1d6ea40 Fix narrowing to PMs with yourself
(imported from commit 1326fa7ae779ba6476165e8838e46ce1323e3ecb)
2014-01-15 16:07:19 -05:00
Jason Michalski 60f878b45e Limit cross-realm private messages to zulip.com users
Cross-realm private messages are only used to respond to support
requests. So now cross-realm private messages are only allowed if
exactly two realms are in the private message and one of them is
zulip.com.

(imported from commit f01a2824e214682acb22a6995714a9d1b0d0c66f)
2014-01-15 16:07:19 -05:00
Jason Michalski 4b86ef59f1 Added Zendesk webhook
Zendesk works a lot like desk.com, it has triggers which use targets.
The triggers have a user defined template. Targets can also have place
holders that are posted, we add the ticket id and title here so we can
always construct the message subject.

(imported from commit 04e8e5c7c0fc5568201f252546f6ed42f282fd00)
2014-01-14 12:01:54 -05:00
Zev Benjamin 45ab625616 Add tests for get_old_messages DB queries
(imported from commit 1d6c871e6ac56324a129567e1ba447d44197a0aa)
2014-01-14 11:47:12 -05:00
Zev Benjamin db23674749 Do query time tracking at the psycopg2 level instead of the Django level
This allows us to track the query time of SQLAlchemy and raw queries.

(imported from commit 818a4ee41786ffc57b80d7ed1cfba075f29b6ee5)
2014-01-14 11:47:12 -05:00
Jessica McKellar 8976057b45 Add a backend test for signing up as the first user in a realm.
(imported from commit 637c28bfdcac2f021544e68bb125b85d759d9856)
2014-01-13 10:36:48 -05:00
Waseem Daher fe748f7633 Make Twitter preview look like other inline image previews.
(imported from commit ca4ff9146679a5348bf53d06e992972e9a4b628a)
2014-01-10 21:39:04 -05:00
Jason Michalski 9e822403bb Linkify twitter media links
Image and video links in the twitter API are media and need to be
handed on separately. We also include a preview image if the media link
is a to a picture.

(imported from commit 2bd00d267e51b29ad0ba681195b2bfea9b991d8c)
2014-01-10 21:39:02 -05:00
Jessica McKellar 5cd851ca4e Add a test for logging in with an invalid email address.
(imported from commit 7d6bc16909e3f3ccaaf218809af6b430c938a671)
2014-01-10 21:39:01 -05:00
Jason Michalski 1352dccea5 Add support to linkify links and mentions on twitter
This converts links in tweets to a tags. We also convert the displayed
text to the target of the twitter short URL. Mentions are linked to the
users twitter page.

(imported from commit 192d5546a7eea82759f9ae30d82c102aed15ff71)
2014-01-10 21:39:01 -05:00
Leo Franchi 45d3bb4f04 Update our pivotal integration to handle v5 of their API
(imported from commit 2deba4ed2f72c7d7ccedafbb8fc4370b2faa5490)
2014-01-10 21:39:00 -05:00