Commit cead3ff7b3ffc6e66d73afb4d5cb5c568057eb5d
1 parent
e2299a22
Exists in
colab
and in
4 other branches
Unit test for updating a kalibro range with a compound metric configuration
Showing
1 changed file
with
20 additions
and
4 deletions
Show diff stats
spec/controllers/kalibro_ranges_controller_spec.rb
@@ -126,17 +126,17 @@ describe KalibroRangesController, :type => :controller do | @@ -126,17 +126,17 @@ describe KalibroRangesController, :type => :controller do | ||
126 | 126 | ||
127 | context "when the user doesn't own the metric configuration" do | 127 | context "when the user doesn't own the metric configuration" do |
128 | before :each do | 128 | before :each do |
129 | - delete :destroy, id: kalibro_range.id.to_s, metric_configuration_id: metric_configuration.id.to_s, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s | 129 | + delete :destroy, id: kalibro_range.id, metric_configuration_id: metric_configuration.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id |
130 | end | 130 | end |
131 | 131 | ||
132 | - it { is_expected.to redirect_to(kalibro_configurations_path(metric_configuration.kalibro_configuration_id)) } | ||
133 | - it { is_expected.to respond_with(:redirect) } | 132 | + it { is_expected.to redirect_to(kalibro_configurations_path(metric_configuration.kalibro_configuration_id)) } |
133 | + it { is_expected.to respond_with(:redirect) } | ||
134 | end | 134 | end |
135 | end | 135 | end |
136 | 136 | ||
137 | context 'with no User logged in' do | 137 | context 'with no User logged in' do |
138 | before :each do | 138 | before :each do |
139 | - delete :destroy, id: kalibro_range.id.to_s, metric_configuration_id: metric_configuration.id.to_s, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s | 139 | + delete :destroy, id: kalibro_range.id, metric_configuration_id: metric_configuration.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id |
140 | end | 140 | end |
141 | 141 | ||
142 | it { is_expected.to redirect_to new_user_session_path } | 142 | it { is_expected.to redirect_to new_user_session_path } |
@@ -216,6 +216,22 @@ describe KalibroRangesController, :type => :controller do | @@ -216,6 +216,22 @@ describe KalibroRangesController, :type => :controller do | ||
216 | it { is_expected.to respond_with(:redirect) } | 216 | it { is_expected.to respond_with(:redirect) } |
217 | end | 217 | end |
218 | 218 | ||
219 | + context 'with valid fields and a compound metric configuration' do | ||
220 | + let(:compound_metric_configuration) { FactoryGirl.build(:compound_metric_configuration_with_id) } | ||
221 | + let(:new_kalibro_range) { FactoryGirl.build(:kalibro_range_with_id, metric_configuration_id: compound_metric_configuration.id) } | ||
222 | + | ||
223 | + before :each do | ||
224 | + subject.expects(:find_resource).with(KalibroRange, new_kalibro_range.id).returns(new_kalibro_range) | ||
225 | + KalibroRange.any_instance.expects(:update).with(new_kalibro_range.to_hash).returns(true) | ||
226 | + MetricConfiguration.expects(:find).with(new_kalibro_range.metric_configuration_id).returns(compound_metric_configuration) | ||
227 | + | ||
228 | + post :update, kalibro_configuration_id: compound_metric_configuration.kalibro_configuration_id, id: new_kalibro_range.id, metric_configuration_id: compound_metric_configuration.id, kalibro_range: new_kalibro_range.to_hash | ||
229 | + end | ||
230 | + | ||
231 | + it { is_expected.to redirect_to(kalibro_configuration_compound_metric_configuration_path(compound_metric_configuration.kalibro_configuration_id, compound_metric_configuration.id)) } | ||
232 | + it { is_expected.to respond_with(:redirect) } | ||
233 | + end | ||
234 | + | ||
219 | context 'with an invalid field' do | 235 | context 'with an invalid field' do |
220 | before :each do | 236 | before :each do |
221 | subject.expects(:find_resource).with(KalibroRange, kalibro_range.id).returns(kalibro_range) | 237 | subject.expects(:find_resource).with(KalibroRange, kalibro_range.id).returns(kalibro_range) |