|
112 | 112 | reference_timeline_id: timeline,
|
113 | 113 | id: time,
|
114 | 114 | reference_time: {
|
115 |
| - lesson_plan_item_id: unassigned_item.id, |
116 | 115 | start_at: new_start_time,
|
117 | 116 | bonus_end_at: new_bonus_end_time,
|
118 | 117 | end_at: new_end_time
|
|
123 | 122 | context 'when the user is a Course Manager' do
|
124 | 123 | let(:user) { create(:course_manager, course: course).user }
|
125 | 124 |
|
126 |
| - it 'changes the assigned lesson plan item and times' do |
127 |
| - expect { subject }. |
128 |
| - to change { assigned_item.reference_times.size }.by(-1). |
129 |
| - and change { unassigned_item.reference_times.size }.by(1) |
130 |
| - |
| 125 | + it 'changes the assigned times' do |
131 | 126 | is_expected.to have_http_status(:ok)
|
132 | 127 |
|
133 | 128 | updated_time = assigns(:reference_time)
|
134 |
| - expect(updated_time.lesson_plan_item.id).to eq(unassigned_item.id) |
135 | 129 | expect(updated_time.start_at).to eq(new_start_time)
|
136 | 130 | expect(updated_time.bonus_end_at).to eq(new_bonus_end_time)
|
137 | 131 | expect(updated_time.end_at).to eq(new_end_time)
|
138 | 132 | end
|
139 | 133 |
|
140 |
| - context 'when about to be reassigned to an assigned lesson plan item in the same timeline' do |
141 |
| - before { create(:course_reference_time, reference_timeline: timeline, lesson_plan_item: unassigned_item) } |
142 |
| - |
| 134 | + context 'when about to have its lesson plan item changed' do |
143 | 135 | subject do
|
144 | 136 | patch :update, as: :json, params: {
|
145 | 137 | course_id: course,
|
|
149 | 141 | }
|
150 | 142 | end
|
151 | 143 |
|
152 |
| - it 'fails and responds bad request with errors' do |
153 |
| - is_expected.to have_http_status(:bad_request) |
154 |
| - expect(JSON.parse(response.body)['errors']).not_to be_nil |
| 144 | + it 'does not change the assigned lesson plan item' do |
| 145 | + is_expected.to have_http_status(:ok) |
| 146 | + expect(time.lesson_plan_item.id).to eq(assigned_item.id) |
155 | 147 | end
|
156 | 148 | end
|
157 | 149 |
|
|
0 commit comments