Sha256: f915b8fb99a4d39ac1887ed593cd20cefd60d442e5a987864cd5c96c2f8bb6fb
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
require 'rails_helper' RSpec.describe UsersController, type: :controller do controller do end before(:each) do reset_to_defaults end context 'when updating a User' do it 'sets the correct updater' do request.session = { user_id: @hera.id } patch :update, 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, 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, id: @hera.id expect(response.status).to eq(200) simulate_second_request end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
activerecord-userstamp-2.1.1 | spec/controllers/users_controller_spec.rb |