Sha256: 324cb39dc70b92a7cd9f820ce50667bd4d8e1f190b51bd6290cdc3e292453c87

Contents?: true

Size: 1.31 KB

Versions: 6

Compression:

Stored size: 1.31 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.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.experiencer, @error.last_experiencer
    end
  end

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

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
errdo-0.11.2 test/models/error_test.rb
errdo-0.11.1 test/models/error_test.rb
errdo-0.11.0 test/models/error_test.rb
errdo-0.10.0 test/models/error_test.rb
errdo-0.9.1 test/models/error_test.rb
errdo-0.9.0 test/models/error_test.rb