Commit 083440f474c582d4ead8440bf25a6b2ecb38c286
1 parent
83230b3b
Exists in
master
and in
29 other branches
ActionItem628: adapting tests to refactoring
Showing
4 changed files
with
13 additions
and
18 deletions
Show diff stats
test/functional/tasks_controller_test.rb
@@ -64,7 +64,7 @@ class TasksControllerTest < Test::Unit::TestCase | @@ -64,7 +64,7 @@ class TasksControllerTest < Test::Unit::TestCase | ||
64 | end | 64 | end |
65 | 65 | ||
66 | should 'affiliate roles to user after finish add member task' do | 66 | should 'affiliate roles to user after finish add member task' do |
67 | - t = AddMember.create!(:person => profile, :community => profile) | 67 | + t = AddMember.create!(:person => profile, :organization => profile) |
68 | count = profile.members.size | 68 | count = profile.members.size |
69 | post :close, :decision => 'finish', :id => t.id | 69 | post :close, :decision => 'finish', :id => t.id |
70 | profile = Profile.find(@profile.id) | 70 | profile = Profile.find(@profile.id) |
@@ -72,7 +72,7 @@ class TasksControllerTest < Test::Unit::TestCase | @@ -72,7 +72,7 @@ class TasksControllerTest < Test::Unit::TestCase | ||
72 | end | 72 | end |
73 | 73 | ||
74 | should 'display custom form to add members task' do | 74 | should 'display custom form to add members task' do |
75 | - t = AddMember.create!(:person => profile, :community => profile) | 75 | + t = AddMember.create!(:person => profile, :organization => profile) |
76 | get :index, :profile => profile.identifier | 76 | get :index, :profile => profile.identifier |
77 | assert_tag :tag => 'form', :attributes => { :action => "/myprofile/#{profile.identifier}/tasks/close/#{t.id}" } | 77 | assert_tag :tag => 'form', :attributes => { :action => "/myprofile/#{profile.identifier}/tasks/close/#{t.id}" } |
78 | end | 78 | end |
@@ -80,7 +80,7 @@ class TasksControllerTest < Test::Unit::TestCase | @@ -80,7 +80,7 @@ class TasksControllerTest < Test::Unit::TestCase | ||
80 | should 'display member role checked if target has members' do | 80 | should 'display member role checked if target has members' do |
81 | profile.affiliate(profile, Profile::Roles.admin) | 81 | profile.affiliate(profile, Profile::Roles.admin) |
82 | assert_equal 1, profile.members.size | 82 | assert_equal 1, profile.members.size |
83 | - t = AddMember.create!(:person => profile, :community => profile) | 83 | + t = AddMember.create!(:person => profile, :organization => profile) |
84 | get :index, :profile => profile.identifier | 84 | get :index, :profile => profile.identifier |
85 | assert_tag :tag => 'input', :attributes => { :name => 'task[roles][]', :checked => 'checked', :value => Profile::Roles.member.id } | 85 | assert_tag :tag => 'input', :attributes => { :name => 'task[roles][]', :checked => 'checked', :value => Profile::Roles.member.id } |
86 | end | 86 | end |
@@ -88,7 +88,7 @@ class TasksControllerTest < Test::Unit::TestCase | @@ -88,7 +88,7 @@ class TasksControllerTest < Test::Unit::TestCase | ||
88 | should 'display roles besides role member unchecked if target has members' do | 88 | should 'display roles besides role member unchecked if target has members' do |
89 | profile.affiliate(profile, Profile::Roles.admin) | 89 | profile.affiliate(profile, Profile::Roles.admin) |
90 | assert_equal 1, profile.members.size | 90 | assert_equal 1, profile.members.size |
91 | - t = AddMember.create!(:person => profile, :community => profile) | 91 | + t = AddMember.create!(:person => profile, :organization => profile) |
92 | get :index, :profile => profile.identifier | 92 | get :index, :profile => profile.identifier |
93 | Role.find(:all).select{ |r| r.has_kind?('Profile') and r.id != Profile::Roles.member.id }.each do |i| | 93 | Role.find(:all).select{ |r| r.has_kind?('Profile') and r.id != Profile::Roles.member.id }.each do |i| |
94 | assert_no_tag :tag => 'input', :attributes => { :name => 'task[roles][]', :checked => 'checked', :value => i.id } | 94 | assert_no_tag :tag => 'input', :attributes => { :name => 'task[roles][]', :checked => 'checked', :value => i.id } |
@@ -97,7 +97,7 @@ class TasksControllerTest < Test::Unit::TestCase | @@ -97,7 +97,7 @@ class TasksControllerTest < Test::Unit::TestCase | ||
97 | 97 | ||
98 | should 'display all roles checked if target has no members' do | 98 | should 'display all roles checked if target has no members' do |
99 | assert_equal 0, profile.members.size | 99 | assert_equal 0, profile.members.size |
100 | - t = AddMember.create!(:person => profile, :community => profile) | 100 | + t = AddMember.create!(:person => profile, :organization => profile) |
101 | get :index, :profile => profile.identifier | 101 | get :index, :profile => profile.identifier |
102 | Role.find(:all).select{ |r| r.has_kind?('Profile') }.each do |i| | 102 | Role.find(:all).select{ |r| r.has_kind?('Profile') }.each do |i| |
103 | assert_tag :tag => 'input', :attributes => { :name => 'task[roles][]', :checked => 'checked', :value => i.id } | 103 | assert_tag :tag => 'input', :attributes => { :name => 'task[roles][]', :checked => 'checked', :value => i.id } |
test/unit/add_friend_test.rb
@@ -72,7 +72,7 @@ class AddFriendTest < ActiveSupport::TestCase | @@ -72,7 +72,7 @@ class AddFriendTest < ActiveSupport::TestCase | ||
72 | 72 | ||
73 | task = AddFriend.create!(:person => p1, :friend => p2) | 73 | task = AddFriend.create!(:person => p1, :friend => p2) |
74 | 74 | ||
75 | - assert_equal 'testuser1 wants to be your friend', task.description | 75 | + assert_equal 'testuser1 wants to be your friend.', task.description |
76 | end | 76 | end |
77 | 77 | ||
78 | should 'has permission to manage friends' do | 78 | should 'has permission to manage friends' do |
test/unit/add_member_test.rb
@@ -10,7 +10,7 @@ class AddMemberTest < ActiveSupport::TestCase | @@ -10,7 +10,7 @@ class AddMemberTest < ActiveSupport::TestCase | ||
10 | p = create_user('testuser1').person | 10 | p = create_user('testuser1').person |
11 | c = Community.create!(:name => 'closed community', :closed => true) | 11 | c = Community.create!(:name => 'closed community', :closed => true) |
12 | TaskMailer.stubs(:deliver_target_notification) | 12 | TaskMailer.stubs(:deliver_target_notification) |
13 | - task = AddMember.create!(:person => p, :community => c) | 13 | + task = AddMember.create!(:person => p, :organization => c) |
14 | assert_difference c, :members, [p] do | 14 | assert_difference c, :members, [p] do |
15 | task.finish | 15 | task.finish |
16 | c.reload | 16 | c.reload |
@@ -45,7 +45,7 @@ class AddMemberTest < ActiveSupport::TestCase | @@ -45,7 +45,7 @@ class AddMemberTest < ActiveSupport::TestCase | ||
45 | 45 | ||
46 | TaskMailer.expects(:deliver_target_notification).at_least_once | 46 | TaskMailer.expects(:deliver_target_notification).at_least_once |
47 | 47 | ||
48 | - task = AddMember.create!(:person => p, :community => c) | 48 | + task = AddMember.create!(:person => p, :organization => c) |
49 | end | 49 | end |
50 | 50 | ||
51 | should 'provide proper description' do | 51 | should 'provide proper description' do |
@@ -54,14 +54,9 @@ class AddMemberTest < ActiveSupport::TestCase | @@ -54,14 +54,9 @@ class AddMemberTest < ActiveSupport::TestCase | ||
54 | 54 | ||
55 | TaskMailer.stubs(:deliver_target_notification) | 55 | TaskMailer.stubs(:deliver_target_notification) |
56 | 56 | ||
57 | - task = AddMember.create!(:person => p, :community => c) | 57 | + task = AddMember.create!(:person => p, :organization => c) |
58 | 58 | ||
59 | - assert_equal 'testuser1 wants to be a member', task.description | ||
60 | - end | ||
61 | - | ||
62 | - should 'has community alias to target' do | ||
63 | - t = AddMember.new | ||
64 | - assert_same t.target, t.community | 59 | + assert_equal 'testuser1 wants to be a member of "closed community".', task.description |
65 | end | 60 | end |
66 | 61 | ||
67 | should 'has permission to manage members' do | 62 | should 'has permission to manage members' do |
@@ -73,7 +68,7 @@ class AddMemberTest < ActiveSupport::TestCase | @@ -73,7 +68,7 @@ class AddMemberTest < ActiveSupport::TestCase | ||
73 | p = create_user('testuser1').person | 68 | p = create_user('testuser1').person |
74 | c = Community.create!(:name => 'community_test') | 69 | c = Community.create!(:name => 'community_test') |
75 | TaskMailer.stubs(:deliver_target_notification) | 70 | TaskMailer.stubs(:deliver_target_notification) |
76 | - task = AddMember.create!(:roles => [1,2,3], :person => p, :community => c) | 71 | + task = AddMember.create!(:roles => [1,2,3], :person => p, :organization => c) |
77 | assert_equal [1,2,3], task.roles | 72 | assert_equal [1,2,3], task.roles |
78 | end | 73 | end |
79 | 74 | ||
@@ -83,7 +78,7 @@ class AddMemberTest < ActiveSupport::TestCase | @@ -83,7 +78,7 @@ class AddMemberTest < ActiveSupport::TestCase | ||
83 | 78 | ||
84 | roles = [Profile::Roles.member, Profile::Roles.admin] | 79 | roles = [Profile::Roles.member, Profile::Roles.admin] |
85 | TaskMailer.stubs(:deliver_target_notification) | 80 | TaskMailer.stubs(:deliver_target_notification) |
86 | - task = AddMember.create!(:roles => roles.map(&:id), :person => p, :community => c) | 81 | + task = AddMember.create!(:roles => roles.map(&:id), :person => p, :organization => c) |
87 | task.finish | 82 | task.finish |
88 | 83 | ||
89 | current_roles = p.find_roles(c).map(&:role) | 84 | current_roles = p.find_roles(c).map(&:role) |
test/unit/pending_task_notifier_test.rb
@@ -17,7 +17,7 @@ class PendingTaskNotifierTest < Test::Unit::TestCase | @@ -17,7 +17,7 @@ class PendingTaskNotifierTest < Test::Unit::TestCase | ||
17 | env = Environment.default | 17 | env = Environment.default |
18 | p = create_user('maelcum').person | 18 | p = create_user('maelcum').person |
19 | response = PendingTaskNotifier.deliver_notification(p) | 19 | response = PendingTaskNotifier.deliver_notification(p) |
20 | - assert_equal "#{env.name} - Pending tasks", response.subject | 20 | + assert_equal "[#{env.name}] Pending tasks", response.subject |
21 | assert_equal p.email, response.to[0] | 21 | assert_equal p.email, response.to[0] |
22 | end | 22 | end |
23 | 23 |