Commit aaae224631f0da915d164132d74de1e91f6f7f2d
Committed by
Rafael Manzo
1 parent
9f532746
Exists in
colab
and in
4 other branches
Cover MetricConfigurationsController failed_action
There was no test case for failed_action when the action was neither create or update. The coverage was achieved through show action with invalid reading group id. Signed-off-by: Rafael Reggiani Manzo <rr.manzo@gmail.com>
Showing
1 changed file
with
21 additions
and
6 deletions
Show diff stats
spec/controllers/metric_configurations_controller_spec.rb
... | ... | @@ -105,15 +105,30 @@ describe MetricConfigurationsController, :type => :controller do |
105 | 105 | let(:kalibro_range) { FactoryGirl.build(:kalibro_range) } |
106 | 106 | |
107 | 107 | before :each do |
108 | - KalibroConfiguration.expects(:find).with(kalibro_configuration.id).returns kalibro_configuration | |
109 | - ReadingGroup.expects(:find).with(metric_configuration.reading_group_id).returns(reading_group) | |
110 | - MetricConfiguration.expects(:find).with(metric_configuration.id).returns(metric_configuration) | |
111 | - metric_configuration.expects(:kalibro_ranges).returns([kalibro_range]) | |
108 | + KalibroConfiguration.expects(:find).with(kalibro_configuration.id).returns kalibro_configuration | |
109 | + MetricConfiguration.expects(:find).with(metric_configuration.id).returns(metric_configuration) | |
110 | + end | |
111 | + | |
112 | + context 'with valid parameters' do | |
113 | + before :each do | |
114 | + ReadingGroup.expects(:find).with(metric_configuration.reading_group_id).returns(reading_group) | |
115 | + metric_configuration.expects(:kalibro_ranges).returns([kalibro_range]) | |
116 | + | |
117 | + get :show, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s, id: metric_configuration.id | |
118 | + end | |
112 | 119 | |
113 | - get :show, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s, id: metric_configuration.id | |
120 | + it { is_expected.to render_template(:show) } | |
114 | 121 | end |
115 | 122 | |
116 | - it { is_expected.to render_template(:show) } | |
123 | + context 'with invalid parameters' do | |
124 | + before :each do | |
125 | + ReadingGroup.expects(:find).with(metric_configuration.reading_group_id).raises(KalibroClient::Errors::RecordNotFound) | |
126 | + | |
127 | + get :show, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s, id: metric_configuration.id | |
128 | + end | |
129 | + | |
130 | + it { is_expected.to redirect_to(kalibro_configuration_path(kalibro_configuration.id)) } | |
131 | + end | |
117 | 132 | end |
118 | 133 | |
119 | 134 | describe 'edit' do | ... | ... |