Commit 298668971b47defb8a994f9338e097ae4558707e

Authored by Rodrigo Souto
1 parent 2711a1d5

Allowing plugins to extend cucumber steps and support

Now the plugins can create the folders 'step_definitions' and 'support'
under the folder 'features' to extend cucumber features as it pleases.

The plugins with any extension gain 2 new profiles on the cucumber.yml
file. For example, for mezuro plugin, it will have the 'mezuro' and
'mezuro_selenium' cucumber profiles that will load the appropriate
files. So if you extend cucumber with new steps, hooks, etc; and you
want to run the cucumber tests of mezuro plugin with all these
extensions you must include '-p mezuro' on the cucumber call (or '-p
mezuro-selenium' to run selenium profile). This is already handled by
the rake task that runs the plugins' tests. So it'd be much better to
run 'rake test:noosfero_plugins:mezuro:{cucumber,selenium}' instead.

Also:
   * Moving plugins' 'features' folder to the plugin' root instead of
     inside the folder 'test' (just following Rails convention).
   * Moving specific steps and hooks of mezuro from core to the plugin.
   * Requiring plugin to be enabled to run any of its tests.
config/cucumber.yml
1   -default: --color --format progress --strict --tags ~@selenium --tags ~@selenium-fixme --tags ~@fixme --exclude features/support/selenium.rb -r features/support -r features/step_definitions
2   -selenium: --strict --tags @selenium -r features/support -r features/step_definitions
  1 +<% base_requires = '-r features/support -r features/step_definitions' %>
  2 +<% default_options = "color --format progress --strict --tags ~@selenium --tags ~@selenium-fixme --tags ~@fixme --exclude features/support/selenium.rb #{base_requires}" %>
  3 +<% selenium_options = "--strict --tags @selenium #{base_requires}" %>
  4 +
  5 +default: <%= default_options %>
  6 +selenium: <% selenium_options %>
  7 +
  8 +<% enabled_plugins = Dir.glob(File.join('config', 'plugins', '*')).map{|path| plugin = File.basename(path); plugin if File.exist?(File.join('features', 'plugins', plugin)) }.compact %>
  9 +
  10 +<% enabled_plugins.each do |plugin| %>
  11 +<% plugin_features_path = File.join('features', 'plugins', plugin) %>
  12 +<% plugin_base_requires = '' %>
  13 +<% plugin_base_requires += " -r features/plugins/#{plugin}/support" if File.exist?(File.join(plugin_features_path, 'support')) %>
  14 +<% plugin_base_requires += " -r features/plugins/#{plugin}/step_definitions" if File.exist?(File.join(plugin_features_path, 'step_definitions')) %>
  15 +<%= "#{plugin}: #{default_options} #{plugin_base_requires}" %>
  16 +<%= "#{plugin}_selenium: #{selenium_options} #{plugin_base_requires}" %>
  17 +<% end %>
... ...
features/step_definitions/mezuro_steps.rb
... ... @@ -1,164 +0,0 @@
1   -When /^I create a Mezuro (project|reading group) with the following data$/ do |type, fields|
2   - click_link ("Mezuro " + type)
3   -
4   - fields.rows_hash.each do |name, value|
5   - When %{I fill in "#{name}" with "#{value}"}
6   - end
7   -
8   - click_button "Save"
9   - Article.find_by_name(fields.rows_hash[:Title])
10   -end
11   -
12   -When /^I create a Mezuro configuration with the following data$/ do |fields|
13   - click_link ("Mezuro configuration")
14   -
15   - fields.rows_hash.each do |name, value|
16   - if name != "Clone"
17   - When %{I fill in "#{name}" with "#{value}"}
18   - end
19   - end
20   -
21   - click_button "Save"
22   - Article.find_by_name(fields.rows_hash[:Title])
23   -end
24   -
25   -Then /^I directly delete content with name "([^\"]*)" for testing purposes$/ do |content_name|
26   - Article.find_by_name(content_name).destroy
27   -end
28   -
29   -Then /^I should be at the url "([^\"]*)"$/ do |url|
30   - if response.class.to_s == 'Webrat::SeleniumResponse'
31   - URI.parse(response.selenium.get_location).path.should == url
32   - else
33   - URI.parse(current_url).path.should == url
34   - end
35   -end
36   -
37   -Then /^the field "([^"]*)" is empty$/ do |field_name|
38   - find_field(field_name).value.should be_nil
39   -end
40   -
41   -Then /^I should see "([^\"]*)" inside an alert$/ do |message|
42   - alert = page.driver.browser.switch_to.alert
43   - assert_equal message, alert.text
44   - alert.accept
45   -end
46   -
47   -Then /^I should see "([^"]*)" in the "([^"]*)"$/ do |content, labeltext|
48   - find_field(labeltext).value.should == content
49   -end
50   -
51   -Then /^I should see "([^"]*)" button$/ do |button_name|
52   - find_button(button_name).should_not be_nil
53   -end
54   -
55   -Then /^I should see "([^"]*)" in a link$/ do |link_name|
56   - find_link(link_name).should_not be_nil
57   -end
58   -
59   -Then /^I should see "([^"]*)" in the process period select field$/ do |content|
60   - selected = MezuroPlugin::Helpers::ContentViewerHelper.periodicity_options.select { |option| option.first == content }.first
61   - assert_equal selected.last, find_field("repository_process_period").value.to_i
62   -end
63   -
64   -Then /^I should see "([^"]*)" in the repository configuration select field$/ do |content|
65   - selected = Kalibro::Configuration.all.select { |option| option.name == content }.first
66   - assert_equal selected.id, find_field("repository_configuration_id").value.to_i
67   -end
68   -
69   -Then /^I should not see "([^"]*)" button$/ do |button_name|
70   - find_button(button_name).should be_nil
71   -end
72   -
73   -When /^I have a Mezuro (project|reading group|configuration) with the following data$/ do |type, fields|
74   - item = {}
75   - fields.rows_hash.each do |name, value|
76   - if(name=="user" or name=="community")
77   - item.merge!(:profile=>Profile[value])
78   - else
79   - item.merge!(name => value)
80   - end
81   - end
82   - if (type == "project")
83   - result = MezuroPlugin::ProjectContent.new(item)
84   - elsif (type == "reading group")
85   - result = MezuroPlugin::ReadingGroupContent.new(item)
86   - elsif (type == "configuration")
87   - result = MezuroPlugin::ConfigurationContent.new(item)
88   - end
89   -
90   - result.save!
91   -end
92   -
93   -When /^I have a Mezuro (reading|repository) with the following data$/ do |type, fields|
94   - item = {}
95   - fields.rows_hash.each do |name, value|
96   - if(name=="user" or name=="community")
97   - item.merge!(:profile=>Profile[value])
98   - else
99   - item.merge!(name => value)
100   - end
101   - end
102   - if (type == "repository")
103   - item["configuration_id"] = Kalibro::Configuration.all.select {|configuration| configuration.name == item["configuration_id"] }.first.id
104   - item.merge!(:project_id => Kalibro::Project.all.last.id)
105   - Kalibro::Repository.create(item)
106   - elsif (type == "reading")
107   - item.merge!(:group_id => Kalibro::ReadingGroup.all.last.id)
108   - Kalibro::Reading.create(item)
109   - end
110   -end
111   -
112   -When /^I erase the "([^"]*)" field$/ do |field_name|
113   - find_field(field_name).set ""
114   -end
115   -
116   -When /^I fill the fields with the new following data$/ do |fields|
117   - fields.rows_hash.each do |key, value|
118   - name = key.to_s
119   - element = find_field(name)
120   - if (element.tag_name.to_s == "select")
121   - select(value, :from => name)
122   - else
123   - element.set value
124   - end
125   - end
126   -end
127   -
128   -When /^I have a Mezuro metric configuration with previous created configuration and reading group$/ do
129   - Kalibro::MetricConfiguration.create({
130   - :code => 'amloc1',
131   - :metric => {:name => 'Total Coupling Factor', :compound => "false", :scope => 'SOFTWARE', :language => ['JAVA']},
132   - :base_tool_name => "Analizo",
133   - :weight => "1.0",
134   - :aggregation_form => 'AVERAGE',
135   - :reading_group_id => Kalibro::ReadingGroup.all.last.id,
136   - :configuration_id => Kalibro::Configuration.all.last.id
137   - })
138   -end
139   -
140   -When /^I follow the (edit|remove) link for "([^"]*)" (repository|reading)$/ do |action, name, type|
141   - if (type == "repository")
142   - project_id = Kalibro::Project.all.last.id
143   - repositories = Kalibro::Repository.repositories_of project_id
144   - id = repositories.select {|option| option.name == name}.first.id
145   - elsif (type == "reading")
146   - reading_group_id = Kalibro::ReadingGroup.all.last.id
147   - readings = Kalibro::Reading.readings_of reading_group_id
148   - id = readings.select {|option| option.label == name}.first.id
149   - if (action == "edit")
150   - action = name
151   - end
152   - end
153   -
154   - elements = all('a', :text => action.capitalize)
155   - link = type + "_id"
156   - action_link = elements.select {|element| (/#{link}=#{id}/ =~ element[:href]) }.first
157   - action_link.click
158   -end
159   -
160   -Then /^I should see the "([^"]*)" color$/ do |color_name|
161   - elements = all('td', :text => "")
162   - found = elements.select { |element| color_name == element[:bgcolor]}.first
163   - assert_not_nil found
164   -end
features/support/hooks.rb
... ... @@ -1,12 +0,0 @@
1   -Before do
2   - if !$dunit
3   - command = "#{RAILS_ROOT}/plugins/mezuro/script/tests/prepare_kalibro_query_file.sh"
4   - system command
5   - $dunit = true
6   - end
7   -end
8   -
9   -After ('@kalibro_restart') do
10   - command = "#{RAILS_ROOT}/plugins/mezuro/script/tests/delete_all_kalibro_entries.sh"
11   - system command
12   -end
lib/tasks/plugins_tests.rake
... ... @@ -17,6 +17,14 @@ def plugin_name(plugin)
17 17 "#{plugin} plugin"
18 18 end
19 19  
  20 +def plugin_enabled?(plugin)
  21 + File.exist?(File.join('config', 'plugins', plugin))
  22 +end
  23 +
  24 +def plugin_disabled_warning(plugin)
  25 + puts "E: you should enable #{plugin} plugin before running it's tests!"
  26 +end
  27 +
