Skip to content

Commit

Permalink
AO3-6796 - fix QA returns for 500 error on fandom_id
Browse files Browse the repository at this point in the history
  • Loading branch information
AliceLoeser committed Sep 17, 2024
1 parent f3f1bbe commit f0f0121
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 2 additions & 4 deletions app/controllers/works_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@ def index

options = params[:work_search].present? ? clean_work_search_params : {}

if params[:fandom_id] || (@collection.present? && @tag.present?)
if params[:fandom_id].present?
@fandom = Fandom.find(params[:fandom_id])
end
if params[:fandom_id].present? || (@collection.present? && @tag.present?)
@fandom = Fandom.find(params[:fandom_id]) if params[:fandom_id]

tag = @fandom || @tag

Expand Down
8 changes: 8 additions & 0 deletions spec/controllers/works/default_rails_actions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,14 @@ def call_with_params(params)
end
end

describe "when the fandom id is empty" do
it "returns the work" do
params = { fandom_id: nil }
get :index, params: params
expect(assigns(:works)).to include(@work)
end
end

describe "without caching" do
before do
AdminSetting.first.update_attribute(:enable_test_caching, false)
Expand Down

0 comments on commit f0f0121

Please sign in to comment.