Commit d262a9ed039ec3bb2e98ce24e5d53cf12d1169a6
1 parent
a8c2d855
Exists in
master
and in
29 other branches
ActionItem16: added units an functional tests to the new functionalities
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@400 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
4 changed files
with
27 additions
and
0 deletions
Show diff stats
app/controllers/enterprise_controller.rb
@@ -104,6 +104,7 @@ class EnterpriseController < ApplicationController | @@ -104,6 +104,7 @@ class EnterpriseController < ApplicationController | ||
104 | redirect_to :action => 'index' | 104 | redirect_to :action => 'index' |
105 | end | 105 | end |
106 | 106 | ||
107 | + # Rejects an enterprise | ||
107 | def reject | 108 | def reject |
108 | @enterprise = Enterprise.find(params[:id]) | 109 | @enterprise = Enterprise.find(params[:id]) |
109 | if @enterprise.reject | 110 | if @enterprise.reject |
app/views/enterprise/show.rhtml
@@ -23,3 +23,9 @@ | @@ -23,3 +23,9 @@ | ||
23 | <%= help _('Be a member of the enterprise') %> | 23 | <%= help _('Be a member of the enterprise') %> |
24 | <%= link_to _('Activate'), :action => 'activate', :id => @enterprise if @my_pending_enterprises.include?(@enterprise) %> | 24 | <%= link_to _('Activate'), :action => 'activate', :id => @enterprise if @my_pending_enterprises.include?(@enterprise) %> |
25 | <%= help _('Activate an approved enterprise') if @my_pending_enterprises.include?(@enterprise) %> | 25 | <%= help _('Activate an approved enterprise') if @my_pending_enterprises.include?(@enterprise) %> |
26 | +<% unless @enterprise.approved? %> | ||
27 | + <%= link_to _('Approve'), :action => 'approve', :id => @enterprise %> | ||
28 | + <%= help _('Approve a submitted enterprise profile') %> | ||
29 | + <%= link_to _('Reject'), :action => 'reject', :id => @enterprise %> | ||
30 | + <%= help _('Reject a submitted enterprise profile') %> | ||
31 | +<% end %> |
test/functional/enterprise_controller_test.rb
@@ -137,4 +137,10 @@ class EnterpriseControllerTest < Test::Unit::TestCase | @@ -137,4 +137,10 @@ class EnterpriseControllerTest < Test::Unit::TestCase | ||
137 | assert_kind_of Enterprise, assigns(:enterprise) | 137 | assert_kind_of Enterprise, assigns(:enterprise) |
138 | assert assigns(:enterprise).active | 138 | assert assigns(:enterprise).active |
139 | end | 139 | end |
140 | + | ||
141 | + def test_approve | ||
142 | + logins_as 'ze' | ||
143 | + post :approve, :id => 5 | ||
144 | + assert assigns(:em) | ||
145 | + end | ||
140 | end | 146 | end |
test/unit/enterprise_test.rb
@@ -46,6 +46,20 @@ class EnterpriseTest < Test::Unit::TestCase | @@ -46,6 +46,20 @@ class EnterpriseTest < Test::Unit::TestCase | ||
46 | end | 46 | end |
47 | end | 47 | end |
48 | 48 | ||
49 | + def test_approve | ||
50 | + e = Enterprise.create(:identifier => 'bli', :name => 'Bli') | ||
51 | + assert !e.approved? | ||
52 | + e.approve | ||
53 | + assert e.approved? | ||
54 | + end | ||
55 | + | ||
56 | + def test_reject | ||
57 | + e = Enterprise.create(:identifier => 'bli', :name => 'Bli') | ||
58 | + assert !e.rejected? | ||
59 | + e.reject | ||
60 | + assert e.rejected? | ||
61 | + end | ||
62 | + | ||
49 | def test_cannot_be_activated_without_approval | 63 | def test_cannot_be_activated_without_approval |
50 | e = Enterprise.create(:identifier => 'bli', :name => 'Bli') | 64 | e = Enterprise.create(:identifier => 'bli', :name => 'Bli') |
51 | assert !e.approved | 65 | assert !e.approved |