20 28 def run_tests(name, files_glob)
21 29 files = Dir.glob(files_glob)
22 30 if files.empty?
... ... @@ -38,21 +46,33 @@ end
38 46 def plugin_test_task(name, plugin, files_glob)
39 47 desc "Run #{name} tests for #{plugin_name(plugin)}"
40 48 task name => 'db:test:plugins:prepare' do |t|
41   - run_tests t.name, files_glob
  49 + if plugin_enabled?(plugin)
  50 + run_tests t.name, files_glob
  51 + else
  52 + plugin_disabled_warning(plugin)
  53 + end
42 54 end
43 55 end
44 56  
45 57 def plugin_cucumber_task(name, plugin, files_glob)
46 58 desc "Run #{name} tests for #{plugin_name(plugin)}"
47 59 task name => 'db:test:plugins:prepare' do |t|
48   - run_cucumber t.name, :default, files_glob
  60 + if plugin_enabled?(plugin)
  61 + run_cucumber t.name, plugin, files_glob
  62 + else
  63 + plugin_disabled_warning(plugin)
  64 + end
49 65 end
50 66 end
51 67  
52 68 def plugin_selenium_task(name, plugin, files_glob)
53 69 desc "Run #{name} tests for #{plugin_name(plugin)}"
54 70 task name => 'db:test:plugins:prepare' do |t|
55   - run_cucumber t.name, :selenium, files_glob
  71 + if plugin_enabled?(plugin)
  72 + run_cucumber t.name, "#{plugin}_selenium", files_glob
  73 + else
  74 + plugin_disabled_warning(plugin)
  75 + end
