Sha256: a5d3493d4ba7d05b9c4955bc9f5f58114275003af16b5bbb6a4518d8b8384477

Contents?: true

Size: 1.5 KB

Versions: 11

Compression:

Stored size: 1.5 KB

Contents

require 'spec_helper'

class AuditsController < ActionController::Base
  def audit
    @company = Company.create
    render :nothing => true
  end

  def update_user
    current_user.update_attributes( :password => 'foo')
    render :nothing => true
  end

  private

  attr_accessor :current_user
  attr_accessor :custom_user
end

describe AuditsController do
  include RSpec::Rails::ControllerExampleGroup

  before(:each) do
    ActsAsAudited.current_user_method = :current_user
  end

  let( :user ) { create_user }

  describe "POST audit" do

    it "should audit user" do
      controller.send(:current_user=, user)

      expect {
        post :audit
      }.to change( Audit, :count )

      assigns(:company).audits.last.user.should == user
    end

    it "should support custom users for sweepers" do
      controller.send(:custom_user=, user)
      ActsAsAudited.current_user_method = :custom_user

      expect {
        post :audit
      }.to change( Audit, :count )

      assigns(:company).audits.last.user.should == user
    end

    it "should record the remote address responsible for the change" do
      request.env['REMOTE_ADDR'] = "1.2.3.4"
      controller.send(:current_user=, user)

      post :audit

      assigns(:company).audits.last.remote_address.should == '1.2.3.4'
    end

  end

  describe "POST update_user" do

    it "should not save blank audits" do
      controller.send(:current_user=, user)

      expect {
        post :update_user
      }.to_not change( Audit, :count )
    end

  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/acts_as_audited-2.1.0/spec/audit_sweeper_spec.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/acts_as_audited-2.1.0/spec/audit_sweeper_spec.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/acts_as_audited-2.1.0/spec/audit_sweeper_spec.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/acts_as_audited-2.1.0/spec/audit_sweeper_spec.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/acts_as_audited-2.1.0/spec/audit_sweeper_spec.rb
acts_as_audited-2.1.0 spec/audit_sweeper_spec.rb
acts_as_audited-2.0.0 spec/audit_sweeper_spec.rb
acts_as_audited-2.0.0.rc7 spec/audit_sweeper_spec.rb
acts_as_audited-2.0.0.rc6 spec/audit_sweeper_spec.rb
acts_as_audited-2.0.0.rc5 spec/audit_sweeper_spec.rb
acts_as_audited-2.0.0.rc4 spec/audit_sweeper_spec.rb