Commit a7da770c3ee722c3f2d8e87d209647a8e5388652

Authored by Heitor
Committed by Diego Camarinha
1 parent e7d644b7

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>
features/repository/notify_push.feature 0 → 100644
... ... @@ -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 37 And I have a sample configuration with native metrics
38 38 And I have a sample of an invalid repository within the sample project
39 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 41 When I visit the repository show page
42 42 And I click the "Hotspot Metric Results" h3
43 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 46 And I have a sample configuration with native metrics
47 47 And I have a sample of an invalid repository within the sample project
48 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 50 When I visit the repository show page
51 51 And I click the "Tree Metric Results" h3
52 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 &quot;(.*?)&quot; within th
14 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 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 21 When(/^I visit the sample compound metric configuration edit page$/) do
18 22 visit edit_kalibro_configuration_compound_metric_configuration_path(kalibro_configuration_id: @compound_metric_configuration.kalibro_configuration_id, id: @compound_metric_configuration.id)
19 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 9 end
10 10  
11 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 15 @kalibro_configuration = FactoryGirl.create(:kalibro_configuration)
16 16 FactoryGirl.create(:kalibro_configuration_attributes, {id: nil, user_id: @user.id, kalibro_configuration_id: @kalibro_configuration.id})
17 17  
18 18 metric_configuration = FactoryGirl.create(:metric_configuration,
19 19 {metric: FactoryGirl.build(:loc),
20   - reading_group_id: reading_group.id,
  20 + reading_group_id: @reading_group.id,
21 21 kalibro_configuration_id: @kalibro_configuration.id})
22 22 range = FactoryGirl.build(:kalibro_range, {reading_id: reading.id, beginning: '-INF', :end => 'INF', metric_configuration_id: metric_configuration.id})
23 23 range.save
... ... @@ -69,7 +69,7 @@ Given(/^I wait up for the last processing to get ready$/) do
69 69 end
70 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 73 while @repository.last_processing_state != "ERROR"
74 74 sleep(10)
75 75 end
... ... @@ -150,6 +150,14 @@ When(/^I get the Creation Date information as &quot;(.*?)&quot;$/) do |variable|
150 150 eval ("@#{variable} = DateTime.parse('#{val}')")
151 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 161 Then(/^I should see the sample metric's name$/) do
154 162 expect(page).to have_content(@metric_results.first.metric_configuration.metric.name)
155 163 end
... ... @@ -245,3 +253,11 @@ Then(/^I should see the hotspot metric results file names$/) do
245 253 expect(page).to have_content(metric_result.module_result.kalibro_module.short_name)
246 254 end
247 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
... ...