Commit a7da770c3ee722c3f2d8e87d209647a8e5388652
Committed by
Diego Camarinha
1 parent
e7d644b7
Exists in
colab
and in
4 other branches
Add acceptance tests for the notify_push feature
* Also fixed a typo on a repository step that waits for an errored processing Signed off by: Diego Araújo <diegoamc90@gmail.com> Signed off by: Eduardo Araújo <duduktamg@hotmail.com>
Showing
5 changed files
with
57 additions
and
6 deletions
Show diff stats
@@ -0,0 +1,31 @@ | @@ -0,0 +1,31 @@ | ||
1 | +Feature: Notify push to repository | ||
2 | + In order to automatically process a repository | ||
3 | + As a regular user | ||
4 | + I want to use a webhook in my repository to notify Mezuro of new pushes | ||
5 | + | ||
6 | + @kalibro_configuration_restart @kalibro_processor_restart | ||
7 | + Scenario: Valid repository | ||
8 | + Given I am a regular user | ||
9 | + And I have a sample configuration with native metrics | ||
10 | + And I have a sample repository | ||
11 | + And I start to process that repository | ||
12 | + And I wait up for a ready processing | ||
13 | + When I push some commits to the repository | ||
14 | + Then Mezuro should process the repository again | ||
15 | + | ||
16 | + @kalibro_configuration_restart @kalibro_processor_restart | ||
17 | + Scenario: Invalid repository | ||
18 | + Given I am a regular user | ||
19 | + When I push some commits to an invalid repository | ||
20 | + Then I should get a not found error | ||
21 | + | ||
22 | + @kalibro_configuration_restart @kalibro_processor_restart | ||
23 | + Scenario: Repository with an errored processing | ||
24 | + Given I am a regular user | ||
25 | + And I have a sample configuration with native metrics | ||
26 | + And I have a compound metric configuration with script "rtrnaqdfwqefwqr213r2145211234ed a = b=2" within the given mezuro configuration | ||
27 | + And I have a sample repository | ||
28 | + And I start to process that repository | ||
29 | + And I wait up for an error processing | ||
30 | + When I push some commits to the repository | ||
31 | + Then Mezuro should process the repository again |
features/repository/show/hotspot_metric_results.feature
@@ -37,7 +37,7 @@ Feature: Repository hotspot metric results | @@ -37,7 +37,7 @@ Feature: Repository hotspot metric results | ||
37 | And I have a sample configuration with native metrics | 37 | And I have a sample configuration with native metrics |
38 | And I have a sample of an invalid repository within the sample project | 38 | And I have a sample of an invalid repository within the sample project |
39 | And I start to process that repository | 39 | And I start to process that repository |
40 | - And I wait up for a error processing | 40 | + And I wait up for an error processing |
41 | When I visit the repository show page | 41 | When I visit the repository show page |
42 | And I click the "Hotspot Metric Results" h3 | 42 | And I click the "Hotspot Metric Results" h3 |
43 | Then I should see "Repository process returned with error. There are no hotspot metric results." | 43 | Then I should see "Repository process returned with error. There are no hotspot metric results." |
features/repository/show/metric_results.feature
@@ -46,7 +46,7 @@ Feature: Repository metric results | @@ -46,7 +46,7 @@ Feature: Repository metric results | ||
46 | And I have a sample configuration with native metrics | 46 | And I have a sample configuration with native metrics |
47 | And I have a sample of an invalid repository within the sample project | 47 | And I have a sample of an invalid repository within the sample project |
48 | And I start to process that repository | 48 | And I start to process that repository |
49 | - And I wait up for a error processing | 49 | + And I wait up for an error processing |
50 | When I visit the repository show page | 50 | When I visit the repository show page |
51 | And I click the "Tree Metric Results" h3 | 51 | And I click the "Tree Metric Results" h3 |
52 | Then I should see "Repository process returned with error. There are no tree metric results." | 52 | Then I should see "Repository process returned with error. There are no tree metric results." |
features/step_definitions/compound_metric_configuration_steps.rb
@@ -14,6 +14,10 @@ Given(/^I have another compound metric configuration with code "(.*?)" within th | @@ -14,6 +14,10 @@ Given(/^I have another compound metric configuration with code "(.*?)" within th | ||
14 | @another_compound_metric_configuration = FactoryGirl.create(:compound_metric_configuration, {kalibro_configuration_id: @kalibro_configuration.id, metric: FactoryGirl.build(:compound_metric, code: code), reading_group_id: @reading_group.id}) | 14 | @another_compound_metric_configuration = FactoryGirl.create(:compound_metric_configuration, {kalibro_configuration_id: @kalibro_configuration.id, metric: FactoryGirl.build(:compound_metric, code: code), reading_group_id: @reading_group.id}) |
15 | end | 15 | end |
16 | 16 | ||
17 | +Given(/^I have a compound metric configuration with script "(.+)" within the given mezuro configuration$/) do |script| | ||
18 | + @another_compound_metric_configuration = FactoryGirl.create(:compound_metric_configuration, kalibro_configuration_id: @kalibro_configuration.id, metric: FactoryGirl.build(:compound_metric, script: script), reading_group_id: @reading_group.id) | ||
19 | +end | ||
20 | + | ||
17 | When(/^I visit the sample compound metric configuration edit page$/) do | 21 | When(/^I visit the sample compound metric configuration edit page$/) do |
18 | visit edit_kalibro_configuration_compound_metric_configuration_path(kalibro_configuration_id: @compound_metric_configuration.kalibro_configuration_id, id: @compound_metric_configuration.id) | 22 | visit edit_kalibro_configuration_compound_metric_configuration_path(kalibro_configuration_id: @compound_metric_configuration.kalibro_configuration_id, id: @compound_metric_configuration.id) |
19 | end | 23 | end |
features/step_definitions/repository_steps.rb
@@ -9,15 +9,15 @@ Given(/^I have a sample configuration with native metrics but without ranges$/) | @@ -9,15 +9,15 @@ Given(/^I have a sample configuration with native metrics but without ranges$/) | ||
9 | end | 9 | end |
10 | 10 | ||
11 | Given(/^I have a sample configuration with native metrics$/) do | 11 | Given(/^I have a sample configuration with native metrics$/) do |
12 | - reading_group = FactoryGirl.create(:reading_group) | ||
13 | - reading = FactoryGirl.create(:reading, {reading_group_id: reading_group.id}) | 12 | + @reading_group = FactoryGirl.create(:reading_group) |
13 | + reading = FactoryGirl.create(:reading, {reading_group_id: @reading_group.id}) | ||
14 | 14 | ||
15 | @kalibro_configuration = FactoryGirl.create(:kalibro_configuration) | 15 | @kalibro_configuration = FactoryGirl.create(:kalibro_configuration) |
16 | FactoryGirl.create(:kalibro_configuration_attributes, {id: nil, user_id: @user.id, kalibro_configuration_id: @kalibro_configuration.id}) | 16 | FactoryGirl.create(:kalibro_configuration_attributes, {id: nil, user_id: @user.id, kalibro_configuration_id: @kalibro_configuration.id}) |
17 | 17 | ||
18 | metric_configuration = FactoryGirl.create(:metric_configuration, | 18 | metric_configuration = FactoryGirl.create(:metric_configuration, |
19 | {metric: FactoryGirl.build(:loc), | 19 | {metric: FactoryGirl.build(:loc), |
20 | - reading_group_id: reading_group.id, | 20 | + reading_group_id: @reading_group.id, |
21 | kalibro_configuration_id: @kalibro_configuration.id}) | 21 | kalibro_configuration_id: @kalibro_configuration.id}) |
22 | range = FactoryGirl.build(:kalibro_range, {reading_id: reading.id, beginning: '-INF', :end => 'INF', metric_configuration_id: metric_configuration.id}) | 22 | range = FactoryGirl.build(:kalibro_range, {reading_id: reading.id, beginning: '-INF', :end => 'INF', metric_configuration_id: metric_configuration.id}) |
23 | range.save | 23 | range.save |
@@ -69,7 +69,7 @@ Given(/^I wait up for the last processing to get ready$/) do | @@ -69,7 +69,7 @@ Given(/^I wait up for the last processing to get ready$/) do | ||
69 | end | 69 | end |
70 | end | 70 | end |
71 | 71 | ||
72 | -Given(/^I wait up for a error processing$/) do | 72 | +Given(/^I wait up for an error processing$/) do |
73 | while @repository.last_processing_state != "ERROR" | 73 | while @repository.last_processing_state != "ERROR" |
74 | sleep(10) | 74 | sleep(10) |
75 | end | 75 | end |
@@ -150,6 +150,14 @@ When(/^I get the Creation Date information as "(.*?)"$/) do |variable| | @@ -150,6 +150,14 @@ When(/^I get the Creation Date information as "(.*?)"$/) do |variable| | ||
150 | eval ("@#{variable} = DateTime.parse('#{val}')") | 150 | eval ("@#{variable} = DateTime.parse('#{val}')") |
151 | end | 151 | end |
152 | 152 | ||
153 | +When(/^I push some commits to the repository$/) do | ||
154 | + post repository_notify_push_path(id: @repository.id) | ||
155 | +end | ||
156 | + | ||
157 | +When(/^I push some commits to an invalid repository$/) do | ||
158 | + @response = post repository_notify_push_path(id: 0) | ||
159 | +end | ||
160 | + | ||
153 | Then(/^I should see the sample metric's name$/) do | 161 | Then(/^I should see the sample metric's name$/) do |
154 | expect(page).to have_content(@metric_results.first.metric_configuration.metric.name) | 162 | expect(page).to have_content(@metric_results.first.metric_configuration.metric.name) |
155 | end | 163 | end |
@@ -245,3 +253,11 @@ Then(/^I should see the hotspot metric results file names$/) do | @@ -245,3 +253,11 @@ Then(/^I should see the hotspot metric results file names$/) do | ||
245 | expect(page).to have_content(metric_result.module_result.kalibro_module.short_name) | 253 | expect(page).to have_content(metric_result.module_result.kalibro_module.short_name) |
246 | end | 254 | end |
247 | end | 255 | end |
256 | + | ||
257 | +Then(/^Mezuro should process the repository again$/) do | ||
258 | + expect(@repository.last_processing).not_to eq(@repository.first_processing) | ||
259 | +end | ||
260 | + | ||
261 | +Then(/^I should get a not found error$/) do | ||
262 | + expect(@response.status).to eq(404) | ||
263 | +end |