56 76 end
57 77 end
58 78  
... ... @@ -81,8 +101,8 @@ namespace :test do
81 101 plugin_test_task :units, plugin, "plugins/#{plugin}/test/unit/**/*.rb"
82 102 plugin_test_task :functionals, plugin, "plugins/#{plugin}/test/functional/**/*.rb"
83 103 plugin_test_task :integration, plugin, "plugins/#{plugin}/test/integration/**/*.rb"
84   - plugin_cucumber_task :cucumber, plugin, "plugins/#{plugin}/test/features/**/*.feature"
85   - plugin_selenium_task :selenium, plugin, "plugins/#{plugin}/test/features/**/*.feature"
  104 + plugin_cucumber_task :cucumber, plugin, "plugins/#{plugin}/features/**/*.feature"
  105 + plugin_selenium_task :selenium, plugin, "plugins/#{plugin}/features/**/*.feature"
86 106 end
87 107  
88 108 test_sequence_task(plugin, plugin, "#{plugin}:units", "#{plugin}:functionals", "#{plugin}:integration", "#{plugin}:cucumber", "#{plugin}:selenium")
... ...
plugins/bsc/features/bsc.feature 0 → 100644
... ... @@ -0,0 +1,164 @@
  1 +Feature: bsc
  2 +
  3 + Background:
  4 + Given "Bsc" plugin is enabled
  5 +
  6 + Scenario: display link to bsc creation on admin panel when bsc plugin active
  7 + Given I am logged in as admin
  8 + When I am on the environment control panel
  9 + Then I should see "Create Bsc"
  10 + When "Bsc" plugin is disabled
  11 + And I am on the environment control panel
  12 + Then I should not see "Create Bsc"
  13 +
  14 + Scenario: be able to create a bsc
  15 + Given I am logged in as admin
  16 + And I am on the environment control panel
  17 + And I follow "Create Bsc"
  18 + And I fill in the following:
  19 + | Business name | Sample Bsc |
  20 + | Company name | Sample Bsc |
  21 + | profile_data_identifier | sample-identifier |
  22 + | Cnpj | 07.970.746/0001-77 |
  23 + When I press "Save"
  24 + Then there should be a profile named "Sample Bsc"
  25 +
  26 + Scenario: display a button on bsc control panel to manage associated enterprises
  27 + Given the folllowing "bsc" from "bsc_plugin"
  28 + | business_name | identifier | company_name | cnpj |
  29 + | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 |
  30 + And I am logged in as admin
  31 + When I am on Bsc Test's control panel
  32 + Then I should see "Manage associated enterprises"
  33 +
  34 + Scenario: display a button on bsc control panel to transfer ownership
  35 + Given the folllowing "bsc" from "bsc_plugin"
  36 + | business_name | identifier | company_name | cnpj |
  37 + | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 |
  38 + And I am logged in as admin
  39 + When I am on Bsc Test's control panel
  40 + Then I should see "Transfer ownership"
  41 +
  42 + Scenario: create a new enterprise already associated with a bsc
  43 + Given the following user
  44 + | login | name |
  45 + | pedro-silva | Pedro Silva |
  46 + And the folllowing "bsc" from "bsc_plugin"
  47 + | business_name | identifier | company_name | cnpj | owner |
  48 + | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | pedro-silva |
  49 + And organization_approval_method is "none" on environment
  50 + And I am logged in as "pedro-silva"
  51 + And I am on Bsc Test's control panel
  52 + And I follow "Manage associated enterprises"
  53 + And I follow "Add new enterprise"
  54 + And I fill in the following:
  55 + | Name | Associated Enterprise |
  56 + | Address | associated-enterprise |
  57 + When I press "Save"
  58 + Then "Associated Enterprise" should be associated with "Bsc Test"
  59 +
  60 + Scenario: do not display "add new product" button
  61 + Given the following user
  62 + | login | name |
  63 + | pedro-silva | Pedro Silva |
  64 + And the folllowing "bsc" from "bsc_plugin"
  65 + | business_name | identifier | company_name | cnpj | owner |
  66 + | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | pedro-silva |
  67 + And feature "disable_products_for_enterprises" is disabled on environment
  68 + And I am logged in as "pedro-silva"
  69 + And I am on Bsc Test's control panel
  70 + When I follow "Manage Products and Services"
  71 + Then I should not see "New product or service"
  72 +
  73 + Scenario: display bsc's enterprises' products name on the bsc catalog
  74 + Given the following user
  75 + | login | name |
  76 + | pedro-silva | Pedro Silva |
  77 + And the folllowing "bsc" from "bsc_plugin"
  78 + | business_name | identifier | company_name | cnpj | owner |
  79 + | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | pedro-silva |
  80 + And the following enterprise
  81 + | identifier | name |
  82 + | sample-enterprise | Sample Enterprise |
  83 + And the following product_category
  84 + | name |
  85 + | bike |
  86 + And the following products
  87 + | owner | category | name |
  88 + | sample-enterprise | bike | Master Bike |
  89 + And "Sample Enterprise" is associated with "Bsc Test"
  90 + And I am logged in as "pedro-silva"
  91 + When I go to Bsc Test's products page
  92 + Then I should see "Master Bike"
  93 + And I should see "Sample Enterprise"
  94 +
  95 + Scenario: display enterprise name linked only if person is member of any Bsc
  96 + Given the folllowing "bsc" from "bsc_plugin"
  97 + | business_name | identifier | company_name | cnpj |
  98 + | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 |
  99 + | Another Bsc | another-bsc | Another Bsc Test Ltda | 07.970.746/0001-77 |
  100 + And the following enterprise
  101 + | identifier | name |
  102 + | sample-enterprise | Sample Enterprise |
  103 + And the following product_category
  104 + | name |
  105 + | bike |
  106 + And the following products
  107 + | owner | category | name |
  108 + | sample-enterprise | bike | Master Bike |
  109 + And "Sample Enterprise" is associated with "Bsc Test"
  110 + And the folllowing "bsc" from "bsc_plugin"
  111 + | business_name | identifier | company_name | cnpj |
  112 + And the following user
  113 + | login | name |
  114 + | pedro | Pedro Souto |
  115 + | maria | Maria Souto |
  116 + And pedro is member of another-bsc
  117 + And I am logged in as "pedro"
  118 + When I go to Bsc Test's products page
  119 + Then I should see "Sample Enterprise"
  120 + And I should see "Sample Enterprise" within "a.bsc-catalog-enterprise-link"
  121 + But I am logged in as "maria"
  122 + When I go to Bsc Test's products page
  123 + Then I should see "Sample Enterprise"
  124 + #TODO -> test that it's not a link
  125 +
  126 + Scenario: allow only environment administrators to delete bsc profile
  127 + Given the folllowing "bsc" from "bsc_plugin"
  128 + | business_name | identifier | company_name | cnpj |
  129 + | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 |
  130 + And the following user
  131 + | login | name |
  132 + | pedro | Pedro Souto |
  133 + And "Pedro Souto" is admin of "Bsc Test"
  134 + And I am logged in as "pedro"
  135 + And I am on Bsc Test's control panel
  136 + And I follow "Bsc info and settings"
  137 + When I follow "Delete profile"
  138 + Then I should see "Access denied"
  139 + And "Bsc Test" profile should exist
  140 + But I am logged in as admin
  141 + And I am on Bsc Test's control panel
  142 + And I follow "Bsc info and settings"
  143 + When I follow "Delete profile"
  144 + Then I should see "Deleting profile Bsc Test"
  145 + And I follow "Yes, I am sure"
  146 + Then "Bsc Test" profile should not exist
  147 +
  148 + # Like we can believe that selenium is going to work...
  149 + @selenium
  150 + Scenario: list already associated enterprises on manage associated enterprises
  151 + Given the folllowing "bsc" from "bsc_plugin"
  152 + | business_name | identifier | company_name | cnpj |
  153 + | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 |
  154 + And the following enterprises
  155 + | identifier | name |
  156 + | enterprise-1 | Enterprise 1 |
  157 + | enterprise-2 | Enterprise 2 |
  158 + And "Enterprise 1" is associated with "Bsc Test"
  159 + And "Enterprise 2" is associated with "Bsc Test"
  160 + And I am logged in as admin
  161 + And I am on Bsc Test's control panel
  162 + When I follow "Manage associated enterprises"
  163 + Then I should see "Enterprise 1"
  164 + And I should see "Enterprise 2"
