diff --git a/config/cucumber.yml b/config/cucumber.yml index f6f27e4..80d4ebe 100644 --- a/config/cucumber.yml +++ b/config/cucumber.yml @@ -1,2 +1,17 @@ -default: --color --format progress --strict --tags ~@selenium --tags ~@selenium-fixme --tags ~@fixme --exclude features/support/selenium.rb -r features/support -r features/step_definitions -selenium: --strict --tags @selenium -r features/support -r features/step_definitions +<% base_requires = '-r features/support -r features/step_definitions' %> +<% default_options = "color --format progress --strict --tags ~@selenium --tags ~@selenium-fixme --tags ~@fixme --exclude features/support/selenium.rb #{base_requires}" %> +<% selenium_options = "--strict --tags @selenium #{base_requires}" %> + +default: <%= default_options %> +selenium: <% selenium_options %> + +<% enabled_plugins = Dir.glob(File.join('config', 'plugins', '*')).map{|path| plugin = File.basename(path); plugin if File.exist?(File.join('features', 'plugins', plugin)) }.compact %> + +<% enabled_plugins.each do |plugin| %> +<% plugin_features_path = File.join('features', 'plugins', plugin) %> +<% plugin_base_requires = '' %> +<% plugin_base_requires += " -r features/plugins/#{plugin}/support" if File.exist?(File.join(plugin_features_path, 'support')) %> +<% plugin_base_requires += " -r features/plugins/#{plugin}/step_definitions" if File.exist?(File.join(plugin_features_path, 'step_definitions')) %> +<%= "#{plugin}: #{default_options} #{plugin_base_requires}" %> +<%= "#{plugin}_selenium: #{selenium_options} #{plugin_base_requires}" %> +<% end %> diff --git a/features/step_definitions/mezuro_steps.rb b/features/step_definitions/mezuro_steps.rb deleted file mode 100644 index bffd099..0000000 --- a/features/step_definitions/mezuro_steps.rb +++ /dev/null @@ -1,164 +0,0 @@ -When /^I create a Mezuro (project|reading group) with the following data$/ do |type, fields| - click_link ("Mezuro " + type) - - fields.rows_hash.each do |name, value| - When %{I fill in "#{name}" with "#{value}"} - end - - click_button "Save" - Article.find_by_name(fields.rows_hash[:Title]) -end - -When /^I create a Mezuro configuration with the following data$/ do |fields| - click_link ("Mezuro configuration") - - fields.rows_hash.each do |name, value| - if name != "Clone" - When %{I fill in "#{name}" with "#{value}"} - end - end - - click_button "Save" - Article.find_by_name(fields.rows_hash[:Title]) -end - -Then /^I directly delete content with name "([^\"]*)" for testing purposes$/ do |content_name| - Article.find_by_name(content_name).destroy -end - -Then /^I should be at the url "([^\"]*)"$/ do |url| - if response.class.to_s == 'Webrat::SeleniumResponse' - URI.parse(response.selenium.get_location).path.should == url - else - URI.parse(current_url).path.should == url - end -end - -Then /^the field "([^"]*)" is empty$/ do |field_name| - find_field(field_name).value.should be_nil -end - -Then /^I should see "([^\"]*)" inside an alert$/ do |message| - alert = page.driver.browser.switch_to.alert - assert_equal message, alert.text - alert.accept -end - -Then /^I should see "([^"]*)" in the "([^"]*)"$/ do |content, labeltext| - find_field(labeltext).value.should == content -end - -Then /^I should see "([^"]*)" button$/ do |button_name| - find_button(button_name).should_not be_nil -end - -Then /^I should see "([^"]*)" in a link$/ do |link_name| - find_link(link_name).should_not be_nil -end - -Then /^I should see "([^"]*)" in the process period select field$/ do |content| - selected = MezuroPlugin::Helpers::ContentViewerHelper.periodicity_options.select { |option| option.first == content }.first - assert_equal selected.last, find_field("repository_process_period").value.to_i -end - -Then /^I should see "([^"]*)" in the repository configuration select field$/ do |content| - selected = Kalibro::Configuration.all.select { |option| option.name == content }.first - assert_equal selected.id, find_field("repository_configuration_id").value.to_i -end - -Then /^I should not see "([^"]*)" button$/ do |button_name| - find_button(button_name).should be_nil -end - -When /^I have a Mezuro (project|reading group|configuration) with the following data$/ do |type, fields| - item = {} - fields.rows_hash.each do |name, value| - if(name=="user" or name=="community") - item.merge!(:profile=>Profile[value]) - else - item.merge!(name => value) - end - end - if (type == "project") - result = MezuroPlugin::ProjectContent.new(item) - elsif (type == "reading group") - result = MezuroPlugin::ReadingGroupContent.new(item) - elsif (type == "configuration") - result = MezuroPlugin::ConfigurationContent.new(item) - end - - result.save! -end - -When /^I have a Mezuro (reading|repository) with the following data$/ do |type, fields| - item = {} - fields.rows_hash.each do |name, value| - if(name=="user" or name=="community") - item.merge!(:profile=>Profile[value]) - else - item.merge!(name => value) - end - end - if (type == "repository") - item["configuration_id"] = Kalibro::Configuration.all.select {|configuration| configuration.name == item["configuration_id"] }.first.id - item.merge!(:project_id => Kalibro::Project.all.last.id) - Kalibro::Repository.create(item) - elsif (type == "reading") - item.merge!(:group_id => Kalibro::ReadingGroup.all.last.id) - Kalibro::Reading.create(item) - end -end - -When /^I erase the "([^"]*)" field$/ do |field_name| - find_field(field_name).set "" -end - -When /^I fill the fields with the new following data$/ do |fields| - fields.rows_hash.each do |key, value| - name = key.to_s - element = find_field(name) - if (element.tag_name.to_s == "select") - select(value, :from => name) - else - element.set value - end - end -end - -When /^I have a Mezuro metric configuration with previous created configuration and reading group$/ do - Kalibro::MetricConfiguration.create({ - :code => 'amloc1', - :metric => {:name => 'Total Coupling Factor', :compound => "false", :scope => 'SOFTWARE', :language => ['JAVA']}, - :base_tool_name => "Analizo", - :weight => "1.0", - :aggregation_form => 'AVERAGE', - :reading_group_id => Kalibro::ReadingGroup.all.last.id, - :configuration_id => Kalibro::Configuration.all.last.id - }) -end - -When /^I follow the (edit|remove) link for "([^"]*)" (repository|reading)$/ do |action, name, type| - if (type == "repository") - project_id = Kalibro::Project.all.last.id - repositories = Kalibro::Repository.repositories_of project_id - id = repositories.select {|option| option.name == name}.first.id - elsif (type == "reading") - reading_group_id = Kalibro::ReadingGroup.all.last.id - readings = Kalibro::Reading.readings_of reading_group_id - id = readings.select {|option| option.label == name}.first.id - if (action == "edit") - action = name - end - end - - elements = all('a', :text => action.capitalize) - link = type + "_id" - action_link = elements.select {|element| (/#{link}=#{id}/ =~ element[:href]) }.first - action_link.click -end - -Then /^I should see the "([^"]*)" color$/ do |color_name| - elements = all('td', :text => "") - found = elements.select { |element| color_name == element[:bgcolor]}.first - assert_not_nil found -end diff --git a/features/support/hooks.rb b/features/support/hooks.rb deleted file mode 100644 index fb89f01..0000000 --- a/features/support/hooks.rb +++ /dev/null @@ -1,12 +0,0 @@ -Before do - if !$dunit - command = "#{RAILS_ROOT}/plugins/mezuro/script/tests/prepare_kalibro_query_file.sh" - system command - $dunit = true - end -end - -After ('@kalibro_restart') do - command = "#{RAILS_ROOT}/plugins/mezuro/script/tests/delete_all_kalibro_entries.sh" - system command -end diff --git a/lib/tasks/plugins_tests.rake b/lib/tasks/plugins_tests.rake index 48575df..70a2f18 100644 --- a/lib/tasks/plugins_tests.rake +++ b/lib/tasks/plugins_tests.rake @@ -17,6 +17,14 @@ def plugin_name(plugin) "#{plugin} plugin" end +def plugin_enabled?(plugin) + File.exist?(File.join('config', 'plugins', plugin)) +end + +def plugin_disabled_warning(plugin) + puts "E: you should enable #{plugin} plugin before running it's tests!" +end + def run_tests(name, files_glob) files = Dir.glob(files_glob) if files.empty? @@ -38,21 +46,33 @@ end def plugin_test_task(name, plugin, files_glob) desc "Run #{name} tests for #{plugin_name(plugin)}" task name => 'db:test:plugins:prepare' do |t| - run_tests t.name, files_glob + if plugin_enabled?(plugin) + run_tests t.name, files_glob + else + plugin_disabled_warning(plugin) + end end end def plugin_cucumber_task(name, plugin, files_glob) desc "Run #{name} tests for #{plugin_name(plugin)}" task name => 'db:test:plugins:prepare' do |t| - run_cucumber t.name, :default, files_glob + if plugin_enabled?(plugin) + run_cucumber t.name, plugin, files_glob + else + plugin_disabled_warning(plugin) + end end end def plugin_selenium_task(name, plugin, files_glob) desc "Run #{name} tests for #{plugin_name(plugin)}" task name => 'db:test:plugins:prepare' do |t| - run_cucumber t.name, :selenium, files_glob + if plugin_enabled?(plugin) + run_cucumber t.name, "#{plugin}_selenium", files_glob + else + plugin_disabled_warning(plugin) + end end end @@ -81,8 +101,8 @@ namespace :test do plugin_test_task :units, plugin, "plugins/#{plugin}/test/unit/**/*.rb" plugin_test_task :functionals, plugin, "plugins/#{plugin}/test/functional/**/*.rb" plugin_test_task :integration, plugin, "plugins/#{plugin}/test/integration/**/*.rb" - plugin_cucumber_task :cucumber, plugin, "plugins/#{plugin}/test/features/**/*.feature" - plugin_selenium_task :selenium, plugin, "plugins/#{plugin}/test/features/**/*.feature" + plugin_cucumber_task :cucumber, plugin, "plugins/#{plugin}/features/**/*.feature" + plugin_selenium_task :selenium, plugin, "plugins/#{plugin}/features/**/*.feature" end test_sequence_task(plugin, plugin, "#{plugin}:units", "#{plugin}:functionals", "#{plugin}:integration", "#{plugin}:cucumber", "#{plugin}:selenium") diff --git a/plugins/bsc/features/bsc.feature b/plugins/bsc/features/bsc.feature new file mode 100644 index 0000000..2de0414 --- /dev/null +++ b/plugins/bsc/features/bsc.feature @@ -0,0 +1,164 @@ +Feature: bsc + + Background: + Given "Bsc" plugin is enabled + + Scenario: display link to bsc creation on admin panel when bsc plugin active + Given I am logged in as admin + When I am on the environment control panel + Then I should see "Create Bsc" + When "Bsc" plugin is disabled + And I am on the environment control panel + Then I should not see "Create Bsc" + + Scenario: be able to create a bsc + Given I am logged in as admin + And I am on the environment control panel + And I follow "Create Bsc" + And I fill in the following: + | Business name | Sample Bsc | + | Company name | Sample Bsc | + | profile_data_identifier | sample-identifier | + | Cnpj | 07.970.746/0001-77 | + When I press "Save" + Then there should be a profile named "Sample Bsc" + + Scenario: display a button on bsc control panel to manage associated enterprises + Given the folllowing "bsc" from "bsc_plugin" + | business_name | identifier | company_name | cnpj | + | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | + And I am logged in as admin + When I am on Bsc Test's control panel + Then I should see "Manage associated enterprises" + + Scenario: display a button on bsc control panel to transfer ownership + Given the folllowing "bsc" from "bsc_plugin" + | business_name | identifier | company_name | cnpj | + | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | + And I am logged in as admin + When I am on Bsc Test's control panel + Then I should see "Transfer ownership" + + Scenario: create a new enterprise already associated with a bsc + Given the following user + | login | name | + | pedro-silva | Pedro Silva | + And the folllowing "bsc" from "bsc_plugin" + | business_name | identifier | company_name | cnpj | owner | + | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | pedro-silva | + And organization_approval_method is "none" on environment + And I am logged in as "pedro-silva" + And I am on Bsc Test's control panel + And I follow "Manage associated enterprises" + And I follow "Add new enterprise" + And I fill in the following: + | Name | Associated Enterprise | + | Address | associated-enterprise | + When I press "Save" + Then "Associated Enterprise" should be associated with "Bsc Test" + + Scenario: do not display "add new product" button + Given the following user + | login | name | + | pedro-silva | Pedro Silva | + And the folllowing "bsc" from "bsc_plugin" + | business_name | identifier | company_name | cnpj | owner | + | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | pedro-silva | + And feature "disable_products_for_enterprises" is disabled on environment + And I am logged in as "pedro-silva" + And I am on Bsc Test's control panel + When I follow "Manage Products and Services" + Then I should not see "New product or service" + + Scenario: display bsc's enterprises' products name on the bsc catalog + Given the following user + | login | name | + | pedro-silva | Pedro Silva | + And the folllowing "bsc" from "bsc_plugin" + | business_name | identifier | company_name | cnpj | owner | + | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | pedro-silva | + And the following enterprise + | identifier | name | + | sample-enterprise | Sample Enterprise | + And the following product_category + | name | + | bike | + And the following products + | owner | category | name | + | sample-enterprise | bike | Master Bike | + And "Sample Enterprise" is associated with "Bsc Test" + And I am logged in as "pedro-silva" + When I go to Bsc Test's products page + Then I should see "Master Bike" + And I should see "Sample Enterprise" + + Scenario: display enterprise name linked only if person is member of any Bsc + Given the folllowing "bsc" from "bsc_plugin" + | business_name | identifier | company_name | cnpj | + | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | + | Another Bsc | another-bsc | Another Bsc Test Ltda | 07.970.746/0001-77 | + And the following enterprise + | identifier | name | + | sample-enterprise | Sample Enterprise | + And the following product_category + | name | + | bike | + And the following products + | owner | category | name | + | sample-enterprise | bike | Master Bike | + And "Sample Enterprise" is associated with "Bsc Test" + And the folllowing "bsc" from "bsc_plugin" + | business_name | identifier | company_name | cnpj | + And the following user + | login | name | + | pedro | Pedro Souto | + | maria | Maria Souto | + And pedro is member of another-bsc + And I am logged in as "pedro" + When I go to Bsc Test's products page + Then I should see "Sample Enterprise" + And I should see "Sample Enterprise" within "a.bsc-catalog-enterprise-link" + But I am logged in as "maria" + When I go to Bsc Test's products page + Then I should see "Sample Enterprise" + #TODO -> test that it's not a link + + Scenario: allow only environment administrators to delete bsc profile + Given the folllowing "bsc" from "bsc_plugin" + | business_name | identifier | company_name | cnpj | + | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | + And the following user + | login | name | + | pedro | Pedro Souto | + And "Pedro Souto" is admin of "Bsc Test" + And I am logged in as "pedro" + And I am on Bsc Test's control panel + And I follow "Bsc info and settings" + When I follow "Delete profile" + Then I should see "Access denied" + And "Bsc Test" profile should exist + But I am logged in as admin + And I am on Bsc Test's control panel + And I follow "Bsc info and settings" + When I follow "Delete profile" + Then I should see "Deleting profile Bsc Test" + And I follow "Yes, I am sure" + Then "Bsc Test" profile should not exist + + # Like we can believe that selenium is going to work... + @selenium + Scenario: list already associated enterprises on manage associated enterprises + Given the folllowing "bsc" from "bsc_plugin" + | business_name | identifier | company_name | cnpj | + | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | + And the following enterprises + | identifier | name | + | enterprise-1 | Enterprise 1 | + | enterprise-2 | Enterprise 2 | + And "Enterprise 1" is associated with "Bsc Test" + And "Enterprise 2" is associated with "Bsc Test" + And I am logged in as admin + And I am on Bsc Test's control panel + When I follow "Manage associated enterprises" + Then I should see "Enterprise 1" + And I should see "Enterprise 2" diff --git a/plugins/bsc/features/contract.feature b/plugins/bsc/features/contract.feature new file mode 100644 index 0000000..c242a17 --- /dev/null +++ b/plugins/bsc/features/contract.feature @@ -0,0 +1,21 @@ +Feature: Bsc contract +As a Bsc admin +I would like to register a contract +In order to make negotiations + + Background: + Given "Bsc" plugin is enabled + And the folllowing "bsc" from "bsc_plugin" + | business_name | identifier | company_name | cnpj | + | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | + And I am logged in as admin + + Scenario: be able see the manage contracts button only if the profile is a Bsc + Given the following community + | name | identifier | + | Sample Community | sample-community | + When I am on Sample Community's control panel + Then I should not see "Manage contracts" + But I am on Bsc Test's control panel + Then I should see "Manage contracts" + diff --git a/plugins/bsc/test/features/bsc.feature b/plugins/bsc/test/features/bsc.feature deleted file mode 100644 index 2de0414..0000000 --- a/plugins/bsc/test/features/bsc.feature +++ /dev/null @@ -1,164 +0,0 @@ -Feature: bsc - - Background: - Given "Bsc" plugin is enabled - - Scenario: display link to bsc creation on admin panel when bsc plugin active - Given I am logged in as admin - When I am on the environment control panel - Then I should see "Create Bsc" - When "Bsc" plugin is disabled - And I am on the environment control panel - Then I should not see "Create Bsc" - - Scenario: be able to create a bsc - Given I am logged in as admin - And I am on the environment control panel - And I follow "Create Bsc" - And I fill in the following: - | Business name | Sample Bsc | - | Company name | Sample Bsc | - | profile_data_identifier | sample-identifier | - | Cnpj | 07.970.746/0001-77 | - When I press "Save" - Then there should be a profile named "Sample Bsc" - - Scenario: display a button on bsc control panel to manage associated enterprises - Given the folllowing "bsc" from "bsc_plugin" - | business_name | identifier | company_name | cnpj | - | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | - And I am logged in as admin - When I am on Bsc Test's control panel - Then I should see "Manage associated enterprises" - - Scenario: display a button on bsc control panel to transfer ownership - Given the folllowing "bsc" from "bsc_plugin" - | business_name | identifier | company_name | cnpj | - | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | - And I am logged in as admin - When I am on Bsc Test's control panel - Then I should see "Transfer ownership" - - Scenario: create a new enterprise already associated with a bsc - Given the following user - | login | name | - | pedro-silva | Pedro Silva | - And the folllowing "bsc" from "bsc_plugin" - | business_name | identifier | company_name | cnpj | owner | - | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | pedro-silva | - And organization_approval_method is "none" on environment - And I am logged in as "pedro-silva" - And I am on Bsc Test's control panel - And I follow "Manage associated enterprises" - And I follow "Add new enterprise" - And I fill in the following: - | Name | Associated Enterprise | - | Address | associated-enterprise | - When I press "Save" - Then "Associated Enterprise" should be associated with "Bsc Test" - - Scenario: do not display "add new product" button - Given the following user - | login | name | - | pedro-silva | Pedro Silva | - And the folllowing "bsc" from "bsc_plugin" - | business_name | identifier | company_name | cnpj | owner | - | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | pedro-silva | - And feature "disable_products_for_enterprises" is disabled on environment - And I am logged in as "pedro-silva" - And I am on Bsc Test's control panel - When I follow "Manage Products and Services" - Then I should not see "New product or service" - - Scenario: display bsc's enterprises' products name on the bsc catalog - Given the following user - | login | name | - | pedro-silva | Pedro Silva | - And the folllowing "bsc" from "bsc_plugin" - | business_name | identifier | company_name | cnpj | owner | - | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | pedro-silva | - And the following enterprise - | identifier | name | - | sample-enterprise | Sample Enterprise | - And the following product_category - | name | - | bike | - And the following products - | owner | category | name | - | sample-enterprise | bike | Master Bike | - And "Sample Enterprise" is associated with "Bsc Test" - And I am logged in as "pedro-silva" - When I go to Bsc Test's products page - Then I should see "Master Bike" - And I should see "Sample Enterprise" - - Scenario: display enterprise name linked only if person is member of any Bsc - Given the folllowing "bsc" from "bsc_plugin" - | business_name | identifier | company_name | cnpj | - | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | - | Another Bsc | another-bsc | Another Bsc Test Ltda | 07.970.746/0001-77 | - And the following enterprise - | identifier | name | - | sample-enterprise | Sample Enterprise | - And the following product_category - | name | - | bike | - And the following products - | owner | category | name | - | sample-enterprise | bike | Master Bike | - And "Sample Enterprise" is associated with "Bsc Test" - And the folllowing "bsc" from "bsc_plugin" - | business_name | identifier | company_name | cnpj | - And the following user - | login | name | - | pedro | Pedro Souto | - | maria | Maria Souto | - And pedro is member of another-bsc - And I am logged in as "pedro" - When I go to Bsc Test's products page - Then I should see "Sample Enterprise" - And I should see "Sample Enterprise" within "a.bsc-catalog-enterprise-link" - But I am logged in as "maria" - When I go to Bsc Test's products page - Then I should see "Sample Enterprise" - #TODO -> test that it's not a link - - Scenario: allow only environment administrators to delete bsc profile - Given the folllowing "bsc" from "bsc_plugin" - | business_name | identifier | company_name | cnpj | - | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | - And the following user - | login | name | - | pedro | Pedro Souto | - And "Pedro Souto" is admin of "Bsc Test" - And I am logged in as "pedro" - And I am on Bsc Test's control panel - And I follow "Bsc info and settings" - When I follow "Delete profile" - Then I should see "Access denied" - And "Bsc Test" profile should exist - But I am logged in as admin - And I am on Bsc Test's control panel - And I follow "Bsc info and settings" - When I follow "Delete profile" - Then I should see "Deleting profile Bsc Test" - And I follow "Yes, I am sure" - Then "Bsc Test" profile should not exist - - # Like we can believe that selenium is going to work... - @selenium - Scenario: list already associated enterprises on manage associated enterprises - Given the folllowing "bsc" from "bsc_plugin" - | business_name | identifier | company_name | cnpj | - | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | - And the following enterprises - | identifier | name | - | enterprise-1 | Enterprise 1 | - | enterprise-2 | Enterprise 2 | - And "Enterprise 1" is associated with "Bsc Test" - And "Enterprise 2" is associated with "Bsc Test" - And I am logged in as admin - And I am on Bsc Test's control panel - When I follow "Manage associated enterprises" - Then I should see "Enterprise 1" - And I should see "Enterprise 2" diff --git a/plugins/bsc/test/features/contract.feature b/plugins/bsc/test/features/contract.feature deleted file mode 100644 index c242a17..0000000 --- a/plugins/bsc/test/features/contract.feature +++ /dev/null @@ -1,21 +0,0 @@ -Feature: Bsc contract -As a Bsc admin -I would like to register a contract -In order to make negotiations - - Background: - Given "Bsc" plugin is enabled - And the folllowing "bsc" from "bsc_plugin" - | business_name | identifier | company_name | cnpj | - | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | - And I am logged in as admin - - Scenario: be able see the manage contracts button only if the profile is a Bsc - Given the following community - | name | identifier | - | Sample Community | sample-community | - When I am on Sample Community's control panel - Then I should not see "Manage contracts" - But I am on Bsc Test's control panel - Then I should see "Manage contracts" - diff --git a/plugins/mezuro/features/step_definitions/mezuro_steps.rb b/plugins/mezuro/features/step_definitions/mezuro_steps.rb new file mode 100644 index 0000000..73ca62c --- /dev/null +++ b/plugins/mezuro/features/step_definitions/mezuro_steps.rb @@ -0,0 +1,164 @@ +When /^I create a Mezuro (project|reading group) with the following data$/ do |type, fields| + click_link ("Mezuro " + type) + + fields.rows_hash.each do |name, value| + When %{I fill in "#{name}" with "#{value}"} + end + + click_button "Save" + Article.find_by_name(fields.rows_hash[:Title]) +end + +When /^I create a Mezuro configuration with the following data$/ do |fields| + click_link ("Mezuro configuration") + + fields.rows_hash.each do |name, value| + if name != "Clone" + When %{I fill in "#{name}" with "#{value}"} + end + end + + click_button "Save" + Article.find_by_name(fields.rows_hash[:Title]) +end + +Then /^I directly delete content with name "([^\"]*)" for testing purposes$/ do |content_name| + Article.find_by_name(content_name).destroy +end + +Then /^I should be at the url "([^\"]*)"$/ do |url| + if response.class.to_s == 'Webrat::SeleniumResponse' + URI.parse(response.selenium.get_location).path.should == url + else + URI.parse(current_url).path.should == url + end +end + +Then /^the field "([^"]*)" is empty$/ do |field_name| + find_field(field_name).value.should be_nil +end + +Then /^I should see "([^\"]*)" inside an alert$/ do |message| + alert = page.driver.browser.switch_to.alert + assert_equal message, alert.text + alert.accept +end + +Then /^I should see "([^"]*)" in the "([^"]*)"$/ do |content, labeltext| + find_field(labeltext).value.should == content +end + +Then /^I should see "([^"]*)" button$/ do |button_name| + find_button(button_name).should_not be_nil +end + +Then /^I should see "([^"]*)" in a link$/ do |link_name| + find_link(link_name).should_not be_nil +end + +Then /^I should see "([^"]*)" in the process period select field$/ do |content| + selected = MezuroPlugin::Helpers::ContentViewerHelper.periodicity_options.select { |option| option.first == content }.first + assert_equal selected.last, find_field("repository_process_period").value.to_i +end + +Then /^I should see "([^"]*)" in the repository configuration select field$/ do |content| + selected = Kalibro::Configuration.all.select { |option| option.name == content }.first + assert_equal selected.id, find_field("repository_configuration_id").value.to_i +end + +Then /^I should not see "([^"]*)" button$/ do |button_name| + find_button(button_name).should be_nil +end + +When /^I have a Mezuro (project|reading group|configuration) with the following data$/ do |type, fields| + item = {} + fields.rows_hash.each do |name, value| + if(name=="user" or name=="community") + item.merge!(:profile=>Profile[value]) + else + item.merge!(name => value) + end + end + if (type == "project") + result = MezuroPlugin::ProjectContent.new(item) + elsif (type == "reading group") + result = MezuroPlugin::ReadingGroupContent.new(item) + elsif (type == "configuration") + result = MezuroPlugin::ConfigurationContent.new(item) + end + + result.save! +end + +When /^I have a Mezuro (reading|repository) with the following data$/ do |type, fields| + item = {} + fields.rows_hash.each do |name, value| + if(name=="user" or name=="community") + item.merge!(:profile=>Profile[value]) + else + item.merge!(name => value) + end + end + if (type == "repository") + item["configuration_id"] = Kalibro::Configuration.all.select {|configuration| configuration.name == item["configuration_id"] }.first.id + item.merge!(:project_id => Kalibro::Project.all.last.id) + Kalibro::Repository.create(item) + elsif (type == "reading") + item.merge!(:group_id => Kalibro::ReadingGroup.all.last.id) + Kalibro::Reading.create(item) + end +end + +When /^I erase the "([^"]*)" field$/ do |field_name| + find_field(field_name).set "" +end + +When /^I fill the fields with the new following data$/ do |fields| + fields.rows_hash.each do |key, value| + name = key.to_s + element = find_field(name) + if (element.tag_name.to_s == "select") + select(value, :from => name) + else + element.set value + end + end +end + +When /^I have a Mezuro metric configuration with previous created configuration and reading group$/ do + Kalibro::MetricConfiguration.create({ + :code => 'amloc1', + :metric => {:name => 'Total Coupling Factor', :compound => "false", :scope => 'SOFTWARE', :language => ['JAVA']}, + :base_tool_name => "Analizo", + :weight => "1.0", + :aggregation_form => 'AVERAGE', + :reading_group_id => Kalibro::ReadingGroup.all.last.id, + :configuration_id => Kalibro::Configuration.all.last.id + }) +end + +When /^I follow the (edit|remove) link for "([^"]*)" (repository|reading)$/ do |action, name, type| + if (type == "repository") + project_id = Kalibro::Project.all.last.id + repositories = Kalibro::Repository.repositories_of project_id + id = repositories.select {|option| option.name == name}.first.id + elsif (type == "reading") + reading_group_id = Kalibro::ReadingGroup.all.last.id + readings = Kalibro::Reading.readings_of reading_group_id + id = readings.select {|option| option.label == name}.first.id + if (action == "edit") + action = name + end + end + + elements = all('a', :text => action.capitalize) + link = type + "_id" + action_link = elements.select {|element| (/#{link}=#{id}/ =~ element[:href]) }.first + action_link.click +end + +Then /^I should see the "([^"]*)" color$/ do |color_name| + elements = all('td', :text => "") + found = elements.select { |element| color_name == element[:bgcolor]}.first + assert_not_nil found +end diff --git a/plugins/mezuro/features/support/hooks.rb b/plugins/mezuro/features/support/hooks.rb new file mode 100644 index 0000000..fb89f01 --- /dev/null +++ b/plugins/mezuro/features/support/hooks.rb @@ -0,0 +1,12 @@ +Before do + if !$dunit + command = "#{RAILS_ROOT}/plugins/mezuro/script/tests/prepare_kalibro_query_file.sh" + system command + $dunit = true + end +end + +After ('@kalibro_restart') do + command = "#{RAILS_ROOT}/plugins/mezuro/script/tests/delete_all_kalibro_entries.sh" + system command +end diff --git a/plugins/send_email/features/send_email_plugin.feature b/plugins/send_email/features/send_email_plugin.feature new file mode 100644 index 0000000..36b97a9 --- /dev/null +++ b/plugins/send_email/features/send_email_plugin.feature @@ -0,0 +1,41 @@ +Feature: send_email_plugin + + Background: + Given the following users + | login | name | + | joaosilva | Joao Silva | + And I am logged in as "joaosilva" + + Scenario: expand macro in article content + Given plugin SendEmailPlugin is enabled on environment + And the following articles + | owner | name | body | + | joaosilva | sample-article | URL path to {sendemail} action | + When I go to /joaosilva/sample-article + Then I should see "URL path to /profile/joaosilva/plugins/send_email/deliver action" + + Scenario: expand macro in block content + Given plugin SendEmailPlugin is enabled on environment + And the following blocks + | owner | type | html | + | joaosilva | RawHTMLBlock | URL path to {sendemail} action | + When I go to Joao Silva's homepage + Then I should see "URL path to /profile/joaosilva/plugins/send_email/deliver action" + + Scenario: as admin I can configure plugin + Given I am logged in as admin + When I go to the environment control panel + And I follow "Enable/disable plugins" + Then I should see "SendEmailPlugin" linking to "/admin/plugin/send_email" + + Scenario: configure plugin to allow emails to john@example.com + Given I am logged in as admin + And I go to the environment control panel + And I follow "Enable/disable plugins" + When I follow "SendEmailPlugin" + Then I should not see "john@example.com" + When I fill in "E-Mail addresses you want to allow to send" with "john@example.com" + And I press "Save" + Then I should be on /admin/plugins + When I follow "SendEmailPlugin" + Then I should see "john@example.com" diff --git a/plugins/send_email/test/features/send_email_plugin.feature b/plugins/send_email/test/features/send_email_plugin.feature deleted file mode 100644 index 36b97a9..0000000 --- a/plugins/send_email/test/features/send_email_plugin.feature +++ /dev/null @@ -1,41 +0,0 @@ -Feature: send_email_plugin - - Background: - Given the following users - | login | name | - | joaosilva | Joao Silva | - And I am logged in as "joaosilva" - - Scenario: expand macro in article content - Given plugin SendEmailPlugin is enabled on environment - And the following articles - | owner | name | body | - | joaosilva | sample-article | URL path to {sendemail} action | - When I go to /joaosilva/sample-article - Then I should see "URL path to /profile/joaosilva/plugins/send_email/deliver action" - - Scenario: expand macro in block content - Given plugin SendEmailPlugin is enabled on environment - And the following blocks - | owner | type | html | - | joaosilva | RawHTMLBlock | URL path to {sendemail} action | - When I go to Joao Silva's homepage - Then I should see "URL path to /profile/joaosilva/plugins/send_email/deliver action" - - Scenario: as admin I can configure plugin - Given I am logged in as admin - When I go to the environment control panel - And I follow "Enable/disable plugins" - Then I should see "SendEmailPlugin" linking to "/admin/plugin/send_email" - - Scenario: configure plugin to allow emails to john@example.com - Given I am logged in as admin - And I go to the environment control panel - And I follow "Enable/disable plugins" - When I follow "SendEmailPlugin" - Then I should not see "john@example.com" - When I fill in "E-Mail addresses you want to allow to send" with "john@example.com" - And I press "Save" - Then I should be on /admin/plugins - When I follow "SendEmailPlugin" - Then I should see "john@example.com" diff --git a/script/noosfero-plugins b/script/noosfero-plugins index fb9cb68..9013e7b 100755 --- a/script/noosfero-plugins +++ b/script/noosfero-plugins @@ -88,7 +88,9 @@ _enable(){ if [ "$dependencies_ok" = true ]; then ln -s "$source" "$target" plugins_public_dir="$NOOSFERO_DIR/public/plugins" + plugins_features_dir="$NOOSFERO_DIR/features/plugins" test -d "$target/public/" && ln -s "$target/public" "$plugins_public_dir/$plugin" + test -d "$target/features" && ln -s "$target/features" "$plugins_features_dir/$plugin" _say "$plugin enabled" needs_migrate=true else @@ -101,9 +103,11 @@ _disable(){ plugin="$1" target="$enabled_plugins_dir/$plugin" plugins_public_dir="$NOOSFERO_DIR/public/plugins" + plugins_features_dir="$NOOSFERO_DIR/features/plugins" if [ -h "$target" ]; then rm "$target" test -h "$plugins_public_dir/$plugin" && rm "$plugins_public_dir/$plugin" + test -h "$plugins_features_dir/$plugin" && rm "$plugins_features_dir/$plugin" _say "$plugin disabled" else _say "$plugin already disabled" -- libgit2 0.21.2