| |
@@ -247,3 +247,58 @@
|
| |
hub.unsubscribe(ralph, role="owner")
|
| |
self.assertNotIn(ralph, hub.owners)
|
| |
self.assertIn(ralph, hub.members)
|
| |
+
|
| |
+
|
| |
+ class ModelBookmarksTest(hubs.tests.APPTest):
|
| |
+
|
| |
+ def _add_assoc(self, hubname, username, role):
|
| |
+ hub = hubs.models.Hub.query.get(hubname)
|
| |
+ user = hubs.models.User.query.get(username)
|
| |
+ self.session.add(hubs.models.Association(
|
| |
+ hub=hub, user=user, role=role))
|
| |
+
|
| |
+ def test_user_bookmarks(self):
|
| |
+ """
|
| |
+ test that when we add bookmarks they show up.
|
| |
+ when adding bookmarks for different hubs, we should
|
| |
+ see them all in the result.
|
| |
+ """
|
| |
+ commops = hubs.models.Hub(name="commops")
|
| |
+ self.session.add(commops)
|
| |
+ self._add_assoc("infra", "ralph", "stargazer")
|
| |
+ self._add_assoc("i18n", "ralph", "member")
|
| |
+ self._add_assoc("commops", "ralph", "subscriber")
|
| |
+ ralph = hubs.models.User.query.get("ralph")
|
| |
+ self.assertEquals(len(ralph.bookmarks["starred"]), 1)
|
| |
+ self.assertEquals(ralph.bookmarks["starred"][0].name, "infra")
|
| |
+ self.assertEquals(len(ralph.bookmarks["memberships"]), 1)
|
| |
+ self.assertEquals(ralph.bookmarks["memberships"][0].name, "i18n")
|
| |
+ self.assertEquals(len(ralph.bookmarks["subscriptions"]), 1)
|
| |
+ self.assertEquals(ralph.bookmarks["subscriptions"][0].name, "commops")
|
| |
+
|
| |
+ def test_user_bookmarks_star(self):
|
| |
+ """
|
| |
+ test that when when adding associations for the same hub,
|
| |
+ we should just see the stargazer one.
|
| |
+ """
|
| |
+ self._add_assoc("infra", "ralph", "stargazer")
|
| |
+ self._add_assoc("infra", "ralph", "member")
|
| |
+ self._add_assoc("infra", "ralph", "subscriber")
|
| |
+ ralph = hubs.models.User.query.get("ralph")
|
| |
+ self.assertEquals(len(ralph.bookmarks["starred"]), 1)
|
| |
+ self.assertEquals(ralph.bookmarks["starred"][0].name, "infra")
|
| |
+ self.assertEquals(len(ralph.bookmarks["memberships"]), 0)
|
| |
+ self.assertEquals(len(ralph.bookmarks["subscriptions"]), 0)
|
| |
+
|
| |
+ def test_user_bookmarks_memberships(self):
|
| |
+ """
|
| |
+ test that when when adding associations for the same hub,
|
| |
+ we should just see the memberships one.
|
| |
+ """
|
| |
+ self._add_assoc("infra", "ralph", "member")
|
| |
+ self._add_assoc("infra", "ralph", "subscriber")
|
| |
+ ralph = hubs.models.User.query.get("ralph")
|
| |
+ self.assertEquals(len(ralph.bookmarks["starred"]), 0)
|
| |
+ self.assertEquals(len(ralph.bookmarks["memberships"]), 1)
|
| |
+ self.assertEquals(ralph.bookmarks["memberships"][0].name, "infra")
|
| |
+ self.assertEquals(len(ralph.bookmarks["subscriptions"]), 0)
|
| |
This makes the stars add to the side bookmarks toolbar.
Also, did some tweaking of how the bookmarks bar is
generated and displayed. (in react only)
Fixes #475
Note that the sidebar is also implemented in flask/jinja templates, but this is currently only used in the allgroups page. That will be fixed when the allgroups page is implemented properly.