... ...
plugins/bsc/features/contract.feature 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +Feature: Bsc contract
  2 +As a Bsc admin
  3 +I would like to register a contract
  4 +In order to make negotiations
  5 +
  6 + Background:
  7 + Given "Bsc" plugin is enabled
  8 + And the folllowing "bsc" from "bsc_plugin"
  9 + | business_name | identifier | company_name | cnpj |
  10 + | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 |
  11 + And I am logged in as admin
  12 +
  13 + Scenario: be able see the manage contracts button only if the profile is a Bsc
  14 + Given the following community
  15 + | name | identifier |
  16 + | Sample Community | sample-community |
  17 + When I am on Sample Community's control panel
  18 + Then I should not see "Manage contracts"
  19 + But I am on Bsc Test's control panel
  20 + Then I should see "Manage contracts"
  21 +
... ...
plugins/bsc/test/features/bsc.feature
... ... @@ -1,164 +0,0 @@
1   -Feature: bsc
2   -
3   - Background:
4   - Given "Bsc" plugin is enabled
5   -
6   - Scenario: display link to bsc creation on admin panel when bsc plugin active
7   - Given I am logged in as admin
8   - When I am on the environment control panel
9   - Then I should see "Create Bsc"
10   - When "Bsc" plugin is disabled
11   - And I am on the environment control panel
12   - Then I should not see "Create Bsc"
13   -
14   - Scenario: be able to create a bsc
15   - Given I am logged in as admin
16   - And I am on the environment control panel
17   - And I follow "Create Bsc"
18   - And I fill in the following:
19   - | Business name | Sample Bsc |
20   - | Company name | Sample Bsc |
21   - | profile_data_identifier | sample-identifier |
22   - | Cnpj | 07.970.746/0001-77 |
23   - When I press "Save"
24   - Then there should be a profile named "Sample Bsc"
25   -
26   - Scenario: display a button on bsc control panel to manage associated enterprises
27   - Given the folllowing "bsc" from "bsc_plugin"
28   - | business_name | identifier | company_name | cnpj |
29   - | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 |
30   - And I am logged in as admin
31   - When I am on Bsc Test's control panel
32   - Then I should see "Manage associated enterprises"
33   -
34   - Scenario: display a button on bsc control panel to transfer ownership
35   - Given the folllowing "bsc" from "bsc_plugin"
36   - | business_name | identifier | company_name | cnpj |
37   - | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 |
38   - And I am logged in as admin
39   - When I am on Bsc Test's control panel
40   - Then I should see "Transfer ownership"
41   -
42   - Scenario: create a new enterprise already associated with a bsc
43   - Given the following user
44   - | login | name |
45   - | pedro-silva | Pedro Silva |
46   - And the folllowing "bsc" from "bsc_plugin"
47   - | business_name | identifier | company_name | cnpj | owner |
48   - | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | pedro-silva |
49   - And organization_approval_method is "none" on environment
50   - And I am logged in as "pedro-silva"
51   - And I am on Bsc Test's control panel
52   - And I follow "Manage associated enterprises"
53   - And I follow "Add new enterprise"
54   - And I fill in the following:
55   - | Name | Associated Enterprise |
56   - | Address | associated-enterprise |
57   - When I press "Save"
58   - Then "Associated Enterprise" should be associated with "Bsc Test"
59   -
60   - Scenario: do not display "add new product" button
61   - Given the following user
62   - | login | name |
63   - | pedro-silva | Pedro Silva |
64   - And the folllowing "bsc" from "bsc_plugin"
65   - | business_name | identifier | company_name | cnpj | owner |
66   - | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | pedro-silva |
67   - And feature "disable_products_for_enterprises" is disabled on environment
68   - And I am logged in as "pedro-silva"
69   - And I am on Bsc Test's control panel
70   - When I follow "Manage Products and Services"
71   - Then I should not see "New product or service"
72   -
73   - Scenario: display bsc's enterprises' products name on the bsc catalog
74   - Given the following user
75   - | login | name |
76   - | pedro-silva | Pedro Silva |
77   - And the folllowing "bsc" from "bsc_plugin"
78   - | business_name | identifier | company_name | cnpj | owner |
79   - | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 | pedro-silva |
80   - And the following enterprise
81   - | identifier | name |
82   - | sample-enterprise | Sample Enterprise |
83   - And the following product_category
84   - | name |
85   - | bike |
86   - And the following products
87   - | owner | category | name |
88   - | sample-enterprise | bike | Master Bike |
89   - And "Sample Enterprise" is associated with "Bsc Test"
90   - And I am logged in as "pedro-silva"
91   - When I go to Bsc Test's products page
92   - Then I should see "Master Bike"
93   - And I should see "Sample Enterprise"
94   -
95   - Scenario: display enterprise name linked only if person is member of any Bsc
96   - Given the folllowing "bsc" from "bsc_plugin"
97   - | business_name | identifier | company_name | cnpj |
98   - | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 |
99   - | Another Bsc | another-bsc | Another Bsc Test Ltda | 07.970.746/0001-77 |
100   - And the following enterprise
101   - | identifier | name |
102   - | sample-enterprise | Sample Enterprise |
103   - And the following product_category
104   - | name |
105   - | bike |
106   - And the following products
107   - | owner | category | name |
108   - | sample-enterprise | bike | Master Bike |
109   - And "Sample Enterprise" is associated with "Bsc Test"
110   - And the folllowing "bsc" from "bsc_plugin"
111   - | business_name | identifier | company_name | cnpj |
112   - And the following user
113   - | login | name |
114   - | pedro | Pedro Souto |
115   - | maria | Maria Souto |
116   - And pedro is member of another-bsc
117   - And I am logged in as "pedro"
118   - When I go to Bsc Test's products page
119   - Then I should see "Sample Enterprise"
120   - And I should see "Sample Enterprise" within "a.bsc-catalog-enterprise-link"
121   - But I am logged in as "maria"
122   - When I go to Bsc Test's products page
123   - Then I should see "Sample Enterprise"
124   - #TODO -> test that it's not a link
125   -
126   - Scenario: allow only environment administrators to delete bsc profile
127   - Given the folllowing "bsc" from "bsc_plugin"
128   - | business_name | identifier | company_name | cnpj |
129   - | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 |
130   - And the following user
131   - | login | name |
132   - | pedro | Pedro Souto |
133   - And "Pedro Souto" is admin of "Bsc Test"
134   - And I am logged in as "pedro"
135   - And I am on Bsc Test's control panel
136   - And I follow "Bsc info and settings"
137   - When I follow "Delete profile"
138   - Then I should see "Access denied"
139   - And "Bsc Test" profile should exist
140   - But I am logged in as admin
141   - And I am on Bsc Test's control panel
142   - And I follow "Bsc info and settings"
143   - When I follow "Delete profile"
144   - Then I should see "Deleting profile Bsc Test"
145   - And I follow "Yes, I am sure"
146   - Then "Bsc Test" profile should not exist
147   -
148   - # Like we can believe that selenium is going to work...
149   - @selenium
150   - Scenario: list already associated enterprises on manage associated enterprises
151   - Given the folllowing "bsc" from "bsc_plugin"
152   - | business_name | identifier | company_name | cnpj |
153   - | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 |
154   - And the following enterprises
155   - | identifier | name |
156   - | enterprise-1 | Enterprise 1 |
157   - | enterprise-2 | Enterprise 2 |
158   - And "Enterprise 1" is associated with "Bsc Test"
159   - And "Enterprise 2" is associated with "Bsc Test"
160   - And I am logged in as admin
161   - And I am on Bsc Test's control panel
162   - When I follow "Manage associated enterprises"
163   - Then I should see "Enterprise 1"
164   - And I should see "Enterprise 2"
plugins/bsc/test/features/contract.feature
... ... @@ -1,21 +0,0 @@
1   -Feature: Bsc contract
2   -As a Bsc admin
3   -I would like to register a contract
4   -In order to make negotiations
5   -
6   - Background:
7   - Given "Bsc" plugin is enabled
8   - And the folllowing "bsc" from "bsc_plugin"
9   - | business_name | identifier | company_name | cnpj |
10   - | Bsc Test | bsc-test | Bsc Test Ltda | 94.132.024/0001-48 |
11   - And I am logged in as admin
12   -
13   - Scenario: be able see the manage contracts button only if the profile is a Bsc
14   - Given the following community
15   - | name | identifier |
16   - | Sample Community | sample-community |
17   - When I am on Sample Community's control panel
18   - Then I should not see "Manage contracts"
19   - But I am on Bsc Test's control panel
20   - Then I should see "Manage contracts"
21   -
plugins/mezuro/features/step_definitions/mezuro_steps.rb 0 → 100644
... ... @@ -0,0 +1,164 @@
  1 +When /^I create a Mezuro (project|reading group) with the following data$/ do |type, fields|
  2 + click_link ("Mezuro " + type)
  3 +
  4 + fields.rows_hash.each do |name, value|
  5 + When %{I fill in "#{name}" with "#{value}"}
  6 + end
  7 +
  8 + click_button "Save"
  9 + Article.find_by_name(fields.rows_hash[:Title])
  10 +end
  11 +
  12 +When /^I create a Mezuro configuration with the following data$/ do |fields|
  13 + click_link ("Mezuro configuration")
  14 +
  15 + fields.rows_hash.each do |name, value|
  16 + if name != "Clone"
  17 + When %{I fill in "#{name}" with "#{value}"}
  18 + end
  19 + end
  20 +
  21 + click_button "Save"
  22 + Article.find_by_name(fields.rows_hash[:Title])
  23 +end
  24 +
  25 +Then /^I directly delete content with name "([^\"]*)" for testing purposes$/ do |content_name|
  26 + Article.find_by_name(content_name).destroy
  27 +end
  28 +
  29 +Then /^I should be at the url "([^\"]*)"$/ do |url|
  30 + if response.class.to_s == 'Webrat::SeleniumResponse'
  31 + URI.parse(response.selenium.get_location).path.should == url
  32 + else
  33 + URI.parse(current_url).path.should == url
  34 + end
  35 +end
  36 +
  37 +Then /^the field "([^"]*)" is empty$/ do |field_name|
  38 + find_field(field_name).value.should be_nil
  39 +end
  40 +
  41 +Then /^I should see "([^\"]*)" inside an alert$/ do |message|
  42 + alert = page.driver.browser.switch_to.alert
  43 + assert_equal message, alert.text
  44 + alert.accept
  45 +end
  46 +
  47 +Then /^I should see "([^"]*)" in the "([^"]*)"$/ do |content, labeltext|
  48 + find_field(labeltext).value.should == content
  49 +end
  50 +
  51 +Then /^I should see "([^"]*)" button$/ do |button_name|
  52 + find_button(button_name).should_not be_nil
  53 +end
  54 +
  55 +Then /^I should see "([^"]*)" in a link$/ do |link_name|
  56 + find_link(link_name).should_not be_nil
  57 +end
  58 +
  59 +Then /^I should see "([^"]*)" in the process period select field$/ do |content|
  60 + selected = MezuroPlugin::Helpers::ContentViewerHelper.periodicity_options.select { |option| option.first == content }.first
  61 + assert_equal selected.last, find_field("repository_process_period").value.to_i
  62 +end
  63 +
  64 +Then /^I should see "([^"]*)" in the repository configuration select field$/ do |content|
  65 + selected = Kalibro::Configuration.all.select { |option| option.name == content }.first
  66 + assert_equal selected.id, find_field("repository_configuration_id").value.to_i
  67 +end
  68 +
  69 +Then /^I should not see "([^"]*)" button$/ do |button_name|
  70 + find_button(button_name).should be_nil
  71 +end
  72 +
  73 +When /^I have a Mezuro (project|reading group|configuration) with the following data$/ do |type, fields|
  74 + item = {}
  75 + fields.rows_hash.each do |name, value|
  76 + if(name=="user" or name=="community")
  77 + item.merge!(:profile=>Profile[value])
  78 + else
  79 + item.merge!(name => value)
  80 + end
  81 + end
  82 + if (type == "project")
  83 + result = MezuroPlugin::ProjectContent.new(item)
  84 + elsif (type == "reading group")
  85 + result = MezuroPlugin::ReadingGroupContent.new(item)
  86 + elsif (type == "configuration")
  87 + result = MezuroPlugin::ConfigurationContent.new(item)
  88 + end
  89 +
  90 + result.save!
  91 +end
  92 +
  93 +When /^I have a Mezuro (reading|repository) with the following data$/ do |type, fields|
  94 + item = {}
  95 + fields.rows_hash.each do |name, value|
  96 + if(name=="user" or name=="community")
  97 + item.merge!(:profile=>Profile[value])
  98 + else
  99 + item.merge!(name => value)
  100 + end
  101 + end
  102 + if (type == "repository")
  103 + item["configuration_id"] = Kalibro::Configuration.all.select {|configuration| configuration.name == item["configuration_id"] }.first.id
  104 + item.merge!(:project_id => Kalibro::Project.all.last.id)
  105 + Kalibro::Repository.create(item)
  106 + elsif (type == "reading")
  107 + item.merge!(:group_id => Kalibro::ReadingGroup.all.last.id)
  108 + Kalibro::Reading.create(item)
  109 + end
  110 +end
  111 +
  112 +When /^I erase the "([^"]*)" field$/ do |field_name|
  113 + find_field(field_name).set ""
  114 +end
  115 +
  116 +When /^I fill the fields with the new following data$/ do |fields|
  117 + fields.rows_hash.each do |key, value|
  118 + name = key.to_s
  119 + element = find_field(name)
  120 + if (element.tag_name.to_s == "select")
  121 + select(value, :from => name)
  122 + else
  123 + element.set value
  124 + end
  125 + end
  126 +end
  127 +
  128 +When /^I have a Mezuro metric configuration with previous created configuration and reading group$/ do
  129 + Kalibro::MetricConfiguration.create({
  130 + :code => 'amloc1',
  131 + :metric => {:name => 'Total Coupling Factor', :compound => "false", :scope => 'SOFTWARE', :language => ['JAVA']},
  132 + :base_tool_name => "Analizo",
  133 + :weight => "1.0",
  134 + :aggregation_form => 'AVERAGE',
  135 + :reading_group_id => Kalibro::ReadingGroup.all.last.id,
  136 + :configuration_id => Kalibro::Configuration.all.last.id
  137 + })
  138 +end
  139 +
  140 +When /^I follow the (edit|remove) link for "([^"]*)" (repository|reading)$/ do |action, name, type|
  141 + if (type == "repository")
  142 + project_id = Kalibro::Project.all.last.id
  143 + repositories = Kalibro::Repository.repositories_of project_id
  144 + id = repositories.select {|option| option.name == name}.first.id
  145 + elsif (type == "reading")
  146 + reading_group_id = Kalibro::ReadingGroup.all.last.id
  147 + readings = Kalibro::Reading.readings_of reading_group_id
  148 + id = readings.select {|option| option.label == name}.first.id
  149 + if (action == "edit")
  150 + action = name
  151 + end
  152 + end
  153 +
  154 + elements = all('a', :text => action.capitalize)
  155 + link = type + "_id"
  156 + action_link = elements.select {|element| (/#{link}=#{id}/ =~ element[:href]) }.first
  157 + action_link.click
  158 +end
  159 +
  160 +Then /^I should see the "([^"]*)" color$/ do |color_name|
  161 + elements = all('td', :text => "")
  162 + found = elements.select { |element| color_name == element[:bgcolor]}.first
  163 + assert_not_nil found
  164 +end
