ref: master
test/integration/enterprise_registration_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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
require_relative "../test_helper" class EnterpriseRegistrationTest < ActionDispatch::IntegrationTest fixtures :users, :profiles, :environments should 'be able to create an enterprise registration request' do environment = Environment.default environment.organization_approval_method = :region environment.save region1 = environment.regions.build(:name => 'A region') region1.save! region2 = environment.regions.build(:name => 'Other region') region2.save! org = Organization.create!(:name => "My organization", :identifier => 'myorg') region1.validators << org login('ze', 'test') get '/enterprise_registration' assert_response :success assert_tag :tag => 'form', :attributes => { :action => '/enterprise_registration', :method => 'post' }, :descendant => { :tag => 'input', :attributes => { :type => 'text', :name => 'create_enterprise[identifier]'} } data = { :name => 'My new enterprise', :identifier => 'mynewenterprise', :address => 'satan street, 666', :contact_phone => '1298372198', :contact_person => 'random joe', :legal_form => 'cooperative', :economic_activity => 'free software', :region_id => region1.id, } post '/enterprise_registration', :create_enterprise => data assert_response :success assert_tag :tag => 'form', :attributes => { :action => '/enterprise_registration', :method => 'post' }, :descendant => { :tag => 'input', :attributes => { :type => 'radio', :name => 'create_enterprise[target_id]', :value => org.id } } assert_difference 'CreateEnterprise.count' do post '/enterprise_registration', :create_enterprise => data.merge(:target_id => org.id) end assert_template 'confirmation' assert_tag :tag => 'a', :attributes => { :href => '/' } code = CreateEnterprise.order('id DESC').first.code post '/account/logout' # steps done by the validator validator = create_user_with_permission('validator', 'validate_enterprise', org) validator.user.activate login 'validator', 'validator' get "/myprofile/myorg/enterprise_validation" assert_response :success assert_tag :tag => 'a', :attributes => { :href => "/myprofile/myorg/enterprise_validation/details/#{code}" } get "/myprofile/myorg/enterprise_validation/details/#{code}" assert_response :success assert_tag :form, :attributes => { :action => "/myprofile/myorg/enterprise_validation/approve/#{code}" } post_via_redirect "/myprofile/myorg/enterprise_validation/approve/#{code}" assert_response :success assert_equal "/myprofile/myorg/enterprise_validation/view_processed/#{code}", path assert_tag :span, :attributes => { :class => 'validation_approved' } end end |