|
37 | 37 | end |
38 | 38 |
|
39 | 39 | describe "#create" do |
40 | | - let(:batch_frequencies) { %w[daily] } |
41 | 40 | let(:params) { { forms_batch_submissions_input: { batch_frequencies: } } } |
| 41 | + let(:batch_frequencies) { %w[daily weekly] } |
42 | 42 |
|
43 | | - context "when the weekly submission batch feature is disabled", feature_weekly_submission_emails_enabled: false do |
44 | | - context "when the daily batch checkbox is checked" do |
45 | | - it "updates the form send_daily_submission_batch flag to true" do |
46 | | - expect { |
47 | | - post(batch_submissions_create_path(form_id: form.id), params:) |
48 | | - }.to change { form.reload.send_daily_submission_batch }.to(true) |
49 | | - end |
50 | | - |
51 | | - it "redirects to the form overview page" do |
52 | | - post(batch_submissions_create_path(form_id: form.id), params:) |
53 | | - expect(response).to redirect_to(form_path(form.id)) |
54 | | - end |
55 | | - |
56 | | - it "displays a success flash message" do |
57 | | - post(batch_submissions_create_path(form_id: form.id), params:) |
58 | | - expect(flash[:success]).to eq(I18n.t("banner.success.form.daily_submission_batch_enabled")) |
59 | | - end |
60 | | - end |
61 | | - |
62 | | - context "when the daily batch checkbox is not checked" do |
63 | | - let(:send_daily_submission_batch) { true } |
64 | | - let(:batch_frequencies) { [] } |
65 | | - |
66 | | - it "updates the form send_daily_submission_batch flag to false" do |
67 | | - expect { |
68 | | - post(batch_submissions_create_path(form_id: form.id), params:) |
69 | | - }.to change { form.reload.send_daily_submission_batch }.to(false) |
70 | | - end |
71 | | - |
72 | | - it "displays a success flash message" do |
73 | | - post(batch_submissions_create_path(form_id: form.id), params:) |
74 | | - expect(flash[:success]).to eq(I18n.t("banner.success.form.daily_submission_batch_disabled")) |
75 | | - end |
76 | | - end |
| 43 | + before do |
| 44 | + post(batch_submissions_create_path(form_id: form.id), params:) |
77 | 45 | end |
78 | 46 |
|
79 | | - context "when the weekly submission batch feature is enabled", :feature_weekly_submission_emails_enabled do |
80 | | - let(:batch_frequencies) { %w[daily weekly] } |
81 | | - |
82 | | - before do |
83 | | - post(batch_submissions_create_path(form_id: form.id), params:) |
84 | | - end |
85 | | - |
86 | | - it "updates the form" do |
87 | | - expect(form.reload.send_daily_submission_batch).to be true |
88 | | - expect(form.reload.send_weekly_submission_batch).to be true |
89 | | - end |
| 47 | + it "updates the form" do |
| 48 | + expect(form.reload.send_daily_submission_batch).to be true |
| 49 | + expect(form.reload.send_weekly_submission_batch).to be true |
| 50 | + end |
90 | 51 |
|
91 | | - it "redirects to the form overview page" do |
92 | | - expect(response).to redirect_to(form_path(form.id)) |
93 | | - end |
| 52 | + it "redirects to the form overview page" do |
| 53 | + expect(response).to redirect_to(form_path(form.id)) |
| 54 | + end |
94 | 55 |
|
95 | | - context "when only the daily batch checkbox is checked" do |
96 | | - let(:batch_frequencies) { %w[daily] } |
| 56 | + context "when only the daily batch checkbox is checked" do |
| 57 | + let(:batch_frequencies) { %w[daily] } |
97 | 58 |
|
98 | | - it "displays a success flash message indicating that daily batch emails are enabled" do |
99 | | - expect(flash[:success]).to eq(I18n.t("banner.success.form.batch_submissions.daily_enabled")) |
100 | | - end |
| 59 | + it "displays a success flash message indicating that daily batch emails are enabled" do |
| 60 | + expect(flash[:success]).to eq(I18n.t("banner.success.form.batch_submissions.daily_enabled")) |
101 | 61 | end |
| 62 | + end |
102 | 63 |
|
103 | | - context "when only the weekly batch checkbox is checked" do |
104 | | - let(:batch_frequencies) { %w[weekly] } |
| 64 | + context "when only the weekly batch checkbox is checked" do |
| 65 | + let(:batch_frequencies) { %w[weekly] } |
105 | 66 |
|
106 | | - it "displays a success flash message indicating that weekly batch emails are enabled" do |
107 | | - expect(flash[:success]).to eq(I18n.t("banner.success.form.batch_submissions.weekly_enabled")) |
108 | | - end |
| 67 | + it "displays a success flash message indicating that weekly batch emails are enabled" do |
| 68 | + expect(flash[:success]).to eq(I18n.t("banner.success.form.batch_submissions.weekly_enabled")) |
109 | 69 | end |
| 70 | + end |
110 | 71 |
|
111 | | - context "when both the daily and weekly batch checkboxes are checked" do |
112 | | - let(:batch_frequencies) { %w[daily weekly] } |
| 72 | + context "when both the daily and weekly batch checkboxes are checked" do |
| 73 | + let(:batch_frequencies) { %w[daily weekly] } |
113 | 74 |
|
114 | | - it "displays a success flash message indicating that daily and weekly batch emails are enabled" do |
115 | | - expect(flash[:success]).to eq(I18n.t("banner.success.form.batch_submissions.daily_and_weekly_enabled")) |
116 | | - end |
| 75 | + it "displays a success flash message indicating that daily and weekly batch emails are enabled" do |
| 76 | + expect(flash[:success]).to eq(I18n.t("banner.success.form.batch_submissions.daily_and_weekly_enabled")) |
117 | 77 | end |
| 78 | + end |
118 | 79 |
|
119 | | - context "when daily and weekly batch checkboxes are unchecked" do |
120 | | - let(:send_daily_submission_batch) { true } |
121 | | - let(:send_weekly_submission_batch) { true } |
122 | | - let(:batch_frequencies) { [] } |
| 80 | + context "when daily and weekly batch checkboxes are unchecked" do |
| 81 | + let(:send_daily_submission_batch) { true } |
| 82 | + let(:send_weekly_submission_batch) { true } |
| 83 | + let(:batch_frequencies) { [] } |
123 | 84 |
|
124 | | - it "displays a success flash message indicating that batch emails are disabled" do |
125 | | - expect(flash[:success]).to eq(I18n.t("banner.success.form.batch_submissions.disabled")) |
126 | | - end |
| 85 | + it "displays a success flash message indicating that batch emails are disabled" do |
| 86 | + expect(flash[:success]).to eq(I18n.t("banner.success.form.batch_submissions.disabled")) |
127 | 87 | end |
128 | 88 | end |
129 | 89 |
|
|
0 commit comments