Skip to content

Commit

Permalink
Merge pull request #1224 from scottsds/issue_3610
Browse files Browse the repository at this point in the history
Issue 3610: Bookmarks: Pending moderator approval visible to all users
  • Loading branch information
CristinaRO committed Apr 29, 2014
2 parents 84dae52 + 0590c04 commit 8f372c3
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/controllers/bookmarks_controller.rb
Expand Up @@ -8,6 +8,7 @@ class BookmarksController < ApplicationController
before_filter :check_visibility, :only => [ :show ]
before_filter :check_ownership, :only => [ :edit, :update, :destroy, :confirm_delete ]


# get the parent
def load_bookmarkable
if params[:work_id]
Expand Down
2 changes: 1 addition & 1 deletion app/models/collection_item.rb
Expand Up @@ -14,7 +14,7 @@ class CollectionItem < ActiveRecord::Base
[LABEL[REJECTED], REJECTED] ]

belongs_to :collection, :inverse_of => :collection_items
belongs_to :item, :polymorphic => :true, :inverse_of => :collection_items
belongs_to :item, :polymorphic => :true, :inverse_of => :collection_items, touch: true
belongs_to :work, :class_name => "Work", :foreign_key => "item_id", :inverse_of => :collection_items
belongs_to :bookmark, :class_name => "Bookmark", :foreign_key => "item_id"

Expand Down
1 change: 1 addition & 0 deletions app/sweepers/collection_sweeper.rb
Expand Up @@ -50,6 +50,7 @@ def expire_collection_cache_for(record)
# expire the collection blurb and dashboard and profile
expire_fragment("collection-blurb-#{collection.id}")
expire_fragment("collection-profile-#{collection.id}")

end
end

Expand Down
23 changes: 17 additions & 6 deletions app/views/bookmarks/_bookmark_user_module.html.erb
@@ -1,6 +1,7 @@
<% # expects "bookmark" %>
<div class="<% if is_author_of?(bookmark) %>own <% end %>user module group">
<% cache [bookmark, 'blurb', 'footer'] do %>
<% blurb_cache_key = (is_author_of?(bookmark) ? "bookmark-owner-blurb-#{bookmark.cache_key}" : "bookmark-blurb-#{bookmark.cache_key}") %>
<% cache(blurb_cache_key) do %>
<!--bookmarker, time-->
<h5 class="byline heading">
<%= ts("Bookmarked by ") %>
Expand All @@ -21,17 +22,27 @@
<% # When the user views their own bookmark blurb, they are warned about seeing their bookmark in a modded collection %>
<% unless bookmark.collections.blank? %>
<% bookmark.collections.each do |modded| %>
<% if modded.moderated? %>
<p class="notice"><%= ts("The collection #{modded.title} is currently moderated. Your bookmark must be approved by the collection maintainers before being listed there.")%></p>
<% end %>
<% bookmark.collections.each do |modded| %>
<% if modded.moderated? && !bookmark.approved_collections.include?(modded) && is_author_of?(bookmark) %>
<p class="notice"><%= ts("The collection #{modded.title} is currently moderated. Your bookmark must be approved by the collection maintainers before being listed there.")%></p>
<% end %>
<% end %>
<% unless bookmark.approved_collections.empty? && !is_author_of?(bookmark) %>
<h6 class="meta heading"><%= ts("Bookmarker's Collections:") %></h6>
<% end %>
<% unless bookmark.approved_collections.empty? && !is_author_of?(bookmark) %>
<ul class="meta commas">
<% bookmark.collections.each do |coll|%>
<% if is_author_of?(bookmark) || logged_in_as_admin? %>
<% bookmark.collections.each do |coll| %>
<li><%= link_to coll.title, collection_path(coll) %></li>
<% end %>
<% else %>
<% bookmark.approved_collections.each do |coll| %>
<li><%= link_to coll.title, collection_path(coll) %></li>
<% end %>
<% end %>
</ul>
<% end %>
<% end %>
<!--notes-->
Expand Down
101 changes: 100 additions & 1 deletion features/bookmarks/bookmark_create.feature
Expand Up @@ -162,6 +162,105 @@ Scenario: extra commas in bookmark form (Issue 2284)
And I press "Create"
Then I should see "created"

Scenario: bookmark added to moderated collection has flash notice only when not approved
Given the following activated users exist
| login | password |
| workauthor | password |
| bookmarker | password |
| otheruser | password |
And I have a moderated collection "Five Pillars" with name "five_pillars"
And I am logged in as "workauthor" with password "password"
And I post the work "Fire Burn, Cauldron Bubble"
When I log out
And I am logged in as "bookmarker" with password "password"
And I view the work "Fire Burn, Cauldron Bubble"
And I follow "Bookmark"
And I fill in "bookmark_collection_names" with "five_pillars"
And I press "Create"
Then I should see "Bookmark was successfully created"
And I should see "The collection Five Pillars is currently moderated."
When I go to bookmarker's bookmarks page
Then I should see "The collection Five Pillars is currently moderated."
When I log out
And I am logged in as "moderator" with password "password"
And I approve the first item in the collection "Five Pillars"
And I am logged in as "bookmarker" with password "password"
And I go to bookmarker's bookmarks page
Then I should not see "The collection Five Pillars is currently moderated."


