Sha256: 38c3d5df59b84feeceeeab1211918497d26b769d0097d939faed7b9825e9383a

Contents?: true

Size: 1.33 KB

Versions: 12

Compression:

Stored size: 1.33 KB

Contents

require 'test_helper'

class ErrorTest < ActiveSupport::TestCase

  context "model attributes" do
    setup do
      @error = FactoryGirl.create(:error)
    end

    should "have right fields" do
      @error.status
    end

    should "default status to active" do
      assert @error.active?
    end
  end

  context "model validations" do
    setup do
      @error = FactoryGirl.create(:error)
    end

    should "force backtrace_hash to be unique" do
      @second_error = FactoryGirl.create(:error)
      @second_error.backtrace = @error.backtrace
      assert_not @second_error.valid?
    end
  end

  context "model linkages" do
    setup do
      @error = FactoryGirl.create(:error)
    end

    should "have correct relations" do
      @error.error_occurrences
    end

    should "have counter cache for occurrences" do
      assert_difference '@error.reload.occurrence_count', 1 do
        @error.error_occurrences.create
      end
    end

    should "set the last experiencer to the last occurrence's user" do
      @occ1 = @error.error_occurrences.create(experiencer: users(:user))
      @occ2 = @error.error_occurrences.create(experiencer: users(:user2))
      assert_equal @occ2.reload.experiencer, @error.reload.last_experiencer
    end
  end

  context "methods" do
    setup do
      @error = FactoryGirl.create(:error)
    end
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
errdo-0.12.7 test/models/error_test.rb
errdo-0.12.6 test/models/error_test.rb
errdo-0.12.5 test/models/error_test.rb
errdo-0.12.4 test/models/error_test.rb
errdo-0.12.3 test/models/error_test.rb
errdo-0.12.2 test/models/error_test.rb
errdo-0.12.1 test/models/error_test.rb
errdo-0.12.0 test/models/error_test.rb
errdo-0.11.6 test/models/error_test.rb
errdo-0.11.5 test/models/error_test.rb
errdo-0.11.4 test/models/error_test.rb
errdo-0.11.3 test/models/error_test.rb