|
37 | 37 | end |
38 | 38 | expect do |
39 | 39 | click_link 'Customise' |
| 40 | + # `org_admin_template_path(Template.last)` would be preferred over %r{#{org_admin_templates_path}/\d+} |
| 41 | + # However, the test is currently evaluating Template.count prior to the new Template being created |
| 42 | + expect(page).to have_current_path(%r{#{org_admin_templates_path}/\d+}) |
40 | 43 | end.to change { Template.count }.by(1) |
41 | 44 |
|
42 | 45 | # New Template created |
|
53 | 56 | # NOTE: This is question 2, since Annotation was copied upon clicking "Customise" |
54 | 57 | within("#edit_question_#{template.question_ids.last}") do |
55 | 58 | # Expect it to destroy the newly cleared Annotation |
56 | | - expect { click_button 'Save' }.not_to change { Annotation.count } |
| 59 | + expect do |
| 60 | + click_button 'Save' |
| 61 | + current_path = org_admin_template_phase_path(template, |
| 62 | + template.phases.first) + |
| 63 | + "?section=#{template.phases.first.sections.first.id}" |
| 64 | + expect(page).to have_current_path(current_path) |
| 65 | + end.not_to change { Annotation.count } |
57 | 66 | end |
58 | 67 | expect(annotation.text).to eql('Foo bar') |
59 | 68 | expect(Annotation.order('created_at').last.text).to eql('<p>Noo bar</p>') |
|
67 | 76 | end |
68 | 77 | expect do |
69 | 78 | click_link 'Customise' |
| 79 | + # `org_admin_template_path(Template.last)` would be preferred over %r{#{org_admin_templates_path}/\d+} |
| 80 | + # However, the test is currently evaluating Template.count prior to the new Template being created |
| 81 | + expect(page).to have_current_path(%r{#{org_admin_templates_path}/\d+}) |
70 | 82 | end.to change { Template.count }.by(1) |
71 | 83 | template = Template.last |
72 | 84 | click_link 'Customise phase' |
|
79 | 91 | # NOTE: This is question 2, since Annotation was copied upon clicking "Customise" |
80 | 92 | within("#edit_question_#{template.question_ids.last}") do |
81 | 93 | # Expect it to destroy the newly cleared Annotation |
82 | | - expect { click_button 'Save' }.to change { Annotation.count }.by(-1) |
| 94 | + expect do |
| 95 | + click_button 'Save' |
| 96 | + current_path = org_admin_template_phase_path(template, |
| 97 | + template.phases.first) + |
| 98 | + "?section=#{template.phases.first.sections.first.id}" |
| 99 | + expect(page).to have_current_path(current_path) |
| 100 | + end.to change { Annotation.count }.by(-1) |
83 | 101 | end |
84 | 102 | expect(page).not_to have_errors |
85 | 103 | end |
|
0 commit comments