Sha256: 488d38839baf472cf8c7d6a60c03d5004dc9f5f5983c1ee6c80e988d42185af6

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'

# Tests controller `info_for_draftsman` method
describe InformantsController, type: :controller do
  let(:trashable) { Trashable.create!(name: 'Bob') }

  describe 'create' do
    before { post :create }
    subject { Draftsman::Draft.last }

    it 'records `ip` from custom `info_for_draftsman`' do
      expect(subject.ip).to eql '123.45.67.89'
    end

    it 'records `user_agent` from custom `info_for_draftsman`' do
      expect(subject.user_agent).to eql '007'
    end
  end

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

    it 'records `ip` from custom `info_for_draftsman`' do
      expect(subject.ip).to eql '123.45.67.89'
    end

    it 'records `user_agent` from custom `info_for_draftsman`' do
      expect(subject.user_agent).to eql '007'
    end
  end

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

    it 'records `ip` from custom `info_for_draftsman`' do
      expect(subject.ip).to eql '123.45.67.89'
    end

    it 'records `user_agent` from custom `info_for_draftsman`' do
      expect(subject.user_agent).to eql '007'
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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