Skip to content

Commit

Permalink
Update pro context redirection tests
Browse files Browse the repository at this point in the history
We're not redirecting to the pro specific request route any more,
instead update these tests to check when the pro livery is used or not.
  • Loading branch information
alexander-griffen authored and gbp committed Mar 26, 2024
1 parent 38e3e77 commit c966b83
Showing 1 changed file with 14 additions and 35 deletions.
49 changes: 14 additions & 35 deletions spec/controllers/request_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,20 @@
end
end

xdescribe "redirecting pro users to the pro context" do
describe "livery used", feature: :alaveteli_pro do
let(:pro_user) { FactoryBot.create(:pro_user) }

before { sign_in pro_user }

context "when showing pros their own requests" do
context "when the request is embargoed" do
let(:info_request) do
FactoryBot.create(:embargoed_request, user: pro_user)
end

it "should always redirect to the pro version of the page" do
with_feature_enabled(:alaveteli_pro) do
sign_in pro_user
get :show, params: { url_title: info_request.url_title }
expect(response).to redirect_to(
show_request_path(url_title: info_request.url_title)
)
end
it 'uses the pro livery' do
get :show, params: { url_title: info_request.url_title }
expect(assigns[:in_pro_area]).to be true
end
end

Expand All @@ -138,12 +135,9 @@
FactoryBot.create(:info_request, user: pro_user)
end

it "should not redirect to the pro version of the page" do
with_feature_enabled(:alaveteli_pro) do
sign_in pro_user
get :show, params: { url_title: info_request.url_title }
expect(response).to be_successful
end
it "should not use the pro livery" do
get :show, params: { url_title: info_request.url_title }
expect(assigns[:in_pro_area]).to be false
end
end
end
Expand All @@ -157,31 +151,16 @@
FactoryBot.create(:embargoed_request, user: pro_user)
end

it 'redirects to the pro version of the page' do
with_feature_enabled(:alaveteli_pro) do
sign_in pro_user
get :show, params: { url_title: info_request.url_title }
expect(response).to redirect_to show_request_path(
url_title: info_request.url_title)
end
end

it 'uses the pro livery' do
with_feature_enabled(:alaveteli_pro) do
sign_in pro_user
get :show, params: { url_title: info_request.url_title, pro: '1' }
expect(assigns[:in_pro_area]).to be true
end
get :show, params: { url_title: info_request.url_title }
expect(assigns[:in_pro_area]).to be true
end
end

context "when showing pros a someone else's request" do
it "should not redirect to the pro version of the page" do
with_feature_enabled(:alaveteli_pro) do
sign_in pro_user
get :show, params: { url_title: 'why_do_you_have_such_a_fancy_dog' }
expect(response).to be_successful
end
it "should not user the pro livery" do
get :show, params: { url_title: 'why_do_you_have_such_a_fancy_dog' }
expect(assigns[:in_pro_area]).to be false
end
end
end
Expand Down

0 comments on commit c966b83

Please sign in to comment.