Scenario: bookmarks added to moderated collections appear correctly
Given the following activated users exist
| login | password |
| workauthor | password |
| bookmarker | password |
| otheruser | password |
And I have a moderated collection "JBs Greatest" with name "jbs_greatest"
And I have the collection "Mrs. Pots" with name "mrs_pots"
And I am logged in as "workauthor" with password "password"
And I post the work "The Murder of Sherlock Holmes"
When I log out
And I am logged in as "bookmarker" with password "password"
And I view the work "The Murder of Sherlock Holmes"
And I follow "Bookmark"
And I fill in "bookmark_collection_names" with "jbs_greatest"
And I press "Create"
Then I should see "Bookmark was successfully created"
And I should see "The collection JBs Greatest is currently moderated. Your bookmark must be approved by the collection maintainers before being listed there."
When I go to bookmarker's bookmarks page
And I should see "The Murder of Sherlock Holmes"
And I should see "Bookmarker's Collections: JBs Greatest"
And I should see "The collection JBs Greatest is currently moderated. Your bookmark must be approved by the collection maintainers before being listed there."
When I go to the bookmarks page
And I should see "The Murder of Sherlock Holmes"
And I should see "Bookmarker's Collections: JBs Greatest"
And I should see "The collection JBs Greatest is currently moderated. Your bookmark must be approved by the collection maintainers before being listed there."
When I log out
# Users who do not own the bookmark should not see the notice, or see that it
# has been submitted to a specific collection
And I am logged in as "otheruser" with password "password"
And I go to bookmarker's bookmarks page
Then I should see "The Murder of Sherlock Holmes"
And I should not see "Bookmarker's Collections: JBs Greatest"
And I should not see "The collection JBs Greatest is currently moderated. Your bookmark must be approved by the collection maintainers before being listed there."
When I go to the bookmarks page
Then I should see "The Murder of Sherlock Holmes"
And I should not see "Bookmarker's Collections: JBs Greatest"
And I should not see "The collection JBs Greatest is currently moderated. Your bookmark must be approved by the collection maintainers before being listed there."
# Edit the bookmark and add it to a second, unmoderated collection, and recheck
# all the things
When I log out
And I am logged in as "bookmarker" with password "password"
And I view the work "The Murder of Sherlock Holmes"
And I follow "Edit Bookmark"
And I fill in "bookmark_collection_names" with "jbs_greatest,mrs_pots"
And I press "Edit" within "div#bookmark-form"
And all search indexes are updated
Then I should see "Bookmark was successfully updated."
And I should see "The collection JBs Greatest is currently moderated."
When I go to bookmarker's bookmarks page
Then I should see "The Murder of Sherlock Holmes"
And I should see "JBs Greatest" within "ul.meta"
And I should see "Mrs. Pots" within "ul.meta"
And I should see "The collection JBs Greatest is currently moderated."
When I go to the bookmarks page
Then I should see "The Murder of Sherlock Holmes"
And I should see "JBs Greatest" within "ul.meta"
And I should see "Mrs. Pots" within "ul.meta"
And I should see "The collection JBs Greatest is currently moderated."
When I log out
And I am logged in as "otheruser" with password "password"
And I go to bookmarker's bookmarks page
Then I should see "The Murder of Sherlock Holmes"
And I should not see "JBs Greatest" within "ul.meta"
And I should see "Bookmarker's Collections: Mrs. Pots"
And I should not see "The collection JBs Greatest is currently moderated."
When I go to the bookmarks page
Then I should see "The Murder of Sherlock Holmes"
And I should not see "JBs Greatest" within "ul.meta"
And I should see "Bookmarker's Collections: Mrs. Pots"
And I should not see "The collection JBs Greatest is currently moderated."

Scenario: Adding bookmarks to closed collections (Issue 3083)
Given I am logged in as "moderator" with password "password"
And I have a closed collection "Unsolved Mysteries" with name "unsolved_mysteries"
Expand Down Expand Up @@ -222,7 +321,7 @@ Scenario: Adding bookmarks to closed collections (Issue 3083)
And I fill in "bookmark_notes" with "This is a user editing a closed collection bookmark"
And I press "Edit"
Then I should see "Bookmark was successfully updated."

Scenario: Delete bookmarks of a work and a series
Given the following activated users exist
| login | password |
Expand Down
10 changes: 10 additions & 0 deletions features/step_definitions/challenge_steps.rb
Expand Up @@ -169,6 +169,16 @@
step %{I press "Update"}
end

When /^I approve the first item in the collection "([^\"]*)"$/ do |collection|
collection = Collection.find_by_title(collection)
collection_item = collection.collection_items.first.id
visit collection_path(collection)
step %{I follow "Manage Items"}
step %{I select "Approved" from "collection_items_#{collection_item}_collection_approval_status"}
step %{I press "Submit"}
end


When /^I reveal the authors of the "([^\"]*)" challenge$/ do |title|
step %{I am logged in as "mod1"}
visit collection_path(Collection.find_by_title(title))
Expand Down
2 changes: 2 additions & 0 deletions features/support/paths.rb
Expand Up @@ -22,6 +22,8 @@ def path_to(page_name)
when /^the search people page$/i
Pseud.tire.index.refresh
search_people_path
when /^the bookmarks page$/i
bookmarks_path

# the following are examples using path_to_pickle

Expand Down

0 comments on commit 8f372c3

Please sign in to comment.