diff --git a/features/repository/notify_push.feature b/features/repository/notify_push.feature new file mode 100644 index 0000000..2d979d7 --- /dev/null +++ b/features/repository/notify_push.feature @@ -0,0 +1,31 @@ +Feature: Notify push to repository + In order to automatically process a repository + As a regular user + I want to use a webhook in my repository to notify Mezuro of new pushes + + @kalibro_configuration_restart @kalibro_processor_restart + Scenario: Valid repository + Given I am a regular user + And I have a sample configuration with native metrics + And I have a sample repository + And I start to process that repository + And I wait up for a ready processing + When I push some commits to the repository + Then Mezuro should process the repository again + + @kalibro_configuration_restart @kalibro_processor_restart + Scenario: Invalid repository + Given I am a regular user + When I push some commits to an invalid repository + Then I should get a not found error + + @kalibro_configuration_restart @kalibro_processor_restart + Scenario: Repository with an errored processing + Given I am a regular user + And I have a sample configuration with native metrics + And I have a compound metric configuration with script "rtrnaqdfwqefwqr213r2145211234ed a = b=2" within the given mezuro configuration + And I have a sample repository + And I start to process that repository + And I wait up for an error processing + When I push some commits to the repository + Then Mezuro should process the repository again diff --git a/features/repository/show/hotspot_metric_results.feature b/features/repository/show/hotspot_metric_results.feature index 702a425..e343c4a 100644 --- a/features/repository/show/hotspot_metric_results.feature +++ b/features/repository/show/hotspot_metric_results.feature @@ -37,7 +37,7 @@ Feature: Repository hotspot metric results And I have a sample configuration with native metrics And I have a sample of an invalid repository within the sample project And I start to process that repository - And I wait up for a error processing + And I wait up for an error processing When I visit the repository show page And I click the "Hotspot Metric Results" h3 Then I should see "Repository process returned with error. There are no hotspot metric results." diff --git a/features/repository/show/metric_results.feature b/features/repository/show/metric_results.feature index 1eb0af8..9ed1457 100644 --- a/features/repository/show/metric_results.feature +++ b/features/repository/show/metric_results.feature @@ -46,7 +46,7 @@ Feature: Repository metric results And I have a sample configuration with native metrics And I have a sample of an invalid repository within the sample project And I start to process that repository - And I wait up for a error processing + And I wait up for an error processing When I visit the repository show page And I click the "Tree Metric Results" h3 Then I should see "Repository process returned with error. There are no tree metric results." diff --git a/features/step_definitions/compound_metric_configuration_steps.rb b/features/step_definitions/compound_metric_configuration_steps.rb index a37181c..326dc83 100644 --- a/features/step_definitions/compound_metric_configuration_steps.rb +++ b/features/step_definitions/compound_metric_configuration_steps.rb @@ -14,6 +14,10 @@ Given(/^I have another compound metric configuration with code "(.*?)" within th @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}) end +Given(/^I have a compound metric configuration with script "(.+)" within the given mezuro configuration$/) do |script| + @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) +end + When(/^I visit the sample compound metric configuration edit page$/) do visit edit_kalibro_configuration_compound_metric_configuration_path(kalibro_configuration_id: @compound_metric_configuration.kalibro_configuration_id, id: @compound_metric_configuration.id) end diff --git a/features/step_definitions/repository_steps.rb b/features/step_definitions/repository_steps.rb index 84db13e..4a3d3e1 100644 --- a/features/step_definitions/repository_steps.rb +++ b/features/step_definitions/repository_steps.rb @@ -9,15 +9,15 @@ Given(/^I have a sample configuration with native metrics but without ranges$/) end Given(/^I have a sample configuration with native metrics$/) do - reading_group = FactoryGirl.create(:reading_group) - reading = FactoryGirl.create(:reading, {reading_group_id: reading_group.id}) + @reading_group = FactoryGirl.create(:reading_group) + reading = FactoryGirl.create(:reading, {reading_group_id: @reading_group.id}) @kalibro_configuration = FactoryGirl.create(:kalibro_configuration) FactoryGirl.create(:kalibro_configuration_attributes, {id: nil, user_id: @user.id, kalibro_configuration_id: @kalibro_configuration.id}) metric_configuration = FactoryGirl.create(:metric_configuration, {metric: FactoryGirl.build(:loc), - reading_group_id: reading_group.id, + reading_group_id: @reading_group.id, kalibro_configuration_id: @kalibro_configuration.id}) range = FactoryGirl.build(:kalibro_range, {reading_id: reading.id, beginning: '-INF', :end => 'INF', metric_configuration_id: metric_configuration.id}) range.save @@ -69,7 +69,7 @@ Given(/^I wait up for the last processing to get ready$/) do end end -Given(/^I wait up for a error processing$/) do +Given(/^I wait up for an error processing$/) do while @repository.last_processing_state != "ERROR" sleep(10) end @@ -150,6 +150,14 @@ When(/^I get the Creation Date information as "(.*?)"$/) do |variable| eval ("@#{variable} = DateTime.parse('#{val}')") end +When(/^I push some commits to the repository$/) do + post repository_notify_push_path(id: @repository.id) +end + +When(/^I push some commits to an invalid repository$/) do + @response = post repository_notify_push_path(id: 0) +end + Then(/^I should see the sample metric's name$/) do expect(page).to have_content(@metric_results.first.metric_configuration.metric.name) end @@ -245,3 +253,11 @@ Then(/^I should see the hotspot metric results file names$/) do expect(page).to have_content(metric_result.module_result.kalibro_module.short_name) end end + +Then(/^Mezuro should process the repository again$/) do + expect(@repository.last_processing).not_to eq(@repository.first_processing) +end + +Then(/^I should get a not found error$/) do + expect(@response.status).to eq(404) +end -- libgit2 0.21.2