Commit cd805c02ff32e4223374b8678e89fad793a55e50

Authored by Diego Camarinha
1 parent e8cf8f91

Improved the following acceptance tests:

1. Included verification of the list of ranges of a compound metric configuration;
2. Included verification of the list of ranges of a metric configuration.

Also fixed show action of compound metric configuration controller.

signed-off-by: Renan Fichberg <rfichberg@gmail.com>
app/controllers/compound_metric_configurations_controller.rb
... ... @@ -26,6 +26,7 @@ class CompoundMetricConfigurationsController &lt; ApplicationController
26 26 def show
27 27 @compound_metric_configuration = @metric_configuration
28 28 @reading_group = ReadingGroup.find(@compound_metric_configuration.reading_group_id)
  29 + @mezuro_ranges = @compound_metric_configuration.mezuro_ranges
29 30 @compound_metric_configuration.configuration_id = params[:mezuro_configuration_id].to_i
30 31 end
31 32  
... ...
app/views/compound_metric_configurations/show.html.erb
... ... @@ -58,7 +58,11 @@
58 58 </tr>
59 59 </thead>
60 60 <tbody>
61   -
  61 + <% if @mezuro_ranges.empty? %>
  62 + <%= render partial: 'no_ranges' %>
  63 + <% else %>
  64 + <%= render partial: 'metric_configurations/ranges', collection: @mezuro_ranges, as: :mezuro_range %>
  65 + <% end %>
62 66 </tbody>
63 67 </table>
64 68  
... ...
app/views/metric_configurations/show.html.erb
... ... @@ -63,7 +63,7 @@
63 63 </tr>
64 64 </thead>
65 65 <tbody>
66   - <% if @mezuro_ranges.size == 0 %>
  66 + <% if @mezuro_ranges.empty? %>
67 67 <%= render partial: 'no_ranges' %>
68 68 <% else %>
69 69 <%= render partial: 'ranges', collection: @mezuro_ranges, as: :mezuro_range %>
... ...
features/compound_metric_configuration/show.feature
... ... @@ -7,7 +7,10 @@ Feature: Show Compound Metric Configuration
7 7 Scenario: Checking metric configuration show link
8 8 Given I have a sample configuration
9 9 And I have a sample reading group
  10 + And I have a sample reading within the sample reading group labeled "My Reading"
10 11 And I have a sample compound metric configuration within the given mezuro configuration
  12 + And I have a sample range within the sample compound metric configuration
11 13 When I am at the Sample Configuration page
12 14 And I click the Show link
13 15 Then I should be at compound metric configuration sample page
  16 + And I should see the sample range
... ...
features/metric_configuration/show.feature
... ... @@ -3,11 +3,14 @@ Feature: Show Metric Configuration
3 3 As a regular user
4 4 I should be able to see each of them
5 5  
6   -@kalibro_restart
7   -Scenario: Checking metric configuration show link
8   - Given I have a sample configuration
9   - And I have a sample reading group
10   - And I have a sample metric configuration within the given mezuro configuration
11   - When I am at the Sample Configuration page
12   - And I click the Show link
13   - Then I should be at metric configuration sample page
14 6 \ No newline at end of file
  7 + @kalibro_restart
  8 + Scenario: Checking metric configuration show link
  9 + Given I have a sample configuration
  10 + And I have a sample reading group
  11 + And I have a sample reading within the sample reading group labeled "My Reading"
  12 + And I have a sample metric configuration within the given mezuro configuration
  13 + And I have a sample range within the sample metric configuration
  14 + When I am at the Sample Configuration page
  15 + And I click the Show link
  16 + Then I should be at metric configuration sample page
  17 + And I should see the sample range
... ...
features/step_definitions/mezuro_range_steps.rb
... ... @@ -16,6 +16,11 @@ Given(/^I have a sample range within the sample metric configuration$/) do
16 16 reading_id: @reading.id, id: nil})
17 17 end
18 18  
  19 +Given(/^I have a sample range within the sample compound metric configuration$/) do
  20 + @mezuro_range = FactoryGirl.create(:mezuro_range, {metric_configuration_id: @compound_metric_configuration.id,
  21 + reading_id: @reading.id, id: nil})
  22 +end
  23 +
19 24 Then(/^I should be at the New Range page$/) do
20 25 page.should have_content("New Range")
21 26 page.should have_content("Beginning")
... ... @@ -27,3 +32,9 @@ When(/^I am at the New Range page$/) do
27 32 visit mezuro_configuration_metric_configuration_new_mezuro_range_path(@metric_configuration.configuration_id, @metric_configuration.id)
28 33 end
29 34  
  35 +Then(/^I should see the sample range$/) do
  36 + page.should have_content(@mezuro_range.label)
  37 + page.should have_content(@mezuro_range.beginning)
  38 + page.should have_content(@mezuro_range.end)
  39 +end
  40 +
... ...
spec/controllers/compound_metric_configurations_controller_spec.rb
... ... @@ -70,10 +70,12 @@ describe CompoundMetricConfigurationsController do
70 70 describe 'show' do
71 71 let(:compound_metric_configuration) { FactoryGirl.build(:compound_metric_configuration) }
72 72 let(:reading_group) { FactoryGirl.build(:reading_group) }
  73 + let(:mezuro_range) { FactoryGirl.build(:mezuro_range) }
73 74  
74 75 before :each do
75 76 ReadingGroup.expects(:find).with(compound_metric_configuration.reading_group_id).returns(reading_group)
76 77 MetricConfiguration.expects(:find).with(compound_metric_configuration.id).returns(compound_metric_configuration)
  78 + MezuroRange.expects(:ranges_of).with(compound_metric_configuration.id).returns([mezuro_range])
77 79  
78 80 get :show, mezuro_configuration_id: compound_metric_configuration.configuration_id.to_s, id: compound_metric_configuration.id
79 81 end
... ...