Skip to content

Commit 0aa2417

Browse files
committed
AO3-5513 Review
Hello reviewdog
1 parent 7685a73 commit 0aa2417

18 files changed

+55
-116
lines changed

app/controllers/fandoms_controller.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ def index
55
if @collection
66
@media = Media.canonical.by_name - [Media.find_by(name: ArchiveConfig.MEDIA_NO_TAG_NAME)] - [Media.find_by(name: ArchiveConfig.MEDIA_UNCATEGORIZED_NAME)]
77
@page_subtitle = @collection.title
8-
@medium = Media.find_by_name(params[:medium_id]) if params[:medium_id]
8+
@medium = Media.find_by_name(params[:media_id]) if params[:media_id]
99
@counts = SearchCounts.fandom_ids_for_collection(@collection)
1010
@fandoms = (@medium ? @medium.fandoms : Fandom.all).where(id: @counts.keys).by_name
11-
elsif params[:medium_id]
12-
if @medium = Media.find_by_name(params[:medium_id])
11+
elsif params[:media_id]
12+
if @medium = Media.find_by_name(params[:media_id])
1313
@page_subtitle = @medium.name
1414
if @medium == Media.uncategorized
1515
@fandoms = @medium.fandoms.in_use.by_name
1616
else
1717
@fandoms = @medium.fandoms.canonical.by_name.with_count
1818
end
1919
else
20-
raise ActiveRecord::RecordNotFound, "Couldn't find media category named '#{params[:medium_id]}'"
20+
raise ActiveRecord::RecordNotFound, "Couldn't find media category named '#{params[:media_id]}'"
2121
end
2222
else
23-
redirect_to media_path(notice: "Please choose a media category to start browsing fandoms.")
23+
redirect_to media_index_path(notice: "Please choose a media category to start browsing fandoms.")
2424
return
2525
end
2626
@fandoms_by_letter = @fandoms.group_by {|f| f.sortable_name[0].upcase}
@@ -30,7 +30,7 @@ def show
3030
@fandom = Fandom.find_by_name(params[:id])
3131
if @fandom.nil?
3232
flash[:error] = ts("Could not find fandom named %{fandom_name}", fandom_name: params[:id])
33-
redirect_to media_path and return
33+
redirect_to media_index_path and return
3434
end
3535
@characters = @fandom.characters.canonical.by_name
3636
end

app/controllers/media_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ def index
2020
end
2121

2222
def show
23-
redirect_to medium_fandoms_path(medium_id: params[:id])
23+
redirect_to media_fandoms_path(media_id: params[:id])
2424
end
2525
end

app/controllers/tags_controller.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,10 @@ def create
181181
return
182182
end
183183

184-
raise "Redshirt: Attempted to constantize invalid class initialize create #{type.classify}" unless Tag::TYPES.include?(type.classify) || type == "Media"
184+
raise "Redshirt: Attempted to constantize invalid class initialize create #{type.classify}" unless Tag::TYPES.include?(type.classify)
185185

186186
model = begin
187-
type == "Media" ? type.constantize : type.classify.constantize
187+
type.classify.constantize
188188
rescue StandardError
189189
nil
190190
end
@@ -248,7 +248,7 @@ def update
248248
new_tag_type = params[:tag].delete(:type)
249249

250250
# Limiting the conditions under which you can update the tag type
251-
types = logged_in_as_admin? ? Tag::TYPES : Tag::USER_DEFINED
251+
types = logged_in_as_admin? ? (Tag::USER_DEFINED + %w[Media]) : Tag::USER_DEFINED
252252
@tag = @tag.recategorize(new_tag_type) if @tag.can_change_type? && (types + %w[UnsortedTag]).include?(new_tag_type)
253253

254254
unless params[:tag].empty?

app/views/bookmarks/index.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<% end %>
4747
4848
<% unless @owner.present? || @bookmarkable.present? %>
49-
<p><%= ts("These are some of the latest bookmarks created on the Archive. To find more bookmarks, #{link_to 'choose a fandom', media_path} or #{link_to 'try our advanced search', search_bookmarks_path}.").html_safe %>
49+
<p><%= ts("These are some of the latest bookmarks created on the Archive. To find more bookmarks, #{link_to 'choose a fandom', media_index_path} or #{link_to 'try our advanced search', search_bookmarks_path}.").html_safe %>
5050
<% end %>
5151
5252
<%== pagy_nav @pagy %>