... ...
plugins/mezuro/features/support/hooks.rb 0 → 100644
... ... @@ -0,0 +1,12 @@
  1 +Before do
  2 + if !$dunit
  3 + command = "#{RAILS_ROOT}/plugins/mezuro/script/tests/prepare_kalibro_query_file.sh"
  4 + system command
  5 + $dunit = true
  6 + end
  7 +end
  8 +
  9 +After ('@kalibro_restart') do
  10 + command = "#{RAILS_ROOT}/plugins/mezuro/script/tests/delete_all_kalibro_entries.sh"
  11 + system command
  12 +end
... ...
plugins/send_email/features/send_email_plugin.feature 0 → 100644
... ... @@ -0,0 +1,41 @@
  1 +Feature: send_email_plugin
  2 +
  3 + Background:
  4 + Given the following users
  5 + | login | name |
  6 + | joaosilva | Joao Silva |
  7 + And I am logged in as "joaosilva"
  8 +
  9 + Scenario: expand macro in article content
  10 + Given plugin SendEmailPlugin is enabled on environment
  11 + And the following articles
  12 + | owner | name | body |
  13 + | joaosilva | sample-article | URL path to {sendemail} action |
  14 + When I go to /joaosilva/sample-article
  15 + Then I should see "URL path to /profile/joaosilva/plugins/send_email/deliver action"
  16 +
  17 + Scenario: expand macro in block content
  18 + Given plugin SendEmailPlugin is enabled on environment
  19 + And the following blocks
  20 + | owner | type | html |
  21 + | joaosilva | RawHTMLBlock | URL path to {sendemail} action |
  22 + When I go to Joao Silva's homepage
  23 + Then I should see "URL path to /profile/joaosilva/plugins/send_email/deliver action"
  24 +
  25 + Scenario: as admin I can configure plugin
  26 + Given I am logged in as admin
  27 + When I go to the environment control panel
  28 + And I follow "Enable/disable plugins"
  29 + Then I should see "SendEmailPlugin" linking to "/admin/plugin/send_email"
  30 +
  31 + Scenario: configure plugin to allow emails to john@example.com
  32 + Given I am logged in as admin
  33 + And I go to the environment control panel
  34 + And I follow "Enable/disable plugins"
  35 + When I follow "SendEmailPlugin"
  36 + Then I should not see "john@example.com"
  37 + When I fill in "E-Mail addresses you want to allow to send" with "john@example.com"
  38 + And I press "Save"
  39 + Then I should be on /admin/plugins
  40 + When I follow "SendEmailPlugin"
  41 + Then I should see "john@example.com"
