ref: master
plugins/classify_members/test/unit/classify_members_plugin_test.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
require 'test_helper' class ClassifyMembersPluginTest < ActiveSupport::TestCase def setup @env = fast_create(Environment) @p1 = fast_create(Person, :environment_id => @env.id) @c1 = fast_create(Community, :environment_id => @env.id) @c2 = fast_create(Community, :environment_id => @env.id) @c3 = fast_create(Community, :environment_id => @env.id) @plugin = ClassifyMembersPlugin.new self end def environment @env end should 'not crash for nil setting' do assert_equal [], @plugin.find_community(@p1) end should 'list all classification communities' do @plugin.settings.communities = " #{@c1.identifier}: Tag1 #{@c2.identifier} " @env.save! assert_equal [[@c1, 'Tag1'], [@c2, @c2.name]], @plugin.communities end should 'list the classification communities for a person' do @c1.add_member @p1 @c2.add_member @p1 @p1.stubs(:is_member_of?).returns(false) @p1.stubs(:is_member_of?).with(@c1).returns(true) @p1.stubs(:is_member_of?).with(@c2).returns(true) @plugin.settings.communities = " #{@c1.identifier}: Tag1 #{@c2.identifier}: Tag2 #{@c3.identifier}: Tag3 " @env.save! assert_equal [[@c1, 'Tag1'], [@c2, 'Tag2']], @plugin.find_community(@p1) end end |