Sha256: 5022debc4da2f5d289d6d23cc34c3456c65b5f5e74a74631de8b927c2725f479
Contents?: true
Size: 1.66 KB
Versions: 2
Compression:
Stored size: 1.66 KB
Contents
require 'spec_helper' RSpec.describe AuthenticatedController, type: :controller do describe "GET index" do context "when engine is embedded" do before { BookingSync::Engine.embedded! } it "redirects to auth using js" do get :index expect(response.status).to eq(200) expect(response.body).to eq( "<script type='text/javascript'>top.location.href = '/auth/bookingsync/?account_id=';</script>") expect(response.header["Content-Type"]).to include("text/html") end end context "when engine is standalone" do before { BookingSync::Engine.standalone! } it "redirects to auth using 302 redirect" do get :index expect(response.status).to eq(302) expect(response.redirect_url).to eq("http://test.host/auth/bookingsync/?account_id=") expect(response.body).to eq( "<html><body>You are being <a href=\"http://test.host/auth/bookingsync/?account_id=\">redirected</a>.</body></html>") end end end describe "XHR index" do context "when engine is embedded" do before { BookingSync::Engine.embedded! } it "renders the target url in response" do get :index, xhr: true expect(response.status).to eq(401) expect(response.body).to eq("http://test.host/auth/bookingsync/?account_id=") end end context "when engine is standalone" do before { BookingSync::Engine.standalone! } it "renders the target url in response" do get :index, xhr: true expect(response.status).to eq(401) expect(response.body).to eq("http://test.host/auth/bookingsync/?account_id=") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bookingsync-engine-3.0.2 | spec/controllers/authenticated_controller_spec.rb |
bookingsync-engine-3.0.1 | spec/controllers/authenticated_controller_spec.rb |