Sha256: d6c1388e00ab264e50b1e794438876f25ebce8575151a0026a50be7bebbe8112

Contents?: true

Size: 1.09 KB

Versions: 19

Compression:

Stored size: 1.09 KB

Contents

require 'test_helper'

class MeritUnitTest < ActiveSupport::TestCase
  test 'extends only meritable models' do
    assert User.method_defined?(:points), 'has_merit adds methods'
    assert !Address.method_defined?(:points), 'other models aren\'t extended'
  end

  test 'Badges get "related_models" methods' do
    Comment.new; User.new # load meritable classes
    assert Merit::Badge.method_defined?(:comments), 'Badge#comments should be defined'
    assert Merit::Badge.method_defined?(:users), 'Badge#users should be defined'
  end

  test 'unknown ranking raises exception' do
    class WeirdRankRules
      include Merit::RankRulesMethods
      def initialize
        set_rank level: 1, to: User, level_name: :clown
      end
    end
    assert_raises Merit::RankAttributeNotDefined do
      WeirdRankRules.new.check_rank_rules
    end
  end

  test 'Badge#custom_fields_hash saves correctly' do
    Merit::Badge.create(id: 99,
                        name: 'test-badge',
                        custom_fields: { key_1: 'value1' })
    assert_equal 'value1', Merit::Badge.find(99).custom_fields[:key_1]
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
merit-4.0.3 test/unit/merit_unit_test.rb
qalam_merit-4.5.12 test/unit/merit_unit_test.rb
merit-4.0.2 test/unit/merit_unit_test.rb
qalam_merit-4.5.11 test/unit/merit_unit_test.rb
qalam_merit-4.5.10 test/unit/merit_unit_test.rb
qalam_merit-4.5.09 test/unit/merit_unit_test.rb
qalam_merit-4.5.08 test/unit/merit_unit_test.rb
qalam_merit-4.5.07 test/unit/merit_unit_test.rb
qalam_merit-4.5.06 test/unit/merit_unit_test.rb
qalam_merit-4.5.05 test/unit/merit_unit_test.rb
qalam_merit-4.5.04 test/unit/merit_unit_test.rb
qalam_merit-4.5.03 test/unit/merit_unit_test.rb
qalam_merit-4.5.02 test/unit/merit_unit_test.rb
qalam_merit-4.5.01 test/unit/merit_unit_test.rb
qalam_merit-4.5.00 test/unit/merit_unit_test.rb
qalam_merit-4.0.4 test/unit/merit_unit_test.rb
qalam_merit-4.0.35 test/unit/merit_unit_test.rb
merit-4.0.1 test/unit/merit_unit_test.rb
merit-4.0.0 test/unit/merit_unit_test.rb