Convert `settings/sessions` spec controller->system (#34072)
parent
debe6c0545
commit
b021cfc91e
|
@ -1,33 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Settings::SessionsController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:session_activation) { Fabricate(:session_activation, user: user) }
|
||||
|
||||
before { sign_in user, scope: :user }
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
subject { delete :destroy, params: { id: id } }
|
||||
|
||||
context 'when session activation exists' do
|
||||
let(:id) { session_activation.id }
|
||||
|
||||
it 'destroys session activation' do
|
||||
expect(subject).to redirect_to edit_user_registration_path
|
||||
expect(SessionActivation.find_by(id: id)).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when session activation does not exist' do
|
||||
let(:id) { session_activation.id + 1000 }
|
||||
|
||||
it 'destroys session activation' do
|
||||
expect(subject).to have_http_status 404
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Settings Sessions' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
||||
before { sign_in(user) }
|
||||
|
||||
describe 'DELETE /settings/sessions/:id' do
|
||||
context 'when session activation does not exist' do
|
||||
it 'returns not found' do
|
||||
delete settings_session_path(123_456_789)
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(404)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Settings Sessions' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let!(:session_activation) { Fabricate(:session_activation, user: user) }
|
||||
|
||||
before { sign_in(user) }
|
||||
|
||||
describe 'deleting a session' do
|
||||
it 'deletes listed session activation from the auth page' do
|
||||
visit edit_user_registration_path
|
||||
expect(page)
|
||||
.to have_title(I18n.t('settings.account_settings'))
|
||||
|
||||
expect { click_on(I18n.t('sessions.revoke')) }
|
||||
.to change(SessionActivation, :count).by(-1)
|
||||
expect { session_activation.reload }
|
||||
.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect(page)
|
||||
.to have_content(I18n.t('sessions.revoke_success'))
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue