Commit 50267ca4a0de5c8dfdc9ead272e5d67870463851
1 parent
30af8808
Exists in
master
and in
29 other branches
ActionItem441: tests for add member task done!
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2024 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
3 changed files
with
42 additions
and
5 deletions
Show diff stats
app/views/tasks/_add_member.rhtml
... | ... | @@ -27,7 +27,7 @@ |
27 | 27 | @roles = Role.find(:all).select{ |r| r.has_kind?('Profile') } |
28 | 28 | %> |
29 | 29 | <% @roles.each do |r| %> |
30 | - <%= labelled_check_box(r.name, 'task[roles][]', r.id, task.target.members.nil?) %><br/> | |
30 | + <%= labelled_check_box(r.name, 'task[roles][]', r.id, ( task.target.members.empty? ? true : ( r.id == Profile::Roles.member.id ) ) ) %><br/> | |
31 | 31 | <% end %> |
32 | 32 | </p> |
33 | 33 | </div> | ... | ... |
test/fixtures/roles.yml
test/functional/tasks_controller_test.rb
... | ... | @@ -62,12 +62,45 @@ class TasksControllerTest < Test::Unit::TestCase |
62 | 62 | ok('task should be cancelled') { t.status == Task::Status::CANCELLED } |
63 | 63 | end |
64 | 64 | |
65 | - should 'affiliate roles to user after finish add member task' | |
65 | + should 'affiliate roles to user after finish add member task' do | |
66 | + t = AddMember.create!(:person => profile, :community => profile) | |
67 | + count = profile.members.size | |
68 | + post :close, :decision => 'finish', :id => t.id | |
69 | + profile.reload | |
70 | + assert_equal count + 1, profile.members.size | |
71 | + end | |
66 | 72 | |
67 | - should 'display form to add members task' | |
73 | + should 'display custom form to add members task' do | |
74 | + t = AddMember.create!(:person => profile, :community => profile) | |
75 | + get :index, :profile => profile.identifier | |
76 | + assert_tag :tag => 'form', :attributes => { :action => "/myprofile/#{profile.identifier}/tasks/close/#{t.id}" } | |
77 | + end | |
68 | 78 | |
69 | - should 'display all roles checked if target has no members' | |
79 | + should 'display member role checked if target has members' do | |
80 | + profile.affiliate(profile, Profile::Roles.admin) | |
81 | + assert_equal 1, profile.members.size | |
82 | + t = AddMember.create!(:person => profile, :community => profile) | |
83 | + get :index, :profile => profile.identifier | |
84 | + assert_tag :tag => 'input', :attributes => { :name => 'task[roles][]', :checked => 'checked', :value => Profile::Roles.member.id } | |
85 | + end | |
70 | 86 | |
71 | - should 'display member role checked if target has members' | |
87 | + should 'display roles besides role member unchecked if target has members' do | |
88 | + profile.affiliate(profile, Profile::Roles.admin) | |
89 | + assert_equal 1, profile.members.size | |
90 | + t = AddMember.create!(:person => profile, :community => profile) | |
91 | + get :index, :profile => profile.identifier | |
92 | + Role.find(:all).select{ |r| r.has_kind?('Profile') and r.id != Profile::Roles.member.id }.each do |i| | |
93 | + assert_no_tag :tag => 'input', :attributes => { :name => 'task[roles][]', :checked => 'checked', :value => i.id } | |
94 | + end | |
95 | + end | |
96 | + | |
97 | + should 'display all roles checked if target has no members' do | |
98 | + assert_equal 0, profile.members.size | |
99 | + t = AddMember.create!(:person => profile, :community => profile) | |
100 | + get :index, :profile => profile.identifier | |
101 | + Role.find(:all).select{ |r| r.has_kind?('Profile') }.each do |i| | |
102 | + assert_tag :tag => 'input', :attributes => { :name => 'task[roles][]', :checked => 'checked', :value => i.id } | |
103 | + end | |
104 | + end | |
72 | 105 | |
73 | 106 | end | ... | ... |