Sha256: 3ef273c7e00561341115dac461d7e609386c6ec8b282b458ac276ef81014b58e

Contents?: true

Size: 1.11 KB

Versions: 6

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'

describe "Articles" do
  let(:valid_params) { { :article => { :title => 'Doh', :content => Faker::Lorem.sentence } } }

  context "versioning disabled" do
    specify { PaperTrail.should_not be_enabled }

    it "should not create a version" do
      PaperTrail.should be_enabled_for_controller
      expect { post articles_path(valid_params) }.to_not change(PaperTrail::Version, :count)
      PaperTrail.should_not be_enabled_for_controller
    end

    it "should not leak the state of the `PaperTrail.enabled_for_controller?` into the next test" do
      PaperTrail.should be_enabled_for_controller
    end
  end

  with_versioning do
    let(:article) { Article.last }

    context "`current_user` method returns a `String`" do
      if RUBY_VERSION.to_f >= 1.9
        it "should set that value as the `whodunnit`" do
          expect { post articles_path(valid_params) }.to change(PaperTrail::Version, :count).by(1)
          article.title.should == 'Doh'
          PaperTrail.whodunnit.should == 'foobar'
          article.versions.last.whodunnit.should == 'foobar'
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
paper_trail-3.0.9 spec/requests/articles_spec.rb
paper_trail-3.0.8 spec/requests/articles_spec.rb
paper_trail-3.0.7 spec/requests/articles_spec.rb
paper_trail-3.0.6 spec/requests/articles_spec.rb
paper_trail-3.0.5 spec/requests/articles_spec.rb
paper_trail-3.0.2 spec/requests/articles_spec.rb