Sha256: a3ac977e3005de08f08dc7a5dfcb30c097ad0045814028f39a4335ee8315703f

Contents?: true

Size: 893 Bytes

Versions: 3

Compression:

Stored size: 893 Bytes

Contents

require 'spec_helper'

# 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
    before { post :create }
    subject { Draftsman::Draft.last }

    it 'records `current_user` via `user_for_draftsman' do
      expect(subject.whodunnit).to eql '153'
    end
  end

  describe 'update' do
    before { put :update, id: trashable.id }
    subject { Draftsman::Draft.last }

    it 'records `current_user` via `user_for_draftsman' do
      expect(subject.whodunnit).to eql '153'
    end
  end

  describe 'destroy' do
    before { delete :destroy, id: trashable.id }
    subject { Draftsman::Draft.last }

    it 'records `current_user` via `user_for_draftsman' do
      expect(subject.whodunnit).to eql '153'
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
draftsman-0.6.0 spec/controllers/whodunnits_controller_spec.rb
draftsman-0.5.1 spec/controllers/whodunnits_controller_spec.rb
draftsman-0.5.0 spec/controllers/whodunnits_controller_spec.rb