Sha256: 441c4cf86fad8ed1f081fc398529e501d233e627be867808831f789d8b482a27
Contents?: true
Size: 1.37 KB
Versions: 3
Compression:
Stored size: 1.37 KB
Contents
require 'rails_helper' RSpec.describe UsersController, type: :controller do controller do end context 'when updating a User' do it 'sets the correct updater' do request.session = { user_id: @hera.id } patch :update, params: { id: @hera.id, user: { name: 'Different'} } expect(response.status).to eq(200) expect(controller.instance_variable_get(:@user).name).to eq('Different') expect(controller.instance_variable_get(:@user).updater).to eq(@hera) end end context 'when handling multiple requests' do def simulate_second_request old_request_session = request.session request.session = { user_id: @zeus.id } post :update, params: { id: @hera.id, user: { name: 'Different Second' } } expect(controller.instance_variable_get(:@user).updater).to eq(@zeus) ensure request.session = old_request_session end it 'sets the correct updater' do request.session = { user_id: @hera.id } get :edit, params: { id: @hera.id } expect(response.status).to eq(200) simulate_second_request end end context 'when the handler raises an exception' do before { @stamper = User.stamper } it 'restores the correct stamper' do begin request.session = { user_id: @zeus.id } post :create rescue end expect(User.stamper).to be(@stamper) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
userstamper-4.1.0 | spec/controllers/users_controller_spec.rb |
userstamper-4.0.1 | spec/controllers/users_controller_spec.rb |
userstamper-4.0.0 | spec/controllers/users_controller_spec.rb |