Sha256: ad4b500c36a3e750d588941ca32dd97e09e986d717a3c4235a19b561d4fa5c09

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

RSpec.describe Transcript::Controller, type: :controller do
  controller ActionController::Base do
    include Transcript::Controller

    def edit
      @user = FactoryGirl.create(:user)
      @post = FactoryGirl.create(:post)
      @meta = "metadata"
      audit_action @user, @post, @meta

      head :ok
    end

    def custom
      @user = FactoryGirl.create(:user)
      @post = FactoryGirl.create(:post)
      @meta = "metadata"
      audit_action @user, @post, "custom", @meta

      head :ok
    end
  end

  it "creates an audit entry by inferring the action" do
    ActiveJob::Base.queue_adapter.enqueued_jobs.clear
    routes.draw { get "edit" => "anonymous#edit" }

    get :edit

    expect(Transcript::Job).to have_been_enqueued
                           .with do |actor, receiver, action, meta|
      expect(actor).to be_a User
      expect(receiver).to be_a Post
      expect(action).to eq "edit"
      expect(meta).to eq "metadata"
    end
  end

  it "creates an audit entry with a given action" do
    ActiveJob::Base.queue_adapter.enqueued_jobs.clear
    routes.draw { get "custom" => "anonymous#custom" }

    get :custom

    expect(Transcript::Job).to have_been_enqueued
                           .with do |actor, receiver, action, meta|
      expect(actor).to be_a User
      expect(receiver).to be_a Post
      expect(action).to eq "custom"
      expect(meta).to eq "metadata"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
transcript-0.3.0 spec/transcript/controller_spec.rb