Commit b36660ac3203cbe4dff84fe98a8b7aa47e346d0a
Committed by
Paulo Meireles
1 parent
92330f68
Exists in
master
and in
23 other branches
[Mezuro] Tests for range controller.
Showing
5 changed files
with
16 additions
and
20 deletions
Show diff stats
plugins/mezuro/controllers/myprofile/mezuro_plugin_range_controller.rb
| @@ -14,7 +14,6 @@ class MezuroPluginRangeController < MezuroPluginMyprofileController | @@ -14,7 +14,6 @@ class MezuroPluginRangeController < MezuroPluginMyprofileController | ||
| 14 | ranges = Kalibro::Range.ranges_of params[:metric_configuration_id].to_i | 14 | ranges = Kalibro::Range.ranges_of params[:metric_configuration_id].to_i |
| 15 | @range = (ranges.select { |range| range.id == params[:range_id].to_i }).first | 15 | @range = (ranges.select { |range| range.id == params[:range_id].to_i }).first |
| 16 | @reading_labels_and_ids = reading_labels_and_ids | 16 | @reading_labels_and_ids = reading_labels_and_ids |
| 17 | - @selected_reading_label = @range.label | ||
| 18 | end | 17 | end |
| 19 | 18 | ||
| 20 | def create | 19 | def create |
plugins/mezuro/lib/kalibro/range.rb
plugins/mezuro/test/functional/myprofile/mezuro_plugin_range_controller_test.rb
| @@ -57,7 +57,7 @@ class MezuroPluginRangeControllerTest < ActionController::TestCase | @@ -57,7 +57,7 @@ class MezuroPluginRangeControllerTest < ActionController::TestCase | ||
| 57 | :metric_configuration_id => @metric_configuration.id, | 57 | :metric_configuration_id => @metric_configuration.id, |
| 58 | :range => @created_range.to_hash}).returns(:range_id => @range.id) | 58 | :range => @created_range.to_hash}).returns(:range_id => @range.id) |
| 59 | Kalibro::Reading.expects(:find).with(@created_range.reading_id).returns(@reading) | 59 | Kalibro::Reading.expects(:find).with(@created_range.reading_id).returns(@reading) |
| 60 | - get :create, :range => @created_range_hash, :metric_configuration_id => @metric_configuration.id | 60 | + get :create, :profile => @profile.identifier, :range => @created_range_hash, :metric_configuration_id => @metric_configuration.id |
| 61 | assert_equal @range.id, assigns(:range).id | 61 | assert_equal @range.id, assigns(:range).id |
| 62 | assert_response 200 | 62 | assert_response 200 |
| 63 | end | 63 | end |
| @@ -66,8 +66,7 @@ class MezuroPluginRangeControllerTest < ActionController::TestCase | @@ -66,8 +66,7 @@ class MezuroPluginRangeControllerTest < ActionController::TestCase | ||
| 66 | Kalibro::Range.expects(:request).with(:save_range, { | 66 | Kalibro::Range.expects(:request).with(:save_range, { |
| 67 | :metric_configuration_id => @metric_configuration.id, | 67 | :metric_configuration_id => @metric_configuration.id, |
| 68 | :range => @range.to_hash}).returns(:range_id => @range.id) | 68 | :range => @range.to_hash}).returns(:range_id => @range.id) |
| 69 | - Kalibro::Reading.expects(:find).with(@range.reading_id).returns(@reading) | ||
| 70 | - get :update, :range => @range_hash, :metric_configuration_id => @metric_configuration.id | 69 | + get :update, :profile => @profile.identifier, :range => @range_hash, :metric_configuration_id => @metric_configuration.id |
| 71 | assert_equal @range.id, assigns(:range).id | 70 | assert_equal @range.id, assigns(:range).id |
| 72 | assert_response 200 | 71 | assert_response 200 |
| 73 | end | 72 | end |
| @@ -75,7 +74,7 @@ class MezuroPluginRangeControllerTest < ActionController::TestCase | @@ -75,7 +74,7 @@ class MezuroPluginRangeControllerTest < ActionController::TestCase | ||
| 75 | should 'test remove range in native metric configuration' do | 74 | should 'test remove range in native metric configuration' do |
| 76 | Kalibro::Range.expects(:new).with({:id => @range.id}).returns(@range) | 75 | Kalibro::Range.expects(:new).with({:id => @range.id}).returns(@range) |
| 77 | @range.expects(:destroy).with().returns() | 76 | @range.expects(:destroy).with().returns() |
| 78 | - get :remove, :id => @content.id, :metric_configuration_id => @metric_configuration.id, :range_id => @range.id, :compound => false | 77 | + get :remove, :profile => @profile.identifier, :id => @content.id, :metric_configuration_id => @metric_configuration.id, :range_id => @range.id, :compound => false |
| 79 | assert_response 302 | 78 | assert_response 302 |
| 80 | end | 79 | end |
| 81 | end | 80 | end |
plugins/mezuro/views/mezuro_plugin_metric_configuration/edit_compound.html.erb
| @@ -50,20 +50,14 @@ | @@ -50,20 +50,14 @@ | ||
| 50 | Color | 50 | Color |
| 51 | </td> | 51 | </td> |
| 52 | </tr> | 52 | </tr> |
| 53 | - <% | ||
| 54 | - #if (@metric_configuration.ranges!=nil) | ||
| 55 | - # @metric_configuration.ranges.each do |range| | ||
| 56 | - %> | ||
| 57 | - <%= #render :partial => "mezuro_plugin_range/range", :locals => {:range => range, :id => @configuration_content.id, | ||
| 58 | - #:metric_name => @metric_configuration.metric.name} | ||
| 59 | - %> | ||
| 60 | - <% #end | ||
| 61 | - #end | ||
| 62 | - %> | 53 | + <% @ranges.each do |range| %> |
| 54 | + <%= render :partial => "mezuro_plugin_range/range", :locals => {:range => range, :id => @configuration_content.id, | ||
| 55 | + :metric_configuration_id => @metric_configuration.id, :reading_group_id => @metric_configuration.reading_group_id, :compound => @metric_configuration.metric.compound} %> | ||
| 56 | + <% end %> | ||
| 63 | </table> | 57 | </table> |
| 64 | 58 | ||
| 65 | <br/> | 59 | <br/> |
| 66 | -<%= link_to_remote "New Range", :url => {:action =>"new_range", :controller => "mezuro_plugin_range", :id => @configuration_content.id, :metric_name => @metric.name} %> | ||
| 67 | -<div id="range_form" style="display:none"></div> | ||
| 68 | -<br/> | ||
| 69 | -<%= render :partial => "metric_codes", :locals => {:metric_configurations => @metric_configurations} %> | 60 | +<% if owner %> |
| 61 | + <%= link_to_remote "New Range", :url => {:action =>"new", :controller => "mezuro_plugin_range", :id => @configuration_content.id, :metric_configuration_id => @metric_configuration.id, :reading_group_id => @metric_configuration.reading_group_id} %> | ||
| 62 | +<% end %> | ||
| 63 | +<div id="form" style="display:none"></div> |
plugins/mezuro/views/mezuro_plugin_range/_form.html.erb
| @@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
| 4 | <%= f.hidden_field :id %> | 4 | <%= f.hidden_field :id %> |
| 5 | 5 | ||
| 6 | <%= required labelled_form_field _('Label'), | 6 | <%= required labelled_form_field _('Label'), |
| 7 | - f.select(:reading_id, @reading_labels_and_ids, :selected => @selected_reading_label) %><br/> | 7 | + f.select(:reading_id, @reading_labels_and_ids) %><br/> |
| 8 | <table> | 8 | <table> |
| 9 | <tr> | 9 | <tr> |
| 10 | <td> | 10 | <td> |