|
11 | 11 | let(:include_none_of_the_above) { "yes" } |
12 | 12 | let(:only_one_option) { "true" } |
13 | 13 | let(:draft_question) { build :draft_question, answer_type: "selection", answer_settings: { only_one_option: } } |
14 | | - let(:describe_none_of_the_above_enabled) { true } |
15 | 14 |
|
16 | 15 | before do |
17 | 16 | # # mock the form.page_number method |
|
22 | 21 | allow(view).to receive_messages(form_pages_path: "/pages", current_form: form) |
23 | 22 | end |
24 | 23 |
|
25 | | - allow(FeatureService).to receive(:enabled?).with(:describe_none_of_the_above_enabled).and_return(describe_none_of_the_above_enabled) |
26 | | - |
27 | 24 | # # setup instance variables |
28 | 25 | assign(:page, page) |
29 | 26 | assign(:selection_options_path, selection_options_path) |
|
126 | 123 | end |
127 | 124 |
|
128 | 125 | describe "include none of the above radios" do |
129 | | - context "when the describe_none_of_the_above_enabled feature is enabled" do |
130 | | - it "contains a radio question for choosing whether to make the form live" do |
131 | | - expect(rendered).to have_css("fieldset", text: I18n.t("helpers.legend.pages_selection_bulk_options_input.include_none_of_the_above")) |
132 | | - expect(rendered).to have_field(I18n.t("helpers.label.pages_selection_bulk_options_input.include_none_of_the_above_options.yes"), type: "radio") |
133 | | - expect(rendered).to have_field(I18n.t("helpers.label.pages_selection_bulk_options_input.include_none_of_the_above_options.yes_with_question"), type: "radio") |
134 | | - expect(rendered).to have_field(I18n.t("helpers.label.pages_selection_bulk_options_input.include_none_of_the_above_options.no"), type: "radio") |
135 | | - end |
136 | | - |
137 | | - context "when input object has value of yes'" do |
138 | | - let(:include_none_of_the_above) { "yes" } |
139 | | - |
140 | | - it "has 'Yes' radio selected" do |
141 | | - expect(rendered).to have_checked_field("pages_selection_options_input[include_none_of_the_above]", with: "yes") |
142 | | - expect(rendered).to have_unchecked_field("pages_selection_options_input[include_none_of_the_above]", with: "yes_with_question") |
143 | | - expect(rendered).to have_unchecked_field("pages_selection_options_input[include_none_of_the_above]", with: "no") |
144 | | - end |
145 | | - end |
| 126 | + it "contains a radio question for choosing whether to include an option for none of the above" do |
| 127 | + expect(rendered).to have_css("fieldset", text: I18n.t("helpers.legend.pages_selection_bulk_options_input.include_none_of_the_above")) |
| 128 | + expect(rendered).to have_field(I18n.t("helpers.label.pages_selection_bulk_options_input.include_none_of_the_above_options.yes"), type: "radio") |
| 129 | + expect(rendered).to have_field(I18n.t("helpers.label.pages_selection_bulk_options_input.include_none_of_the_above_options.yes_with_question"), type: "radio") |
| 130 | + expect(rendered).to have_field(I18n.t("helpers.label.pages_selection_bulk_options_input.include_none_of_the_above_options.no"), type: "radio") |
| 131 | + end |
146 | 132 |
|
147 | | - context "when input object has value of yes_with_question" do |
148 | | - let(:include_none_of_the_above) { "yes_with_question" } |
| 133 | + context "when input object has value of yes'" do |
| 134 | + let(:include_none_of_the_above) { "yes" } |
149 | 135 |
|
150 | | - it "has 'No' radio selected" do |
151 | | - expect(rendered).to have_checked_field("pages_selection_options_input[include_none_of_the_above]", with: "yes_with_question") |
152 | | - expect(rendered).to have_unchecked_field("pages_selection_options_input[include_none_of_the_above]", with: "yes") |
153 | | - expect(rendered).to have_unchecked_field("pages_selection_options_input[include_none_of_the_above]", with: "no") |
154 | | - end |
| 136 | + it "has 'Yes' radio selected" do |
| 137 | + expect(rendered).to have_checked_field("pages_selection_options_input[include_none_of_the_above]", with: "yes") |
| 138 | + expect(rendered).to have_unchecked_field("pages_selection_options_input[include_none_of_the_above]", with: "yes_with_question") |
| 139 | + expect(rendered).to have_unchecked_field("pages_selection_options_input[include_none_of_the_above]", with: "no") |
155 | 140 | end |
| 141 | + end |
156 | 142 |
|
157 | | - context "when input object has value of no" do |
158 | | - let(:include_none_of_the_above) { "no" } |
| 143 | + context "when input object has value of yes_with_question" do |
| 144 | + let(:include_none_of_the_above) { "yes_with_question" } |
159 | 145 |
|
160 | | - it "has 'No' radio selected" do |
161 | | - expect(rendered).to have_checked_field("pages_selection_options_input[include_none_of_the_above]", with: "no") |
162 | | - expect(rendered).to have_unchecked_field("pages_selection_options_input[include_none_of_the_above]", with: "yes") |
163 | | - expect(rendered).to have_unchecked_field("pages_selection_options_input[include_none_of_the_above]", with: "yes_with_question") |
164 | | - end |
| 146 | + it "has 'No' radio selected" do |
| 147 | + expect(rendered).to have_checked_field("pages_selection_options_input[include_none_of_the_above]", with: "yes_with_question") |
| 148 | + expect(rendered).to have_unchecked_field("pages_selection_options_input[include_none_of_the_above]", with: "yes") |
| 149 | + expect(rendered).to have_unchecked_field("pages_selection_options_input[include_none_of_the_above]", with: "no") |
165 | 150 | end |
| 151 | + end |
166 | 152 |
|
167 | | - context "when input object has no value set" do |
168 | | - let(:include_none_of_the_above) { nil } |
| 153 | + context "when input object has value of no" do |
| 154 | + let(:include_none_of_the_above) { "no" } |
169 | 155 |
|
170 | | - it "does not have a radio option selected" do |
171 | | - expect(rendered).to have_unchecked_field("pages_selection_options_input[include_none_of_the_above]", with: "no") |
172 | | - expect(rendered).to have_unchecked_field("pages_selection_options_input[include_none_of_the_above]", with: "yes") |
173 | | - expect(rendered).to have_unchecked_field("pages_selection_options_input[include_none_of_the_above]", with: "yes_with_question") |
174 | | - end |
| 156 | + it "has 'No' radio selected" do |
| 157 | + expect(rendered).to have_checked_field("pages_selection_options_input[include_none_of_the_above]", with: "no") |
| 158 | + expect(rendered).to have_unchecked_field("pages_selection_options_input[include_none_of_the_above]", with: "yes") |
| 159 | + expect(rendered).to have_unchecked_field("pages_selection_options_input[include_none_of_the_above]", with: "yes_with_question") |
175 | 160 | end |
176 | 161 | end |
177 | 162 |
|
178 | | - context "when the describe_none_of_the_above_enabled feature is disabled" do |
179 | | - let(:describe_none_of_the_above_enabled) { false } |
| 163 | + context "when input object has no value set" do |
| 164 | + let(:include_none_of_the_above) { nil } |
180 | 165 |
|
181 | | - it "does not render the yes_with_question radio option" do |
182 | | - expect(rendered).not_to have_field(I18n.t("helpers.label.pages_selection_bulk_options_input.include_none_of_the_above_options.yes_with_question")) |
| 166 | + it "does not have a radio option selected" do |
| 167 | + expect(rendered).to have_unchecked_field("pages_selection_options_input[include_none_of_the_above]", with: "no") |
| 168 | + expect(rendered).to have_unchecked_field("pages_selection_options_input[include_none_of_the_above]", with: "yes") |
| 169 | + expect(rendered).to have_unchecked_field("pages_selection_options_input[include_none_of_the_above]", with: "yes_with_question") |
183 | 170 | end |
184 | 171 | end |
185 | 172 | end |
|
0 commit comments