app/views/fandoms/index.html.erb

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<% if @collection %>
44
<%= link_to(@collection.title, @collection) %> > <%= ts("Fandoms") %>
55
<% elsif @medium %>
6-
<%= link_to ts("Fandoms"), media_path %> > <%= @medium.name %>
6+
<%= link_to ts("Fandoms"), media_index_path %> > <%= @medium.name %>
77
<% else %>
8-
<%= link_to ts("Fandoms"), media_path %>
8+
<%= link_to ts("Fandoms"), media_index_path %>
99
<% end %>
1010
</h2>
1111
<p>You can search this page by pressing <kbd>ctrl F</kbd> / <kbd>cmd F</kbd> and typing in what you are looking for.</p>
@@ -14,7 +14,7 @@
1414
<%= form_tag "", method: :get, class: "filter", id: "media-filter" do %>
1515
<fieldset>
1616
<p title="<%=ts("Choose media type") %>">
17-
<%= select_tag :medium_id, options_for_select(["All Media Types"] + @media.map{|m| m.name}, params[:medium_id]) %>
17+
<%= select_tag :media_id, options_for_select(["All Media Types"] + @media.map{|m| m.name}, params[:media_id]) %>
1818
<%= submit_tag ts("Show") %>
1919
</p>
2020
</fieldset>

app/views/home/_fandoms.html.erb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<ul>
2-
<li><%= link_to t(".all_fandoms"), media_path %></li>
2+
<li><%= link_to t(".all_fandoms"), media_index_path %></li>
33
<%# When changing the cache key, also update Media#expire_caches %>
44
<% cache "homepage-fandoms-version1", skip_digest: true do %>
55
<% Media.for_menu.each do |medium| %>
66
<% unless medium.id.nil? %>
7-
<li><%= link_to ts("#{medium.name}"), medium_fandoms_path(medium) %></li>
7+
<li><%= link_to ts("#{medium.name}"), media_fandoms_path(medium) %></li>
88
<% end %>
99
<% end %>
1010
<% end %>

