diff --git a/app/controllers/compound_metric_configurations_controller.rb b/app/controllers/compound_metric_configurations_controller.rb index 7fc6ea7..128d51d 100644 --- a/app/controllers/compound_metric_configurations_controller.rb +++ b/app/controllers/compound_metric_configurations_controller.rb @@ -26,6 +26,7 @@ class CompoundMetricConfigurationsController < ApplicationController def show @compound_metric_configuration = @metric_configuration @reading_group = ReadingGroup.find(@compound_metric_configuration.reading_group_id) + @mezuro_ranges = @compound_metric_configuration.mezuro_ranges @compound_metric_configuration.configuration_id = params[:mezuro_configuration_id].to_i end diff --git a/app/views/compound_metric_configurations/show.html.erb b/app/views/compound_metric_configurations/show.html.erb index a4e676f..d9fc00c 100644 --- a/app/views/compound_metric_configurations/show.html.erb +++ b/app/views/compound_metric_configurations/show.html.erb @@ -58,7 +58,11 @@
- + <% if @mezuro_ranges.empty? %> + <%= render partial: 'no_ranges' %> + <% else %> + <%= render partial: 'metric_configurations/ranges', collection: @mezuro_ranges, as: :mezuro_range %> + <% end %> diff --git a/app/views/metric_configurations/show.html.erb b/app/views/metric_configurations/show.html.erb index 1297feb..870166e 100644 --- a/app/views/metric_configurations/show.html.erb +++ b/app/views/metric_configurations/show.html.erb @@ -63,7 +63,7 @@ - <% if @mezuro_ranges.size == 0 %> + <% if @mezuro_ranges.empty? %> <%= render partial: 'no_ranges' %> <% else %> <%= render partial: 'ranges', collection: @mezuro_ranges, as: :mezuro_range %> diff --git a/features/compound_metric_configuration/show.feature b/features/compound_metric_configuration/show.feature index 12e9b70..ce74ed9 100644 --- a/features/compound_metric_configuration/show.feature +++ b/features/compound_metric_configuration/show.feature @@ -7,7 +7,10 @@ Feature: Show Compound Metric Configuration Scenario: Checking metric configuration show link Given I have a sample configuration And I have a sample reading group + And I have a sample reading within the sample reading group labeled "My Reading" And I have a sample compound metric configuration within the given mezuro configuration + And I have a sample range within the sample compound metric configuration When I am at the Sample Configuration page And I click the Show link Then I should be at compound metric configuration sample page + And I should see the sample range diff --git a/features/metric_configuration/show.feature b/features/metric_configuration/show.feature index 3a37966..6ec79e3 100644 --- a/features/metric_configuration/show.feature +++ b/features/metric_configuration/show.feature @@ -3,11 +3,14 @@ Feature: Show Metric Configuration As a regular user I should be able to see each of them -@kalibro_restart -Scenario: Checking metric configuration show link - Given I have a sample configuration - And I have a sample reading group - And I have a sample metric configuration within the given mezuro configuration - When I am at the Sample Configuration page - And I click the Show link - Then I should be at metric configuration sample page \ No newline at end of file + @kalibro_restart + Scenario: Checking metric configuration show link + Given I have a sample configuration + And I have a sample reading group + And I have a sample reading within the sample reading group labeled "My Reading" + And I have a sample metric configuration within the given mezuro configuration + And I have a sample range within the sample metric configuration + When I am at the Sample Configuration page + And I click the Show link + Then I should be at metric configuration sample page + And I should see the sample range diff --git a/features/step_definitions/mezuro_range_steps.rb b/features/step_definitions/mezuro_range_steps.rb index 7e0105d..c222f74 100644 --- a/features/step_definitions/mezuro_range_steps.rb +++ b/features/step_definitions/mezuro_range_steps.rb @@ -16,6 +16,11 @@ Given(/^I have a sample range within the sample metric configuration$/) do reading_id: @reading.id, id: nil}) end +Given(/^I have a sample range within the sample compound metric configuration$/) do + @mezuro_range = FactoryGirl.create(:mezuro_range, {metric_configuration_id: @compound_metric_configuration.id, + reading_id: @reading.id, id: nil}) +end + Then(/^I should be at the New Range page$/) do page.should have_content("New Range") page.should have_content("Beginning") @@ -27,3 +32,9 @@ When(/^I am at the New Range page$/) do visit mezuro_configuration_metric_configuration_new_mezuro_range_path(@metric_configuration.configuration_id, @metric_configuration.id) end +Then(/^I should see the sample range$/) do + page.should have_content(@mezuro_range.label) + page.should have_content(@mezuro_range.beginning) + page.should have_content(@mezuro_range.end) +end + diff --git a/spec/controllers/compound_metric_configurations_controller_spec.rb b/spec/controllers/compound_metric_configurations_controller_spec.rb index 855e146..c19e07c 100644 --- a/spec/controllers/compound_metric_configurations_controller_spec.rb +++ b/spec/controllers/compound_metric_configurations_controller_spec.rb @@ -70,10 +70,12 @@ describe CompoundMetricConfigurationsController do describe 'show' do let(:compound_metric_configuration) { FactoryGirl.build(:compound_metric_configuration) } let(:reading_group) { FactoryGirl.build(:reading_group) } + let(:mezuro_range) { FactoryGirl.build(:mezuro_range) } before :each do ReadingGroup.expects(:find).with(compound_metric_configuration.reading_group_id).returns(reading_group) MetricConfiguration.expects(:find).with(compound_metric_configuration.id).returns(compound_metric_configuration) + MezuroRange.expects(:ranges_of).with(compound_metric_configuration.id).returns([mezuro_range]) get :show, mezuro_configuration_id: compound_metric_configuration.configuration_id.to_s, id: compound_metric_configuration.id end -- libgit2 0.21.2