Skip to content

Commit

Permalink
Allow JSON requests for petitions before opening
Browse files Browse the repository at this point in the history
It's up to the consumer of the data to respond appropriately.
  • Loading branch information
pixeltrix committed Oct 30, 2024
1 parent 3229a37 commit 8b1132f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/controllers/petitions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ def redirect_to_home_page_if_dissolved
end

def redirect_to_home_page_unless_opened
redirect_to home_url unless Parliament.opened?
unless json_request?
redirect_to home_url unless Parliament.opened?
end
end

def request_format
Expand Down
5 changes: 5 additions & 0 deletions spec/controllers/petitions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,11 @@
get :index
expect(response).to redirect_to("https://petition.parliament.uk/")
end

it "doesn't redirect JSON requests" do
get :index, as: :json
expect(response).to be_successful
end
end
end

Expand Down

0 comments on commit 8b1132f

Please sign in to comment.