Commit 1324c451b36d9c6918a9d1c4b894514bf3d8df83

Authored by Daniela Feitosa
Committed by Antonio Terceiro
1 parent 231fe9fa

Adding tests for enterprise activation

   * copying theme when applying template

(ActionItem1311)
app/models/profile.rb
... ... @@ -262,6 +262,7 @@ class Profile < ActiveRecord::Base
262 262  
263 263 # copy interesting attributes
264 264 self.layout_template = template.layout_template
  265 + self.theme = template.theme
265 266 self.custom_footer = template[:custom_footer]
266 267 self.custom_header = template[:custom_header]
267 268  
... ...
features/activate_enterprise.feature 0 → 100644
... ... @@ -0,0 +1,134 @@
  1 +Feature: activate enterprise
  2 + As an enterprise owner
  3 + I want to activate my enterprise
  4 + In order to publish content
  5 +
  6 + Background:
  7 + Given the following users
  8 + | login | name |
  9 + | joaosilva | Joao Silva |
  10 +
  11 + Scenario: added an unexistent code
  12 + Given feature "enterprise_activation" is enabled on environment
  13 + And I am logged in as "joaosilva"
  14 + And I am on Joao Silva's control panel
  15 + And I fill in "Enterprise activation code" with "abcde"
  16 + When I press "Activate"
  17 + Then I should see "Invalid enterprise code"
  18 +
  19 + Scenario: added a code from an activated enterprise
  20 + Given feature "enterprise_activation" is enabled on environment
  21 + And the following enterprises
  22 + | identifier | name | enabled |
  23 + | products-factory | Products Factory | false |
  24 + And I am logged in as "joaosilva"
  25 + And I am on Joao Silva's control panel
  26 + And enterprise "Products Factory" is enabled
  27 + And I fill in "Enterprise activation code" with code of "Products Factory"
  28 + When I press "Activate"
  29 + Then I should see "This enterprise is already active"
  30 +
  31 + Scenario: added a code from an enterprise with no foundation year or cnpj
  32 + Given feature "enterprise_activation" is enabled on environment
  33 + And the following enterprises
  34 + | identifier | name | enabled |
  35 + | products-factory | Products Factory | false |
  36 + And I am logged in as "joaosilva"
  37 + And I am on Joao Silva's control panel
  38 + And I fill in "Enterprise activation code" with code of "Products Factory"
  39 + When I press "Activate"
  40 + Then I should see "We don't have enough information about your enterprise to identify you."
  41 + And enterprise "Products Factory" should not be blocked
  42 +
  43 + Scenario: filled activation question with wrong foundation year
  44 + Given feature "enterprise_activation" is enabled on environment
  45 + And the following enterprises
  46 + | identifier | name | enabled | foundation_year |
  47 + | services-provider | Services Provider | false | 2000 |
  48 + And I am logged in as "joaosilva"
  49 + And I am on Joao Silva's control panel
  50 + And I fill in "Enterprise activation code" with code of "Services Provider"
  51 + And I press "Activate"
  52 + And I fill in "What year your enterprise was founded? It must have 4 digits, eg 1990." with "1999"
  53 + When I press "Continue"
  54 + Then I should see "There was a failed atempt of activation and the automated activation was disabled for your security."
  55 + And enterprise "Services Provider" should be blocked
  56 +
  57 + Scenario: filled activation question with wrong cnpj
  58 + Given feature "enterprise_activation" is enabled on environment
  59 + And the following enterprises
  60 + | identifier | name | enabled | cnpj |
  61 + | services-provider | Services Provider | false | 00000000000000 |
  62 + And I am logged in as "joaosilva"
  63 + And I am on Joao Silva's control panel
  64 + And I fill in "Enterprise activation code" with code of "Services Provider"
  65 + And I press "Activate"
  66 + And I fill in "What is the CNPJ of your enterprise?" with "12345678912345"
  67 + When I press "Continue"
  68 + Then I should see "There was a failed atempt of activation and the automated activation was disabled for your security."
  69 + And enterprise "Services Provider" should be blocked
  70 +
  71 + @selenium
  72 + Scenario: activate succesffuly an enterprise with foundation_year
  73 + Given feature "enterprise_activation" is enabled on environment
  74 + And the following enterprises
  75 + | identifier | name | enabled | foundation_year |
  76 + | services-provider | Services Provider | false | 2000 |
  77 + And I am logged in as "joaosilva"
  78 + And I am on Joao Silva's control panel
  79 + And I fill in "Enterprise activation code" with code of "Services Provider"
  80 + And I press "Activate"
  81 + And I fill in "enterprise-activation-answer" with "2000"
  82 + And I press "Continue"
  83 + And I check "I read the terms of use and accepted them"
  84 + When I press "Continue"
  85 + Then I should see "Services Provider was successfuly activated. Now you may go to your control panel or to the control panel of your enterprise"
  86 + And enterprise "Services Provider" should be enabled
  87 + And "Joao Silva" is admin of "Services Provider"
  88 +
  89 + @selenium
  90 + Scenario: replace template after enable an enterprise
  91 + Given enterprise template must be replaced after enable
  92 + And feature "enterprise_activation" is enabled on environment
  93 + And the following enterprises
  94 + | identifier | name | enabled | foundation_year |
  95 + | services-provider | Services Provider | false | 2000 |
  96 + | active-template | Active Template | false | 2000 |
  97 + And "Active Template" is the active enterprise template
  98 + And "Services Provider" doesnt have "Active Template" as template
  99 + And I am logged in as "joaosilva"
  100 + And I am on Joao Silva's control panel
  101 + And I fill in "Enterprise activation code" with code of "Services Provider"
  102 + And I press "Activate"
  103 + And I fill in "enterprise-activation-answer" with "2000"
  104 + And I press "Continue"
  105 + And I check "I read the terms of use and accepted them"
  106 + When I press "Continue"
  107 + Then I should see "Services Provider was successfuly activated. Now you may go to your control panel or to the control panel of your enterprise"
  108 + And enterprise "Services Provider" should be enabled
  109 + And "Joao Silva" is admin of "Services Provider"
  110 + And "Services Provider" has "Active Template" as template
  111 +
  112 + @selenium
  113 + Scenario: not replace template after enable an enterprise
  114 + Given enterprise template must not be replaced after enable
  115 + And feature "enterprise_activation" is enabled on environment
  116 + And the following enterprises
  117 + | identifier | name | enabled | foundation_year |
  118 + | services-provider | Services Provider | false | 2000 |
  119 + | active-template | Active Template | false | 2000 |
  120 + And "Active Template" is the active enterprise template
  121 + And "Services Provider" doesnt have "Active Template" as template
  122 + And I am logged in as "joaosilva"
  123 + And I am on Joao Silva's control panel
  124 + And I fill in "Enterprise activation code" with code of "Services Provider"
  125 + And I press "Activate"
  126 + And I fill in "enterprise-activation-answer" with "2000"
  127 + And I press "Continue"
  128 + And I check "I read the terms of use and accepted them"
  129 + When I press "Continue"
  130 + Then I should see "Services Provider was successfuly activated. Now you may go to your control panel or to the control panel of your enterprise"
  131 + And enterprise "Services Provider" should be enabled
  132 + And "Joao Silva" is admin of "Services Provider"
  133 + And "Services Provider" doesnt have "Active Template" as template
  134 +
