Sha256: 9e08ad70d859ac7f780ee98968d71263683ab54da781ecf846ca93fed3fd7f6f

Contents?: true

Size: 1.68 KB

Versions: 14

Compression:

Stored size: 1.68 KB

Contents

require File.dirname(__FILE__) + '/../test_helper.rb'

module SessionTest
  module SessionTest
    class ConfigTest < ActiveSupport::TestCase
      def test_disable_magic_states_config
        UserSession.disable_magic_states = true
        assert_equal true, UserSession.disable_magic_states

        UserSession.disable_magic_states false
        assert_equal false, UserSession.disable_magic_states
      end
    end

    class InstanceMethodsTest < ActiveSupport::TestCase
      def test_disabling_magic_states
        UserSession.disable_magic_states = true

        ben = users(:ben)
        ben.update_attribute(:active, false)
        assert UserSession.create(ben)

        UserSession.disable_magic_states = false
      end

      def test_validate_validate_magic_states_active
        session = UserSession.new
        ben = users(:ben)
        session.unauthorized_record = ben
        assert session.valid?

        ben.update_attribute(:active, false)
        assert !session.valid?
        assert session.errors[:base].size > 0
      end

      def test_validate_validate_magic_states_approved
        session = UserSession.new
        ben = users(:ben)
        session.unauthorized_record = ben
        assert session.valid?

        ben.update_attribute(:approved, false)
        assert !session.valid?
        assert session.errors[:base].size > 0
      end

      def test_validate_validate_magic_states_confirmed
        session = UserSession.new
        ben = users(:ben)
        session.unauthorized_record = ben
        assert session.valid?

        ben.update_attribute(:confirmed, false)
        assert !session.valid?
        assert session.errors[:base].size > 0
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
refinerycms-0.9.6.34 vendor/plugins/authlogic/test/session_test/magic_states_test.rb
refinerycms-0.9.6.33 vendor/plugins/authlogic/test/session_test/magic_states_test.rb
refinerycms-0.9.6.32 vendor/plugins/authlogic/test/session_test/magic_states_test.rb
refinerycms-0.9.6.31 vendor/plugins/authlogic/test/session_test/magic_states_test.rb
refinerycms-0.9.6.30 vendor/plugins/authlogic/test/session_test/magic_states_test.rb
refinerycms-0.9.6.29 vendor/plugins/authlogic/test/session_test/magic_states_test.rb
refinerycms-0.9.6.28 vendor/plugins/authlogic/test/session_test/magic_states_test.rb
refinerycms-0.9.6.27 vendor/plugins/authlogic/test/session_test/magic_states_test.rb
refinerycms-0.9.6.26 vendor/plugins/authlogic/test/session_test/magic_states_test.rb
refinerycms-0.9.6.25 vendor/plugins/authlogic/test/session_test/magic_states_test.rb
refinerycms-0.9.6.24 vendor/plugins/authlogic/test/session_test/magic_states_test.rb
refinerycms-0.9.6.23 vendor/plugins/authlogic/test/session_test/magic_states_test.rb
refinerycms-0.9.6.22 vendor/plugins/authlogic/test/session_test/magic_states_test.rb
refinerycms-0.9.6.21 vendor/plugins/authlogic/test/session_test/magic_states_test.rb