app/views/home/first_login_help.html.erb

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@
6464
<% media_movie = Media.find_by_name("Movies") %>
6565
<%= t(".browsing.html",
6666
fandoms_link: link_to(t(".browsing.fandoms"), menu_fandoms_path),
67-
all_fandoms_link: link_to(t(".browsing.all_fandoms"), media_path),
67+
all_fandoms_link: link_to(t(".browsing.all_fandoms"), media_index_path),
6868
movies_link: if media_movie
69-
link_to(t(".browsing.movies"), medium_fandoms_path(media_movie))
69+
link_to(t(".browsing.movies"), media_fandoms_path(media_movie))
7070
else
7171
t(".browsing.movies")
7272
end,

app/views/home/site_map.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<h3 class="heading"><%= t(".explore.header") %></h3>
44
<ul>
55
<li><%= link_to t(".explore.homepage"), root_path %></li>
6-
<li><%= link_to t(".explore.fandoms"), media_path %></li>
6+
<li><%= link_to t(".explore.fandoms"), media_index_path %></li>
77
<li><%= link_to t(".explore.recent_works"), works_path %></li>
88
<li><%= link_to t(".explore.people"), search_people_path %></li>
99
<li><%= link_to t(".explore.bookmarks"), bookmarks_path %></li>

app/views/media/index.html.erb

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<ul class="media fandom index group">
77
<% for medium in @media %>
88
<li id="medium_<%= medium.id %>" class="medium listbox group">
9-
<h3 class="heading"><%= link_to medium.name, medium_fandoms_path(medium) %></h3>
9+
<h3 class="heading"><%= link_to medium.name, media_fandoms_path(medium) %></h3>
1010

1111
<ol class="index group">
1212
<% for fandom in @fandom_listing[medium] %>
@@ -20,7 +20,7 @@
2020
</ol>
2121

2222
<% unless @fandom_listing[medium].size < 5 %>
23-
<p class="actions" role="navigation"><%= link_to ts("All %{media_type}...", :media_type => medium.name), medium_fandoms_path(medium) %></p>
23+
<p class="actions" role="navigation"><%= link_to ts("All %{media_type}...", :media_type => medium.name), media_fandoms_path(medium) %></p>
2424
<% end %>
2525
</li>
2626
<% end %>

app/views/menu/_menu_fandoms.html.erb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<ul class="menu">
2-
<li><%= link_to t(".all"), media_path %></li>
2+
<li><%= link_to t(".all"), media_index_path %></li>
33
<%# When changing the cache key, also update Media#expire_caches %>
44
<% cache "menu-fandoms-version4", skip_digest: true do %>
55
<% Media.for_menu.each do |medium| %>
66
<% unless medium.id.nil? %>
7-
<li id="medium_<%= medium.id %>"><%= link_to medium.name, medium_fandoms_path(medium) %></li>
7+
<li id="medium_<%= medium.id %>"><%= link_to medium.name, media_fandoms_path(medium) %></li>
88
<% end %>
99
<% end %>
1010
<% end %>

app/views/tags/edit.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
<dt><%= ts("Category") %></dt>
4949
<dd>
50-
<% types = logged_in_as_admin? ? Tag::TYPES : Tag::USER_DEFINED %>
50+
<% types = logged_in_as_admin? ? (Tag::USER_DEFINED + %w[Media]) : Tag::USER_DEFINED %>
5151
<% if @tag.can_change_type? %>
5252
<%= f.select :type,
5353
options_for_select(types + %w[UnsortedTag],

app/views/works/index.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<!---/subnav-->
4444

4545
<% unless @owner.present? %>
46-
<p><%= ts("These are some of the latest works posted to the Archive. To find more works, #{link_to 'choose a fandom', media_path} or #{link_to 'try our advanced search', search_works_path}.").html_safe %>
46+
<p><%= ts("These are some of the latest works posted to the Archive. To find more works, #{link_to 'choose a fandom', media_index_path} or #{link_to 'try our advanced search', search_works_path}.").html_safe %>
4747
<% end %>
4848

4949
<%== pagy_nav @pagy %>

config/initializers/inflections.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
# Add new inflection rules using the following format. Inflections
44
# are locale specific, and you may define rules for as many different
55
# locales as you wish. All of these examples are active by default:
6-
# ActiveSupport::Inflector.inflections(:en) do |inflect|
6+
ActiveSupport::Inflector.inflections(:en) do |inflect|
7+
inflect.irregular "Media", "Media"
78
# inflect.plural /^(ox)$/i, "\\1en"
89
# inflect.singular /^(ox)en/i, "\\1"
9-
# inflect.irregular "person", "people"
1010
# inflect.uncountable %w( fish sheep )
11-
# end
11+
end
1212

1313
# These inflection rules are supported but not enabled by default:
1414
# ActiveSupport::Inflector.inflections(:en) do |inflect|

features/collections/collection_navigation.feature

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ Feature: Basic collection navigation
8282
And I post the work "Breaking Free" with fandom "High School Musical" in the collection "We all sing together"
8383
And I go to "We all sing together" collection's page
8484
And I follow "Fandoms ("
85-
And I select "Movies" from "medium_id"
85+
And I select "Movies" from "media_id"
8686
And I press "Show"
8787
Then I should see "High School Musical"
8888
And I should not see "Steven's Universe"
89-
When I select "TV Shows" from "medium_id"
89+
When I select "TV Shows" from "media_id"
9090
And I press "Show"
9191
Then I should not see "High School Musical"
9292
And I should see "Steven's Universe"

features/step_definitions/tag_steps.rb

+3-7
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,6 @@
102102
rel.add_association(fand)
103103
end
104104

105-
Given "the non(-)canonical media {string}" do |tag_name|
106-
Media.find_or_create_by_name(tag_name)
107-
end
108-
109105
Given /^a (non-?canonical|canonical) (\w+) "([^\"]*)"$/ do |canonical_status, tag_type, tag_name|
110106
t = tag_type.classify.constantize.find_or_create_by_name(tag_name)
111107
t.canonical = canonical_status == "canonical"
@@ -230,16 +226,16 @@
230226
blank_tag.save!(validate: false)
231227
end
232228

233-
Given "I have just created the canonical media tag {string}" do |name|
229+
Given "I create the canonical media tag {string}" do |name|
234230
step %{I am logged in as a "tag_wrangling" admin}
235231
visit(new_tag_path)
236232
fill_in("Name", with: name)
237-
choose("Medium")
233+
choose("Media")
238234
check("Canonical")
239235
click_button("Create Tag")
240236
end
241237

242-
Given "I have just recategorized the {string} fandom as a {string} tag" do |name, tag_type|
238+
Given "I recategorize the {string} fandom as a {string} tag" do |name, tag_type|
243239
step %{I am logged in as a "tag_wrangling" admin}
244240
visit(edit_tag_path(Fandom.create(name: name)))
245241
select(tag_type, from: "tag_type")

features/support/paths.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def path_to(page_name)
1111
when /the home\s?page/
1212
'/'
1313
when /the media page/
14-
media_path
14+
media_index_path
1515
when /^the search bookmarks page$/i
1616
step %{all indexing jobs have been run}
1717
search_bookmarks_path
@@ -278,7 +278,7 @@ def path_to(page_name)
278278
when /^the unassigned fandoms page $/i
279279
unassigned_fandoms_path
280280
when /^the "(.*)" fandoms page$/i
281-
medium_fandoms_path(Media.find_by(name: Regexp.last_match(1)))
281+
media_fandoms_path(Media.find_by(name: Regexp.last_match(1)))
282282
when /^the "(.*)" tag page$/i
283283
tag_path(Tag.find_by_name($1))
284284
when /^the '(.*)' tag edit page$/i

features/tags_and_wrangling/tag_wrangling_banned.feature

-57
This file was deleted.

0 commit comments

Comments
 (0)