... ...
features/step_definitions/activate_enterprise_steps.rb 0 → 100644
... ... @@ -0,0 +1,69 @@
  1 +Given /^I fill in "([^\"]*)" with code of "([^\"]*)"$/ do |field, enterprise|
  2 + enterprise = Enterprise.find_by_name(enterprise)
  3 + value = EnterpriseActivation.all.select { |task| task.enterprise == enterprise}.first.code
  4 + fill_in(field, :with => value)
  5 +end
  6 +
  7 +Given /^enterprise "([^\"]*)" should be enabled$/ do |enterprise|
  8 + Enterprise.find_by_name(enterprise).enabled?.should be_true
  9 +end
  10 +
  11 +Given /^"([^\"]*)" is the active enterprise template$/ do |enterprise|
  12 + template = Enterprise.find_by_name(enterprise)
  13 + template.boxes.destroy_all
  14 + template.boxes << Box.new
  15 + template.layout_template = 'leftbar'
  16 + template.theme = 'template_theme'
  17 + template.custom_header = 'template header'
  18 + template.custom_footer = 'template_footer'
  19 + template.save!
  20 +
  21 + e = Environment.default
  22 + e.enterprise_template = template
  23 + e.save
  24 +end
  25 +
  26 +Given /^"([^\"]*)" has "([^\"]*)" as template$/ do |ent, templ|
  27 + template = Enterprise.find_by_name(templ)
  28 + enterprise = Enterprise.find_by_name(ent)
  29 + (template.boxes.size == enterprise.boxes.size).should be_true
  30 + (template.layout_template == enterprise.layout_template).should be_true
  31 + (template.theme == enterprise.theme).should be_true
  32 + (template.custom_header == enterprise.custom_header).should be_true
  33 + (template.custom_footer == enterprise.custom_footer).should be_true
  34 +end
  35 +
  36 +Given /^"([^\"]*)" doesnt have "([^\"]*)" as template$/ do |ent, templ|
  37 + template = Enterprise.find_by_name(templ)
  38 + enterprise = Enterprise.find_by_name(ent)
  39 + (template.boxes.size == enterprise.boxes.size).should be_false
  40 + (template.layout_template == enterprise.layout_template).should be_false
  41 + (template.theme == enterprise.theme).should be_false
  42 + (template.custom_header == enterprise.custom_header).should be_false
  43 + (template.custom_footer == enterprise.custom_footer).should be_false
  44 +end
  45 +
  46 +Given /^enterprise "([^\"]*)" is enabled$/ do |enterprise|
  47 + Enterprise.find_by_name(enterprise).update_attribute(:enabled,true)
  48 + Enterprise.find_by_name(enterprise).enabled?.should be_true
  49 +end
  50 +
  51 +Given /^enterprise "([^\"]*)" should be blocked$/ do |enterprise|
  52 + Enterprise.find_by_name(enterprise).blocked?.should be_true
  53 +end
  54 +
  55 +Given /^enterprise "([^\"]*)" should not be blocked$/ do |enterprise|
  56 + Enterprise.find_by_name(enterprise).blocked?.should_not be_true
  57 +end
  58 +
  59 +Given /^enterprise template must be replaced after enable$/ do
  60 + e = Environment.default
  61 + e.replace_enterprise_template_when_enable = true
  62 + e.save
  63 +end
  64 +
  65 +Given /^enterprise template must not be replaced after enable$/ do
  66 + e = Environment.default
  67 + e.replace_enterprise_template_when_enable = false
  68 + e.save
  69 +end
... ...