Sha256: 292194e53af3e426d5826914e77f9cb7efcc5475d7c3dedae7fac4f175813116

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'
require 'support/feature_detection'

# Tests the automatic usage of `current_user` as the `whodunnit` attribute on the draft object
describe WhodunnitsController, type: :controller do
  let(:trashable) { Trashable.create!(name: 'Bob') }

  describe 'create' do
    it 'records `current_user` via `user_for_draftsman' do
      post :create
      expect(Draftsman::Draft.last.whodunnit).to eql '153'
    end
  end

  describe 'update' do
    it 'records `current_user` via `user_for_draftsman' do
      if request_test_helpers_require_keyword_args?
        put :update, params: { id: trashable.id }
      else
        put :update, id: trashable.id
      end

      expect(Draftsman::Draft.last.whodunnit).to eql '153'
    end
  end

  describe 'destroy' do
    it 'records `current_user` via `user_for_draftsman' do
      if request_test_helpers_require_keyword_args?
        delete :destroy, params: { id: trashable.id }
      else
        delete :destroy, id: trashable.id
      end

      expect(Draftsman::Draft.last.whodunnit).to eql '153'
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
draftsman-0.7.2 spec/controllers/whodunnits_controller_spec.rb
draftsman-0.7.1 spec/controllers/whodunnits_controller_spec.rb
draftsman-0.7.0 spec/controllers/whodunnits_controller_spec.rb