... ...
plugins/send_email/test/features/send_email_plugin.feature
... ... @@ -1,41 +0,0 @@
1   -Feature: send_email_plugin
2   -
3   - Background:
4   - Given the following users
5   - | login | name |
6   - | joaosilva | Joao Silva |
7   - And I am logged in as "joaosilva"
8   -
9   - Scenario: expand macro in article content
10   - Given plugin SendEmailPlugin is enabled on environment
11   - And the following articles
12   - | owner | name | body |
13   - | joaosilva | sample-article | URL path to {sendemail} action |
14   - When I go to /joaosilva/sample-article
15   - Then I should see "URL path to /profile/joaosilva/plugins/send_email/deliver action"
16   -
17   - Scenario: expand macro in block content
18   - Given plugin SendEmailPlugin is enabled on environment
19   - And the following blocks
20   - | owner | type | html |
21   - | joaosilva | RawHTMLBlock | URL path to {sendemail} action |
22   - When I go to Joao Silva's homepage
23   - Then I should see "URL path to /profile/joaosilva/plugins/send_email/deliver action"
24   -
25   - Scenario: as admin I can configure plugin
26   - Given I am logged in as admin
27   - When I go to the environment control panel
28   - And I follow "Enable/disable plugins"
29   - Then I should see "SendEmailPlugin" linking to "/admin/plugin/send_email"
30   -
31   - Scenario: configure plugin to allow emails to john@example.com
32   - Given I am logged in as admin
33   - And I go to the environment control panel
34   - And I follow "Enable/disable plugins"
35   - When I follow "SendEmailPlugin"
36   - Then I should not see "john@example.com"
37   - When I fill in "E-Mail addresses you want to allow to send" with "john@example.com"
38   - And I press "Save"
39   - Then I should be on /admin/plugins
40   - When I follow "SendEmailPlugin"
41   - Then I should see "john@example.com"
script/noosfero-plugins
... ... @@ -88,7 +88,9 @@ _enable(){
88 88 if [ "$dependencies_ok" = true ]; then
89 89 ln -s "$source" "$target"
90 90 plugins_public_dir="$NOOSFERO_DIR/public/plugins"
  91 + plugins_features_dir="$NOOSFERO_DIR/features/plugins"
91 92 test -d "$target/public/" && ln -s "$target/public" "$plugins_public_dir/$plugin"
  93 + test -d "$target/features" && ln -s "$target/features" "$plugins_features_dir/$plugin"
92 94 _say "$plugin enabled"
93 95 needs_migrate=true
94 96 else
... ... @@ -101,9 +103,11 @@ _disable(){
101 103 plugin="$1"
102 104 target="$enabled_plugins_dir/$plugin"
103 105 plugins_public_dir="$NOOSFERO_DIR/public/plugins"
  106 + plugins_features_dir="$NOOSFERO_DIR/features/plugins"
104 107 if [ -h "$target" ]; then
105 108 rm "$target"
106 109 test -h "$plugins_public_dir/$plugin" && rm "$plugins_public_dir/$plugin"
  110 + test -h "$plugins_features_dir/$plugin" && rm "$plugins_features_dir/$plugin"
107 111 _say "$plugin disabled"
108 112 else
109 113 _say "$plugin already disabled"
... ...