Sha256: 78067420943ed70a80ef59d490e65ef06e7b67df6d8ff18010aba3d5d8336885
Contents?: true
Size: 1.49 KB
Versions: 3
Compression:
Stored size: 1.49 KB
Contents
require 'rails_helper' describe 'redirection' do let(:logged_user) { create :user } before do sign_in logged_user end context 'when switcher controller raises no tenant set' do # This is to prevent a redirect loop before do allow_any_instance_of(User).to receive(:user_accounts).and_raise(ActsAsTenant::Errors::NoTenantSet) end it 'shows the error' do get '/u/switcher' expect(response).to have_http_status(:internal_server_error) end end it do get '/u/cosas' expect(response).to have_http_status(:ok) end context 'when has been removed from account' do let!(:other_account) { create :account } let!(:other_user_account) { logged_user.user_accounts.create(account: other_account) } it 'redirects to switcher' do get '/u/cosas' expect(response).to redirect_to users_account_switcher_path follow_redirect! expect(response.body).to include 'Switcher' post "/u/switcher/#{other_user_account.to_param}" expect(response).to redirect_to(root_path) follow_redirect! expect(response.body).to include other_account.to_s other_user_account.destroy! get '/' expect(response).to redirect_to users_account_switcher_path end end context 'when belongs to other account' do before do create :account, subdomain: 'other' host! 'other.example.com' end it do get '/u/cosas' expect(response).to redirect_to new_user_session_path end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pg_rails-7.5.2 | pg_engine/spec/requests/users/switcher_spec.rb |
pg_rails-7.5.1 | pg_engine/spec/requests/users/switcher_spec.rb |
pg_rails-7.5.0 | pg_engine/spec/requests/users/switcher_spec.rb |