diff --git a/app/models/profile.rb b/app/models/profile.rb index 5a0e3b3..c3ad804 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -262,6 +262,7 @@ class Profile < ActiveRecord::Base # copy interesting attributes self.layout_template = template.layout_template + self.theme = template.theme self.custom_footer = template[:custom_footer] self.custom_header = template[:custom_header] diff --git a/features/activate_enterprise.feature b/features/activate_enterprise.feature new file mode 100644 index 0000000..69dbdac --- /dev/null +++ b/features/activate_enterprise.feature @@ -0,0 +1,134 @@ +Feature: activate enterprise + As an enterprise owner + I want to activate my enterprise + In order to publish content + + Background: + Given the following users + | login | name | + | joaosilva | Joao Silva | + + Scenario: added an unexistent code + Given feature "enterprise_activation" is enabled on environment + And I am logged in as "joaosilva" + And I am on Joao Silva's control panel + And I fill in "Enterprise activation code" with "abcde" + When I press "Activate" + Then I should see "Invalid enterprise code" + + Scenario: added a code from an activated enterprise + Given feature "enterprise_activation" is enabled on environment + And the following enterprises + | identifier | name | enabled | + | products-factory | Products Factory | false | + And I am logged in as "joaosilva" + And I am on Joao Silva's control panel + And enterprise "Products Factory" is enabled + And I fill in "Enterprise activation code" with code of "Products Factory" + When I press "Activate" + Then I should see "This enterprise is already active" + + Scenario: added a code from an enterprise with no foundation year or cnpj + Given feature "enterprise_activation" is enabled on environment + And the following enterprises + | identifier | name | enabled | + | products-factory | Products Factory | false | + And I am logged in as "joaosilva" + And I am on Joao Silva's control panel + And I fill in "Enterprise activation code" with code of "Products Factory" + When I press "Activate" + Then I should see "We don't have enough information about your enterprise to identify you." + And enterprise "Products Factory" should not be blocked + + Scenario: filled activation question with wrong foundation year + Given feature "enterprise_activation" is enabled on environment + And the following enterprises + | identifier | name | enabled | foundation_year | + | services-provider | Services Provider | false | 2000 | + And I am logged in as "joaosilva" + And I am on Joao Silva's control panel + And I fill in "Enterprise activation code" with code of "Services Provider" + And I press "Activate" + And I fill in "What year your enterprise was founded? It must have 4 digits, eg 1990." with "1999" + When I press "Continue" + Then I should see "There was a failed atempt of activation and the automated activation was disabled for your security." + And enterprise "Services Provider" should be blocked + + Scenario: filled activation question with wrong cnpj + Given feature "enterprise_activation" is enabled on environment + And the following enterprises + | identifier | name | enabled | cnpj | + | services-provider | Services Provider | false | 00000000000000 | + And I am logged in as "joaosilva" + And I am on Joao Silva's control panel + And I fill in "Enterprise activation code" with code of "Services Provider" + And I press "Activate" + And I fill in "What is the CNPJ of your enterprise?" with "12345678912345" + When I press "Continue" + Then I should see "There was a failed atempt of activation and the automated activation was disabled for your security." + And enterprise "Services Provider" should be blocked + + @selenium + Scenario: activate succesffuly an enterprise with foundation_year + Given feature "enterprise_activation" is enabled on environment + And the following enterprises + | identifier | name | enabled | foundation_year | + | services-provider | Services Provider | false | 2000 | + And I am logged in as "joaosilva" + And I am on Joao Silva's control panel + And I fill in "Enterprise activation code" with code of "Services Provider" + And I press "Activate" + And I fill in "enterprise-activation-answer" with "2000" + And I press "Continue" + And I check "I read the terms of use and accepted them" + When I press "Continue" + 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" + And enterprise "Services Provider" should be enabled + And "Joao Silva" is admin of "Services Provider" + + @selenium + Scenario: replace template after enable an enterprise + Given enterprise template must be replaced after enable + And feature "enterprise_activation" is enabled on environment + And the following enterprises + | identifier | name | enabled | foundation_year | + | services-provider | Services Provider | false | 2000 | + | active-template | Active Template | false | 2000 | + And "Active Template" is the active enterprise template + And "Services Provider" doesnt have "Active Template" as template + And I am logged in as "joaosilva" + And I am on Joao Silva's control panel + And I fill in "Enterprise activation code" with code of "Services Provider" + And I press "Activate" + And I fill in "enterprise-activation-answer" with "2000" + And I press "Continue" + And I check "I read the terms of use and accepted them" + When I press "Continue" + 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" + And enterprise "Services Provider" should be enabled + And "Joao Silva" is admin of "Services Provider" + And "Services Provider" has "Active Template" as template + + @selenium + Scenario: not replace template after enable an enterprise + Given enterprise template must not be replaced after enable + And feature "enterprise_activation" is enabled on environment + And the following enterprises + | identifier | name | enabled | foundation_year | + | services-provider | Services Provider | false | 2000 | + | active-template | Active Template | false | 2000 | + And "Active Template" is the active enterprise template + And "Services Provider" doesnt have "Active Template" as template + And I am logged in as "joaosilva" + And I am on Joao Silva's control panel + And I fill in "Enterprise activation code" with code of "Services Provider" + And I press "Activate" + And I fill in "enterprise-activation-answer" with "2000" + And I press "Continue" + And I check "I read the terms of use and accepted them" + When I press "Continue" + 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" + And enterprise "Services Provider" should be enabled + And "Joao Silva" is admin of "Services Provider" + And "Services Provider" doesnt have "Active Template" as template + diff --git a/features/step_definitions/activate_enterprise_steps.rb b/features/step_definitions/activate_enterprise_steps.rb new file mode 100644 index 0000000..31b8d20 --- /dev/null +++ b/features/step_definitions/activate_enterprise_steps.rb @@ -0,0 +1,69 @@ +Given /^I fill in "([^\"]*)" with code of "([^\"]*)"$/ do |field, enterprise| + enterprise = Enterprise.find_by_name(enterprise) + value = EnterpriseActivation.all.select { |task| task.enterprise == enterprise}.first.code + fill_in(field, :with => value) +end + +Given /^enterprise "([^\"]*)" should be enabled$/ do |enterprise| + Enterprise.find_by_name(enterprise).enabled?.should be_true +end + +Given /^"([^\"]*)" is the active enterprise template$/ do |enterprise| + template = Enterprise.find_by_name(enterprise) + template.boxes.destroy_all + template.boxes << Box.new + template.layout_template = 'leftbar' + template.theme = 'template_theme' + template.custom_header = 'template header' + template.custom_footer = 'template_footer' + template.save! + + e = Environment.default + e.enterprise_template = template + e.save +end + +Given /^"([^\"]*)" has "([^\"]*)" as template$/ do |ent, templ| + template = Enterprise.find_by_name(templ) + enterprise = Enterprise.find_by_name(ent) + (template.boxes.size == enterprise.boxes.size).should be_true + (template.layout_template == enterprise.layout_template).should be_true + (template.theme == enterprise.theme).should be_true + (template.custom_header == enterprise.custom_header).should be_true + (template.custom_footer == enterprise.custom_footer).should be_true +end + +Given /^"([^\"]*)" doesnt have "([^\"]*)" as template$/ do |ent, templ| + template = Enterprise.find_by_name(templ) + enterprise = Enterprise.find_by_name(ent) + (template.boxes.size == enterprise.boxes.size).should be_false + (template.layout_template == enterprise.layout_template).should be_false + (template.theme == enterprise.theme).should be_false + (template.custom_header == enterprise.custom_header).should be_false + (template.custom_footer == enterprise.custom_footer).should be_false +end + +Given /^enterprise "([^\"]*)" is enabled$/ do |enterprise| + Enterprise.find_by_name(enterprise).update_attribute(:enabled,true) + Enterprise.find_by_name(enterprise).enabled?.should be_true +end + +Given /^enterprise "([^\"]*)" should be blocked$/ do |enterprise| + Enterprise.find_by_name(enterprise).blocked?.should be_true +end + +Given /^enterprise "([^\"]*)" should not be blocked$/ do |enterprise| + Enterprise.find_by_name(enterprise).blocked?.should_not be_true +end + +Given /^enterprise template must be replaced after enable$/ do + e = Environment.default + e.replace_enterprise_template_when_enable = true + e.save +end + +Given /^enterprise template must not be replaced after enable$/ do + e = Environment.default + e.replace_enterprise_template_when_enable = false + e.save +end -- libgit2 0.21.2