Commit dc1001979a596174732d19ff7cd16e8f6777e845
1 parent
9f30e983
Exists in
staging
and in
42 other branches
ActionItem102: adding an integration test
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@669 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
1 changed file
with
45 additions
and
0 deletions
Show diff stats
test/integration/assigning_validator_organizations_to_regions_test.rb
0 → 100644
@@ -0,0 +1,45 @@ | @@ -0,0 +1,45 @@ | ||
1 | +require "#{File.dirname(__FILE__)}/../test_helper" | ||
2 | + | ||
3 | +class AssigningValidatorOrganizationsToRegionsTest < ActionController::IntegrationTest | ||
4 | + | ||
5 | + should 'be able to properly assign organizations as validators to regions' do | ||
6 | + env = Environment.default | ||
7 | + | ||
8 | + Organization.destroy_all | ||
9 | + org1 = Organization.create!(:name => 'Organization one', :identifier => 'org1') | ||
10 | + org2 = Organization.create!(:name => 'Organization two', :identifier => 'org2') | ||
11 | + | ||
12 | + Region.destroy_all | ||
13 | + region1 = Region.create!(:name => "Region 1", :environment_id => env.id) | ||
14 | + region2 = Region.create!(:name => "Region 2", :environment_id => env.id) | ||
15 | + | ||
16 | + login('ze', 'test') | ||
17 | + | ||
18 | + get '/admin/region_validators' | ||
19 | + assert_response :success | ||
20 | + | ||
21 | + get "/admin/region_validators/region/#{region1.id}" | ||
22 | + assert_response :success | ||
23 | + assert_tag :tag => 'form', :attributes => { :action => "/admin/region_validators/region/#{region1.id}" }, :descendant => { :tag => 'input', :attributes => { :type => 'text', :name => 'search' } } | ||
24 | + | ||
25 | + get "/admin/region_validators/region/#{region1.id}", :search => 'two' | ||
26 | + assert_response :success | ||
27 | + assert_tag :tag => 'form', :attributes => { :action => "/admin/region_validators/add/#{region1.id}" }, :descendant => { :tag => 'input', :attributes => { :type => 'hidden', :name => 'validator_id', :value => org2.id } } | ||
28 | + | ||
29 | + post "/admin/region_validators/add/#{region1.id}", :validator_id => org2.id | ||
30 | + assert_response :redirect | ||
31 | + | ||
32 | + follow_redirect! | ||
33 | + assert_equal "/admin/region_validators/region/#{region1.id}", path | ||
34 | + | ||
35 | + assert_tag :tag => 'a', :attributes => { :href => "/admin/region_validators/remove/#{region1.id}?validator_id=#{org2.id}" } | ||
36 | + | ||
37 | + post "/admin/region_validators/remove/#{region1.id}", :validator_id => org2.id | ||
38 | + assert_response :redirect | ||
39 | + | ||
40 | + follow_redirect! | ||
41 | + assert_equal "/admin/region_validators/region/#{region1.id}", path | ||
42 | + assert_no_tag :tag => 'a', :attributes => { :href => "/admin/region_validators/remove/#{region1.id}?validator_id=#{org2.id}" } | ||
43 | + | ||
44 | + end | ||
45 | +end |