Reformat spec/requests/maintenance_spec.rb
This commit is contained in:
parent
9d2ee08958
commit
16933dde08
1 changed files with 99 additions and 77 deletions
|
@ -4,7 +4,8 @@
|
||||||
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
|
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
require 'controllers/support/shared_user_context'
|
require 'controllers/support/shared_user_context'
|
||||||
|
# rubocop:disable RSpec/InstanceVariable
|
||||||
|
# rubocop:disable RSpec/DescribeClass
|
||||||
describe 'Maintenance Mode' do
|
describe 'Maintenance Mode' do
|
||||||
page = 'http://commet'
|
page = 'http://commet'
|
||||||
token = 'thoathioa'
|
token = 'thoathioa'
|
||||||
|
@ -18,8 +19,8 @@ describe 'Maintenance Mode' do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'in maintenance' do
|
describe 'in maintenance' do
|
||||||
before(:each) do
|
before do
|
||||||
Houdini.maintenance = Houdini::Maintenance.new(active:true, token: token, page: page)
|
Houdini.maintenance = Houdini::Maintenance.new(active: true, token: token, page: page)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects for onboard' do
|
it 'redirects for onboard' do
|
||||||
|
@ -36,64 +37,85 @@ describe 'Maintenance Mode' do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe Users::SessionsController, type: :controller do
|
describe Users::SessionsController, type: :controller do
|
||||||
after(:each) do
|
after do
|
||||||
Houdini.maintenance.active = false
|
Houdini.maintenance.active = false
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'in maintenance' do
|
describe 'in maintenance' do
|
||||||
include_context :shared_user_context
|
include_context :shared_user_context
|
||||||
|
|
||||||
before(:each) do
|
before do
|
||||||
@request.env['devise.mapping'] = Devise.mappings[:user]
|
@request.env['devise.mapping'] = Devise.mappings[:user]
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'in maintenance' do
|
describe 'in maintenance' do
|
||||||
before(:each) do
|
before do
|
||||||
Houdini.maintenance = Houdini::Maintenance.new(active:true, token: token, page: page)
|
Houdini.maintenance = Houdini::Maintenance.new(active: true, token: token, page: page)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects sign_in if the token is wrong' do
|
describe 'redirects sign_in if the token is wrong' do
|
||||||
|
subject do
|
||||||
get(:new, params: { maintenance_token: "#{token}3" })
|
get(:new, params: { maintenance_token: "#{token}3" })
|
||||||
expect(response.code).to eq '302'
|
response
|
||||||
expect(response.location).to eq page
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects for login' do
|
it { is_expected.to have_attributes(code: '302', location: page) }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'redirects to sign_in' do
|
||||||
|
subject do
|
||||||
get(:new)
|
get(:new)
|
||||||
expect(response.code).to eq '302'
|
response
|
||||||
expect(response.location).to eq page
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects sign_in if the token is passed in wrong param' do
|
it { is_expected.to have_attributes(code: '302', location: page) }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'redirects to sign_in if token passed on wrong param' do
|
||||||
|
subject do
|
||||||
get(:new, params: { maintnancerwrwer_token: token.to_s })
|
get(:new, params: { maintnancerwrwer_token: token.to_s })
|
||||||
expect(response.code).to eq '302'
|
response
|
||||||
expect(response.location).to eq page
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'allows sign_in if the token is passed' do
|
it { is_expected.to have_attributes(code: '302', location: page) }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'allows sign_in if the token is passed' do
|
||||||
|
subject do
|
||||||
get(:new, params: { maintenance_token: token.to_s })
|
get(:new, params: { maintenance_token: token.to_s })
|
||||||
expect(response.code).to eq '200'
|
response
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'allows sign_in.json' do
|
it { is_expected.to have_attributes(code: '200') }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'allows sign_in.json if the token is passed' do
|
||||||
|
subject do
|
||||||
get(:new, params: { maintenance_token: token.to_s, format: 'json' })
|
get(:new, params: { maintenance_token: token.to_s, format: 'json' })
|
||||||
expect(response.code).to eq '200'
|
response
|
||||||
|
end
|
||||||
|
|
||||||
|
it { is_expected.to have_attributes(code: '200') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'in maintenance without maintenance_token set' do
|
describe 'in maintenance without maintenance_token set' do
|
||||||
before(:each) do
|
before do
|
||||||
@request.env['devise.mapping'] = Devise.mappings[:user]
|
@request.env['devise.mapping'] = Devise.mappings[:user]
|
||||||
end
|
Houdini.maintenance = Houdini::Maintenance.new(active: true, token: nil, page: page)
|
||||||
before(:each) do
|
|
||||||
Houdini.maintenance = Houdini::Maintenance.new(active:true, token: nil, page: page)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects sign_in if the token is nil' do
|
describe 'redirects sign_in if the token is nil' do
|
||||||
|
subject do
|
||||||
get(:new)
|
get(:new)
|
||||||
expect(response.code).to eq '302'
|
response
|
||||||
expect(response.location).to eq page
|
end
|
||||||
|
|
||||||
|
it { is_expected.to have_attributes(code: '302', location: page) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# rubocop:enable all
|
||||||
|
|
Loading…
Reference in a new issue