diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 3fa550fb219..c038d3722c5 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -354,6 +354,52 @@ def load_collection
@collection = Collection.find_by(name: params[:collection_id]) if params[:collection_id]
end
+ # obj_name: "work", "bookmark", or "collection" (used in the respective controllers)
+ def load_owner(obj_name)
+ @work = Work.find(params[:work_id]) if params[:work_id].present?
+ @collection = Collection.find_by!(name: params[:collection_id]) if params[:collection_id].present?
+ @language = Language.find_by(short: params[:language_id]) if params[:language_id].present?
+
+ if params[:user_id].present?
+ @user = User.find_by(login: params[:user_id])
+ raise ActiveRecord::RecordNotFound, "Couldn't find user named '#{params[:user_id]}'" if @user.blank?
+
+ if params[:pseud_id].present?
+ @pseud = @user.pseuds.find_by(name: params[:pseud_id])
+ raise ActiveRecord::RecordNotFound, "Couldn't find pseud named '#{params[:pseud_id]}'" if @pseud.blank? && obj_name == "bookmark"
+ end
+ end
+
+ if params[:tag_id].present?
+ @tag = Tag.find_by_name(params[:tag_id])
+ raise ActiveRecord::RecordNotFound, "Couldn't find tag named '#{params[:tag_id]}'" unless @tag.is_a?(Tag)
+
+ unless @tag.canonical?
+ redirect_to tag_path(@tag) and return if @tag.merger.blank?
+
+ work_redirect_path = @collection.present? ? collection_tag_works_path(@collection, @tag.merger) : tag_works_path(@tag.merger)
+ case obj_name
+ when "collection"
+ redirect_to tag_collections_path(@tag.merger) and return
+ when "bookmark"
+ redirect_to tag_bookmarks_path(@tag.merger) and return
+ when "work"
+ redirect_to work_redirect_path and return
+ end
+ end
+ end
+
+ # can't factor out shared user/collection/tag variables because precedence matters
+ @owner = case obj_name
+ when "work"
+ @pseud || @user || @collection || @tag || @language
+ when "bookmark"
+ @bookmarkable || @pseud || @user || @collection || @tag
+ when "collection"
+ @user || @work || @collection || @tag
+ end
+ end
+
def privileged_collection_admin?
policy(Collection).access?
end
diff --git a/app/controllers/bookmarks_controller.rb b/app/controllers/bookmarks_controller.rb
index c4f43b87f1c..17b24ee630e 100644
--- a/app/controllers/bookmarks_controller.rb
+++ b/app/controllers/bookmarks_controller.rb
@@ -1,6 +1,6 @@
class BookmarksController < ApplicationController
before_action :load_collection
- before_action :load_owner, only: [:index]
+ before_action :load_bookmark_owner, only: [:index]
before_action :load_bookmarkable, only: [:index, :new, :create]
before_action :users_only, only: [:new, :create, :edit, :update]
before_action :check_user_status, only: [:new, :create, :edit, :update]
@@ -251,33 +251,8 @@ def destroy
protected
- def load_owner
- if params[:user_id].present?
- @user = User.find_by(login: params[:user_id])
- unless @user
- raise ActiveRecord::RecordNotFound, "Couldn't find user named '#{params[:user_id]}'"
- end
- if params[:pseud_id].present?
- @pseud = @user.pseuds.find_by(name: params[:pseud_id])
- unless @pseud
- raise ActiveRecord::RecordNotFound, "Couldn't find pseud named '#{params[:pseud_id]}'"
- end
- end
- end
- if params[:tag_id]
- @tag = Tag.find_by_name(params[:tag_id])
- unless @tag
- raise ActiveRecord::RecordNotFound, "Couldn't find tag named '#{params[:tag_id]}'"
- end
- unless @tag.canonical?
- if @tag.merger.present?
- redirect_to tag_bookmarks_path(@tag.merger) and return
- else
- redirect_to tag_path(@tag) and return
- end
- end
- end
- @owner = @bookmarkable || @pseud || @user || @collection || @tag
+ def load_bookmark_owner
+ load_owner("bookmark")
end
def index_page_title
diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb
index 505a0791c35..9ed13baded8 100644
--- a/app/controllers/collections_controller.rb
+++ b/app/controllers/collections_controller.rb
@@ -1,4 +1,5 @@
class CollectionsController < ApplicationController
+ before_action :load_collection_owner, only: [:index]
before_action :users_only, only: [:new, :create]
before_action :load_collection_from_id, only: [:show, :edit, :update, :destroy, :confirm_delete]
before_action :collection_owners_or_privileged_admins_only, only: [:edit]
@@ -31,32 +32,48 @@ def check_parent_visible
end
def index
+ base_options = {
+ page: params[:page] || 1
+ }
options = params[:collection_search].present? ? collection_filter_params : {}
- if params[:work_id]
- @work = Work.find(params[:work_id])
- @collections = @work.approved_collections
- .by_title
- .for_blurb
- .paginate(page: params[:page])
- elsif params[:collection_id]
- @collection = Collection.find_by!(name: params[:collection_id])
- @search = CollectionSearchForm.new({ parent_id: @collection.id, sort_column: "title.keyword" }.merge(page: params[:page]))
- @collections = @search.search_results.scope(:for_search)
- flash_search_warnings(@collections)
- @page_subtitle = t(".subcollections_page_title", collection_title: @collection.title)
- elsif params[:user_id]
- @sort_and_filter = true
- @user = User.find_by!(login: params[:user_id])
- @search = CollectionSearchForm.new(options.merge({ maintainer_id: @user.id }.merge(page: params[:page])))
- @collections = @search.search_results.scope(:for_search)
- flash_search_warnings(@collections)
- @page_subtitle = ts("%{username} - Collections", username: @user.login)
+ options.merge!(base_options)
+
+ @page_subtitle = case @owner
+ when Collection
+ t(".page_title.subcollection", collection_title: @collection.title)
+ when User
+ t(".page_title.user", username: @user.login)
+ when Tag
+ t(".page_title.tag", tag_name: @tag.name)
+ else
+ t(".page_title.general")
+ end
+
+ if @owner.present?
+ if @work.present?
+ @sort_and_filter = false
+ @collections = @work.approved_collections
+ .by_title
+ .for_blurb
+ .page(params[:page])
+ elsif @collection.present?
+ @sort_and_filter = false
+ @search = CollectionSearchForm.new({ parent_id: @collection.id, sort_column: "title.keyword" }.merge(base_options))
+ @collections = @search.search_results.scope(:for_search)
+ elsif @user.present? || @tag.present?
+ @sort_and_filter = true
+ add_owner options
+ @search = CollectionSearchForm.new(options)
+ @collections = @search.search_results.scope(:for_search)
+ end
else
@sort_and_filter = true
- @search = CollectionSearchForm.new(options.merge(page: params[:page]))
+ @search = CollectionSearchForm.new(options)
@collections = @search.search_results.scope(:for_search)
- flash_search_warnings(@collections)
end
+
+ flash_search_warnings(@collections) if @work.blank?
+ @pagy = pagy_query_result(@collections) if @collections.respond_to?(:total_pages)
end
# display challenges that are currently taking signups
@@ -194,6 +211,22 @@ def destroy
redirect_to(collections_path)
end
+ protected
+
+ def load_collection_owner
+ load_owner("collection")
+ end
+
+ def add_owner(options)
+ case @owner
+ when Tag
+ options[:filter_ids] ||= []
+ options[:filter_ids] << @owner.id
+ when User
+ options[:maintainer_id] = @owner.id
+ end
+ end
+
private
def collection_filter_params
diff --git a/app/controllers/works_controller.rb b/app/controllers/works_controller.rb
index 2a2929a326d..c18ee810a5e 100755
--- a/app/controllers/works_controller.rb
+++ b/app/controllers/works_controller.rb
@@ -5,7 +5,7 @@ class WorksController < ApplicationController
# only registered users and NOT admin should be able to create new works
before_action :load_collection
- before_action :load_owner, only: [:index]
+ before_action :load_work_owner, only: [:index]
before_action :users_only, except: [:index, :show, :navigate, :search, :collected, :edit, :update, :drafts, :share]
before_action :check_user_status, except: [:index, :edit, :edit_multiple, :confirm_delete_multiple, :delete_multiple, :confirm_delete, :destroy, :show, :show_multiple, :navigate, :search, :collected, :share]
before_action :check_user_not_suspended, only: [:edit, :confirm_delete, :destroy, :show_multiple, :edit_multiple, :confirm_delete_multiple, :delete_multiple]
@@ -723,32 +723,8 @@ def mark_as_read
protected
- def load_owner
- if params[:user_id].present?
- @user = User.find_by!(login: params[:user_id])
- if params[:pseud_id].present?
- @pseud = @user.pseuds.find_by(name: params[:pseud_id])
- end
- end
- if params[:tag_id]
- @tag = Tag.find_by_name(params[:tag_id])
- unless @tag && @tag.is_a?(Tag)
- raise ActiveRecord::RecordNotFound, "Couldn't find tag named '#{params[:tag_id]}'"
- end
- unless @tag.canonical?
- if @tag.merger.present?
- if @collection.present?
- redirect_to(collection_tag_works_path(@collection, @tag.merger)) && return
- else
- redirect_to(tag_works_path(@tag.merger)) && return
- end
- else
- redirect_to(tag_path(@tag)) && return
- end
- end
- end
- @language = Language.find_by(short: params[:language_id]) if params[:language_id].present?
- @owner = @pseud || @user || @collection || @tag || @language
+ def load_work_owner
+ load_owner("work")
end
def load_work
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
index a98848c890c..2e8b61dbbbb 100644
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -52,22 +52,20 @@ def works_original_path
)
end
- def collections_original_path
+ def bookmarks_original_path
url_for(
- controller: :collections,
+ controller: :bookmarks,
action: :index,
only_path: true,
- **params.slice(:title, :challenge_type, :moderated, :multifandom, :closed, :tag,
- :sort_column, :sort_direction).permit!
+ **params.slice(:tag_id, :collection_id, :pseud_id, :user_id).permit!
)
end
- def bookmarks_original_path
+ def collections_original_path
url_for(
- controller: :bookmarks,
+ controller: :collections,
action: :index,
- only_path: true,
- **params.slice(:tag_id, :collection_id, :pseud_id, :user_id).permit!
+ only_path: true
)
end
end
diff --git a/app/views/bookmarks/index.html.erb b/app/views/bookmarks/index.html.erb
index 7293d1419f2..222b70f8a57 100755
--- a/app/views/bookmarks/index.html.erb
+++ b/app/views/bookmarks/index.html.erb
@@ -31,6 +31,7 @@
<% if @tag %>
<%= span_if_current t(".navigation.works"), tag_works_path(@tag) %>
<%= span_if_current t(".navigation.bookmarks"), tag_bookmarks_path(@tag) %>
+ <%= span_if_current t(".navigation.collections"), tag_collections_path(@tag) %>
<% end %>
<% if @facets.present? %>
<% # Filters button for narrow screens jumps to filters when JavaScript is disabled and opens filters when JavaScript is enabled %>
diff --git a/app/views/collection_profile/show.html.erb b/app/views/collection_profile/show.html.erb
index 606d638f81a..d51bc95bbc0 100644
--- a/app/views/collection_profile/show.html.erb
+++ b/app/views/collection_profile/show.html.erb
@@ -19,7 +19,7 @@
diff --git a/app/views/collections/_collection_blurb.html.erb b/app/views/collections/_collection_blurb.html.erb
index 4697a9952b2..f15a94724d9 100644
--- a/app/views/collections/_collection_blurb.html.erb
+++ b/app/views/collections/_collection_blurb.html.erb
@@ -17,7 +17,7 @@
<% unless collection.tag_string.blank? %>
<% end %>
diff --git a/app/views/collections/_filters.html.erb b/app/views/collections/_filters.html.erb
index b6994f397e8..10809b5d523 100644
--- a/app/views/collections/_filters.html.erb
+++ b/app/views/collections/_filters.html.erb
@@ -1,5 +1,11 @@
<%= form_for @search, as: :collection_search,
- url: (@user ? user_collections_path(@user) : collections_path),
+ url: (if @user
+ user_collections_path(@user)
+ elsif @tag
+ tag_collections_path(@tag)
+ else
+ collections_path
+ end),
html: {
method: :get,
class: "narrow-hidden filters",
diff --git a/app/views/collections/index.html.erb b/app/views/collections/index.html.erb
index 5582648c664..a0dcd6dff5d 100755
--- a/app/views/collections/index.html.erb
+++ b/app/views/collections/index.html.erb
@@ -1,29 +1,25 @@
- <% if @user %>
- <%= t(".page_heading.users_collections", user: @user.login) %>
+ <% if @user || @tag %>
+ <%= search_header(@collections, @query, t(".page_heading.collection"), @owner) %>
<% elsif @collection %>
- <%= t(".page_heading.challenges_subcollections_in", collection: @collection.title) %>
+ <%= search_header(@collections, @query, t(".page_heading.subcollection"), @owner) %>
<% elsif @work %>
- <%= t(".page_heading.collections_including", work: @work.title) %>
+ <%= t(".page_heading.collections_including", work: @work.title, collections: search_header(@collections, @query, t(".page_heading.collection"), @owner)) %>
<% else %>
- <%= t(".page_heading.collections_in_the", archive: ArchiveConfig.APP_NAME) %>
+ <%= t(".page_heading.collections_in_the", archive: ArchiveConfig.APP_NAME, collections: search_header(@collections, @query, t(".page_heading.collection"), @owner)) %>
<% end %>
-
-
- <% if @collections.empty? %>
- <%= t(".page_heading.no_results") %>
- <% else %>
- <%= search_header @collections, @query, t(".page_heading.search_header") %>
- <% end %>
-
<%= t(".navigation.landmark_heading") %>
-
- <% if @collection %>
+
+ <% if @tag %>
+ - <%= span_if_current t(".navigation.actions.tag.works"), tag_works_path(@tag) %>
+ - <%= span_if_current t(".navigation.actions.tag.bookmarks"), tag_bookmarks_path(@tag) %>
+ - <%= span_if_current t(".navigation.actions.tag.collections"), tag_collections_path(@tag) %>
+ <% elsif @collection %>
<%# Collection subcollections index gets link for Subcollections %>
- <%= span_if_current t(".navigation.actions.subcollections"), collection_collections_path(@collection) %>
<% elsif @user %>
@@ -34,7 +30,7 @@
- <%= link_to t(".navigation.actions.manage_items"), user_collection_items_path(@user) %>
<% end %>
<% else %>
- <%# Collections and Open Challenges link unless on a user's collections page or collection's subcollections page %>
+ <%# Collections and Open Challenges link unless on a tag's/user's collections page or collection's subcollections page %>
- <%= span_if_current t(".navigation.actions.collections"), collections_path %>
- <%= link_to t(".navigation.actions.open_challenges"), list_challenges_collections_path %>
<% end %>
@@ -42,7 +38,7 @@
<%# Logged in collection maintainer on own collection gets link for New Subcollection and all other logged in users get New Collection link %>
<% if @collection && !@collection.parent && @collection.user_is_maintainer?(current_user) %>
- <%= link_to t(".navigation.actions.new_subcollection"), new_collection_collection_path(@collection) %>
- <% else %>
+ <% elsif !@tag %>
- <%= link_to t(".navigation.actions.new_collection"), new_collection_path %>
<% end %>
<% end %>
@@ -54,7 +50,7 @@
<% unless @collections.blank? %>
- <%= will_paginate @collections %>
+ <%= pagy_nav @pagy %>
<%= t(".main_content.landmark_heading") %>
@@ -70,5 +66,5 @@
<% end %>
<% unless @collections.blank? %>
- <%= will_paginate @collections %>
+ <%= pagy_nav @pagy %>
<% end %>
diff --git a/app/views/tag_wranglings/_wrangler_dashboard.html.erb b/app/views/tag_wranglings/_wrangler_dashboard.html.erb
index a1e0bcd38d7..44321d7af8f 100644
--- a/app/views/tag_wranglings/_wrangler_dashboard.html.erb
+++ b/app/views/tag_wranglings/_wrangler_dashboard.html.erb
@@ -30,6 +30,11 @@
<%= span_if_current t(".use_type_and_count", use_type: t(".use_type.external_works"), count: @counts[key]),
{ controller: :bookmarks, action: :index, tag_id: @tag } %>
+ <% elsif key == "Collections" %>
+ -
+ <%= span_if_current t(".use_type_and_count", use_type: t(".use_type.collections"), count: @counts[key]),
+ tag_collections_path(@tag) %>
+
<% else %>
-
diff --git a/app/views/tags/show.html.erb b/app/views/tags/show.html.erb
index 47934a8c127..f6fef3a5a9c 100644
--- a/app/views/tags/show.html.erb
+++ b/app/views/tags/show.html.erb
@@ -6,13 +6,14 @@
<% if @tag.canonical || @tag.merger || can_wrangle? %>
<% if @tag.canonical || @tag.merger %>
- - <%= link_to ts("Works"), tag_works_path(@tag) %>
- - <%= link_to ts("Bookmarks"), tag_bookmarks_path(@tag) %>
+ - <%= link_to t(".navigation.works"), tag_works_path(@tag) %>
+ - <%= link_to t(".navigation.bookmarks"), tag_bookmarks_path(@tag) %>
+ - <%= link_to t(".navigation.collections"), tag_collections_path(@tag) %>
<% end %>
<% if can_wrangle? %>
- - <%= link_to ts("Edit"), edit_tag_path(@tag) %>
+ - <%= link_to t(".navigation.edit"), edit_tag_path(@tag) %>
- <%= tag_comment_link(@tag) %>
- - <%= link_to ts("Troubleshoot"), tag_troubleshooting_path(@tag) %>
+ - <%= link_to t(".navigation.troubleshoot"), tag_troubleshooting_path(@tag) %>
<% end %>
<% end %>
diff --git a/app/views/works/index.html.erb b/app/views/works/index.html.erb
index db80ac94b4e..6bf72dbef8c 100755
--- a/app/views/works/index.html.erb
+++ b/app/views/works/index.html.erb
@@ -18,14 +18,15 @@
<% if @user %>
<% if @user == current_user %>
- - <%= link_to ts("Edit Works"), show_multiple_user_works_path(@user) %>
+ - <%= link_to t(".navigation.user.edit_works"), show_multiple_user_works_path(@user) %>
<% end %>
- - <%= span_if_current ts("Works in Collections"), collected_user_works_path(@user) %>
- - <%= span_if_current ts("Works"), user_works_path(@user) %>
+ - <%= span_if_current t(".navigation.user.collection_works"), collected_user_works_path(@user) %>
+ - <%= span_if_current t(".navigation.user.works"), user_works_path(@user) %>
<% end %>
<% if @tag && !@collection %>
- - <%= span_if_current ts("Works"), tag_works_path(@tag) %>
- - <%= span_if_current ts("Bookmarks"), tag_bookmarks_path(@tag) %>
+ - <%= span_if_current t(".navigation.tag.works"), tag_works_path(@tag) %>
+ - <%= span_if_current t(".navigation.tag.bookmarks"), tag_bookmarks_path(@tag) %>
+ - <%= span_if_current t(".navigation.tag.collections"), tag_collections_path(@tag) %>
<% end %>
<% if @facets.present? %>
<%# Filters button for narrow screens jumps to filters when JavaScript is disabled and opens filters when JavaScript is enabled %>
diff --git a/config/locales/controllers/en.yml b/config/locales/controllers/en.yml
index a82b7329b55..88ee68dbefd 100644
--- a/config/locales/controllers/en.yml
+++ b/config/locales/controllers/en.yml
@@ -182,7 +182,11 @@ en:
page_title: "%{collection_title} - Profile"
collections:
index:
- subcollections_page_title: "%{collection_title} - Subcollections"
+ page_title:
+ general: Collections
+ subcollection: "%{collection_title} - Subcollections"
+ tag: "%{tag_name} - Collections"
+ user: "%{username} - Collections"
comments:
check_blocked:
parent: Sorry, you have been blocked by one or more of this work's creators.
diff --git a/config/locales/views/en.yml b/config/locales/views/en.yml
index a9556d4bee9..c5a47e90253 100644
--- a/config/locales/views/en.yml
+++ b/config/locales/views/en.yml
@@ -695,6 +695,7 @@ en:
choose_fandom: choose a fandom
navigation:
bookmarks: Bookmarks
+ collections: Collections
edit: Edit Bookmark
new: Bookmark
new_external_work: Bookmark External Work
@@ -888,14 +889,16 @@ en:
new_subcollection: New Subcollection
open_challenges: Open Challenges
subcollections: Subcollections
+ tag:
+ bookmarks: Bookmarks
+ collections: Collections
+ works: Works
landmark_heading: Navigation
page_heading:
- challenges_subcollections_in: Challenges/Subcollections in %{collection}
- collections_in_the: Collections in the %{archive}
- collections_including: Collections including %{work}
- no_results: Sorry, there were no collections found.
- search_header: Collection
- users_collections: "%{user}'s Collections"
+ collection: Collection
+ collections_in_the: "%{collections} in the %{archive}"
+ collections_including: "%{collections} including %{work}"
+ subcollection: Subcollection
sidebar:
bookmarks: Bookmarked Items (%{count})
challenge_settings: Challenge Settings
@@ -3190,6 +3193,12 @@ en:
filter_bookmarks: filter bookmarks
filter_works: filter works
list_fandom_tags_html: You can also access a list of %{fandom_relationship_tags_link}.
+ navigation:
+ bookmarks: Bookmarks
+ collections: Collections
+ edit: Edit
+ troubleshoot: Troubleshoot
+ works: Works
synonyms: 'Tags with the same meaning:'
wrangle:
manage:
@@ -3526,6 +3535,15 @@ en:
index:
advanced_search: try our advanced search
choose_fandom: choose a fandom
+ navigation:
+ tag:
+ bookmarks: Bookmarks
+ collections: Collections
+ works: Works
+ user:
+ collection_works: Works in Collections
+ edit_works: Edit Works
+ works: Works
recent_works_html: These are some of the latest works posted to the Archive. To find more works, %{choose_fandom_link} or %{advanced_search_link}.
meta:
original_creators:
diff --git a/config/routes.rb b/config/routes.rb
index 82b2f56855c..915ab7feb7d 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -132,6 +132,7 @@
end
resources :works
resources :bookmarks
+ resources :collections, only: [:index]
resources :comments
resource :troubleshooting, controller: :troubleshooting, only: [:show, :update]
end
diff --git a/features/collections/collection_browse.feature b/features/collections/collection_browse.feature
index 3fe0bd09342..5c39e2a48e2 100644
--- a/features/collections/collection_browse.feature
+++ b/features/collections/collection_browse.feature
@@ -345,7 +345,7 @@ Feature: Collection
And the 2nd collection result should contain "The Hobbit"
When I fill in "Filter by title" with "Not Mine!"
And I press "Sort and Filter"
- Then I should see "Sorry, there were no collections found."
+ Then I should see "0 Collections"
Scenario: Default sorting is different from collections page and user collections page
diff --git a/features/collections/collection_navigation.feature b/features/collections/collection_navigation.feature
index 2b768d9b1c0..7ccf2c59281 100644
--- a/features/collections/collection_navigation.feature
+++ b/features/collections/collection_navigation.feature
@@ -32,8 +32,8 @@ Feature: Basic collection navigation
Then I should see "About My Collection (my_collection)"
And I should see "Maintainers: mod"
When I follow "Subcollections (0)"
- Then I should see "Challenges/Subcollections in My Collection"
- And I should see "Sorry, there were no collections found."
+ Then I should see "Subcollections in My Collection"
+ And I should see "0 Subcollections"
When I follow "Fandoms (1)"
Then I should see "New Fandom (1)"
When I follow "Works (1)"
diff --git a/features/collections/collection_taglisting.feature b/features/collections/collection_taglisting.feature
new file mode 100644
index 00000000000..37ba4158096
--- /dev/null
+++ b/features/collections/collection_taglisting.feature
@@ -0,0 +1,112 @@
+@collections
+Feature: Collection
+ In order to have an archive full of collections
+ As a humble user
+ I want to locate and browse through tag collection listings
+
+ Scenario: Collections tagged with a tag and synonyms of the tag show up in the tag's collection listing
+ Given a set of collections for tag page searching
+ When I go to the collections page
+ And I follow "My Beautiful Canonical Tag"
+ Then I should see the page title "My Beautiful Canonical Tag - Collections"
+ And I should see "My Beautiful Canonical Tag" within "h2.heading"
+ And I should see "3 Collections" within "h2.heading"
+ And I should not see "Example Archive" within "h2.heading"
+ And I should see "Beautiful Tag Test Collection"
+ And I should see "Multiple Tag Test Collection"
+ And I should see "Gorgeous Tag Test Collection"
+ But I should not see "Noncanonical Tag Test Collection"
+
+ Scenario: Clicking on a synonymous tag on a collection also brings you to the canonical tag's collection page
+ Given a set of collections for tag page searching
+ When I go to the collections page
+ And I follow "My Gorgeous Synonymous Tag"
+ Then I should see the page title "My Beautiful Canonical Tag - Collections"
+ And I should see "My Beautiful Canonical Tag" within "h2.heading"
+ And I should see "3 Collections" within "h2.heading"
+ And I should see "Beautiful Tag Test Collection"
+ And I should see "Multiple Tag Test Collection"
+ And I should see "Gorgeous Tag Test Collection"
+ But I should not see "Noncanonical Tag Test Collection"
+
+ Scenario: We can further filter a tag's collection listing with another tag
+ Given a set of collections for tag page searching
+ When I go to the collections page
+ And I follow "My Beautiful Canonical Tag"
+ And I fill in "Filter by tag" with "a noncanonical tag"
+ And I press "Sort and Filter"
+ Then I should see "My Beautiful Canonical Tag" within "h2.heading"
+ And I should see "1 Collection" within "h2.heading"
+ And I should see "Multiple Tag Test Collection"
+ But I should not see "Beautiful Tag Test Collection"
+ And I should not see "Noncanonical Tag Test Collection"
+ And I should not see "Gorgeous Tag Test Collection"
+
+ Scenario: We can further filter a tag's collection listing with radio buttons
+ Given a set of collections for tag page searching
+ When I go to the collections page
+ And I follow "My Beautiful Canonical Tag"
+ And I choose "Gift Exchange Challenge"
+ And I press "Sort and Filter"
+ Then I should see "My Beautiful Canonical Tag" within "h2.heading"
+ And I should see "1 Collection" within "h2.heading"
+ And I should see "Gorgeous Tag Test Collection"
+ But I should not see "Beautiful Tag Test Collection"
+ And I should not see "Multiple Tag Test Collection"
+ And I should not see "Noncanonical Tag Test Collection"
+
+ Scenario: Clearing filters brings us back to the tag's collection listing
+ Given a set of collections for tag page searching
+ When I go to the collections page
+ And I follow "My Beautiful Canonical Tag"
+ And I choose "Gift Exchange Challenge"
+ And I press "Sort and Filter"
+ Then I should see "My Beautiful Canonical Tag" within "h2.heading"
+ And I should see "1 Collection" within "h2.heading"
+ When I follow "Clear Filters"
+ Then I should see "My Beautiful Canonical Tag" within "h2.heading"
+ And I should see "3 Collections" within "h2.heading"
+
+ Scenario: We can find collection listings for a tag through a collection profile
+ Given a set of collections for tag page searching
+ When I go to "Beautiful Tag Test Collection" collection's page
+ And I follow "Profile"
+ And I follow "My Beautiful Canonical Tag" within ".tags"
+ Then I should see "My Beautiful Canonical Tag" within "h2.heading"
+ And I should see "3 Collections" within "h2.heading"
+
+ Scenario: We can find collection listings for a tag through the buttons at the top of the tag profile and its works/bookmarks pages
+ Given a set of collections for tag page searching
+ When I view the tag "My Beautiful Canonical Tag"
+ And I follow "Collections" within ".primary.header.module"
+ Then I should see "My Beautiful Canonical Tag" within "h2.heading"
+ And I should see "3 Collections" within "h2.heading"
+ When I follow "Works" within "#main"
+ Then I should see "My Beautiful Canonical Tag" within "h2.heading"
+ And I should see "Works" within "h2.heading"
+ When I follow "Collections" within "#main"
+ Then I should see "My Beautiful Canonical Tag" within "h2.heading"
+ And I should see "3 Collections" within "h2.heading"
+ When I follow "Bookmarks" within "#main"
+ Then I should see "My Beautiful Canonical Tag" within "h2.heading"
+ And I should see "Bookmarked Items" within "h2.heading"
+ When I follow "Collections" within "#main"
+ Then I should see "My Beautiful Canonical Tag" within "h2.heading"
+ And I should see "3 Collections" within "h2.heading"
+
+ Scenario: A tag's collection listings should update when a collection's tags are edited
+ Given a set of collections for tag page searching
+ When I am logged in as the owner of "Beautiful Tag Test Collection"
+ And I go to "Beautiful Tag Test Collection" collection's page
+ And I follow "Profile"
+ And I follow "Collection Settings"
+ And I fill in "Collection Tags" with ""
+ And I press "Update"
+ And all indexing jobs have been run
+ And I go to the collections tagged "My Beautiful Canonical Tag"
+ Then I should see "My Beautiful Canonical Tag" within "h2.heading"
+ And I should see "2 Collections" within "h2.heading"
+ And I should see "Multiple Tag Test Collection"
+ And I should see "Gorgeous Tag Test Collection"
+ But I should not see "Beautiful Tag Test Collection"
+ And I should not see "Noncanonical Tag Test Collection"
diff --git a/features/step_definitions/collection_steps.rb b/features/step_definitions/collection_steps.rb
index b0ab7e70003..9c77c11039f 100644
--- a/features/step_definitions/collection_steps.rb
+++ b/features/step_definitions/collection_steps.rb
@@ -179,6 +179,37 @@
step %{all indexing jobs have been run}
end
+Given "a set of collections for tag page searching" do
+ beautiful = Fandom.where(name: "My Beautiful Canonical Tag", canonical: true).first_or_create!
+ gorgeous = Fandom.find_or_create_by!(name: "My Gorgeous Synonymous Tag")
+ gorgeous.reload.merger = beautiful
+ gorgeous.save!
+ profile = CollectionProfile.create!(faq: "FAQ goes here",
+ intro: "Intro goes here",
+ rules: "Rules go here")
+ FactoryBot.create(:collection,
+ name: "btagtest",
+ title: "Beautiful Tag Test Collection",
+ tag_string: "My Beautiful Canonical Tag",
+ collection_profile: profile)
+ FactoryBot.create(:collection,
+ name: "mtagtest",
+ title: "Multiple Tag Test Collection",
+ tag_string: "My Beautiful Canonical Tag, a noncanonical tag")
+ FactoryBot.create(:collection,
+ name: "ntagtest",
+ title: "Noncanonical Tag Test Collection",
+ tag_string: "a noncanonical tag",
+ challenge: FactoryBot.create(:gift_exchange))
+ FactoryBot.create(:collection,
+ name: "gtagtest",
+ title: "Gorgeous Tag Test Collection",
+ tag_string: "My Gorgeous Synonymous Tag",
+ challenge: FactoryBot.create(:gift_exchange))
+
+ step %{all indexing jobs have been run}
+end
+
### WHEN
When /^I set up (?:a|the) collection "([^"]*)"(?: with name "([^"]*)")?$/ do |title, name|
diff --git a/features/support/paths.rb b/features/support/paths.rb
index 2215470ed95..ef68a15f9d9 100644
--- a/features/support/paths.rb
+++ b/features/support/paths.rb
@@ -216,6 +216,9 @@ def path_to(page_name)
when /^the bookmarks (?:tagged|page for the tag) "(.*)"$/i
step %{all indexing jobs have been run}
tag_bookmarks_path(Tag.find_by_name(Regexp.last_match(1)))
+ when /^the collections tagged "(.*)"$/i
+ step %{all indexing jobs have been run}
+ tag_collections_path(Tag.find_by_name(Regexp.last_match(1)))
when /^the bookmarks in collection "(.*)"$/i
step %{all indexing jobs have been run}
collection_bookmarks_path(Collection.find_by(title: $1))