Sha256: 6cf13e28c3406de4b87f69b5f96f76179b8ad9af46ffdd9453c95b686da24852

Contents?: true

Size: 1.08 KB

Versions: 12

Compression:

Stored size: 1.08 KB

Contents

require "rails_helper"

describe "Articles management", type: :request, order: :defined do
  let(:valid_params) { { article: { title: "Doh", content: FFaker::Lorem.sentence } } }

  context "versioning disabled" do
    specify { expect(PaperTrail).not_to be_enabled }

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

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

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

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

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/paper_trail-5.2.3/spec/requests/articles_spec.rb
paper_trail-6.0.2 spec/requests/articles_spec.rb
paper_trail-6.0.1 spec/requests/articles_spec.rb
paper_trail-6.0.0 spec/requests/articles_spec.rb
paper_trail-5.2.3 spec/requests/articles_spec.rb
paper_trail-5.2.2 spec/requests/articles_spec.rb
paper_trail-5.2.1 spec/requests/articles_spec.rb
paper_trail-5.2.0 spec/requests/articles_spec.rb
paper_trail-5.1.1 spec/requests/articles_spec.rb
paper_trail-5.1.0 spec/requests/articles_spec.rb
paper_trail-5.0.1 spec/requests/articles_spec.rb
paper_trail-5.0.0 spec/requests/articles_spec.rb