|
6 | 6 |
|
7 | 7 | before { sign_in admin } |
8 | 8 |
|
9 | | - describe "GET /index" do |
10 | | - subject(:request) do |
11 | | - get case_contacts_new_design_path |
12 | | - |
13 | | - response |
| 9 | + context "when new_case_contact_table flag is disabled" do |
| 10 | + before do |
| 11 | + allow(Flipper).to receive(:enabled?).with(:new_case_contact_table).and_return(false) |
14 | 12 | end |
15 | 13 |
|
16 | | - let!(:casa_case) { create(:casa_case, casa_org: organization) } |
17 | | - let!(:past_contact) { create(:case_contact, :active, casa_case: casa_case, occurred_at: 3.weeks.ago) } |
18 | | - let!(:recent_contact) { create(:case_contact, :active, casa_case: casa_case, occurred_at: 3.days.ago) } |
19 | | - let!(:draft_contact) { create(:case_contact, casa_case: casa_case, occurred_at: 5.days.ago, status: "started") } |
20 | | - |
21 | | - it { is_expected.to have_http_status(:success) } |
| 14 | + describe "GET /index" do |
| 15 | + it "redirects to case_contacts_path" do |
| 16 | + get case_contacts_new_design_path |
| 17 | + expect(response).to redirect_to(case_contacts_path) |
| 18 | + end |
22 | 19 |
|
23 | | - it "lists exactly two active contacts and one draft" do |
24 | | - doc = Nokogiri::HTML(request.body) |
25 | | - case_contact_rows = doc.css('[data-testid="case_contact-row"]') |
26 | | - expect(case_contact_rows.size).to eq(3) |
| 20 | + it "sets an alert message" do |
| 21 | + get case_contacts_new_design_path |
| 22 | + expect(flash[:alert]).to eq("This feature is not available.") |
| 23 | + end |
27 | 24 | end |
| 25 | + end |
28 | 26 |
|
29 | | - it "shows the draft badge exactly once" do |
30 | | - doc = Nokogiri::HTML(request.body) |
31 | | - expect(doc.css('[data-testid="draft-badge"]').count).to eq(1) |
| 27 | + context "when new_case_contact_table flag is enabled" do |
| 28 | + before do |
| 29 | + allow(Flipper).to receive(:enabled?).with(:new_case_contact_table).and_return(true) |
32 | 30 | end |
33 | 31 |
|
34 | | - it "orders contacts by occurred_at desc" do |
35 | | - body = request.body |
| 32 | + describe "GET /index" do |
| 33 | + subject(:request) do |
| 34 | + get case_contacts_new_design_path |
| 35 | + |
| 36 | + response |
| 37 | + end |
| 38 | + |
| 39 | + let!(:casa_case) { create(:casa_case, casa_org: organization) } |
| 40 | + let!(:past_contact) { create(:case_contact, :active, casa_case: casa_case, occurred_at: 3.weeks.ago) } |
| 41 | + let!(:recent_contact) { create(:case_contact, :active, casa_case: casa_case, occurred_at: 3.days.ago) } |
| 42 | + let!(:draft_contact) { create(:case_contact, casa_case: casa_case, occurred_at: 5.days.ago, status: "started") } |
| 43 | + |
| 44 | + it { is_expected.to have_http_status(:success) } |
| 45 | + |
| 46 | + it "lists exactly two active contacts and one draft" do |
| 47 | + doc = Nokogiri::HTML(request.body) |
| 48 | + case_contact_rows = doc.css('[data-testid="case_contact-row"]') |
| 49 | + expect(case_contact_rows.size).to eq(3) |
| 50 | + end |
| 51 | + |
| 52 | + it "shows the draft badge exactly once" do |
| 53 | + doc = Nokogiri::HTML(request.body) |
| 54 | + expect(doc.css('[data-testid="draft-badge"]').count).to eq(1) |
| 55 | + end |
| 56 | + |
| 57 | + it "orders contacts by occurred_at desc" do |
| 58 | + body = request.body |
36 | 59 |
|
37 | | - recent_index = body.index(I18n.l(recent_contact.occurred_at, format: :full)) |
38 | | - past_index = body.index(I18n.l(past_contact.occurred_at, format: :full)) |
| 60 | + recent_index = body.index(I18n.l(recent_contact.occurred_at, format: :full)) |
| 61 | + past_index = body.index(I18n.l(past_contact.occurred_at, format: :full)) |
39 | 62 |
|
40 | | - expect(recent_index).to be < past_index |
| 63 | + expect(recent_index).to be < past_index |
| 64 | + end |
41 | 65 | end |
42 | 66 | end |
43 | 67 | end |
0 commit comments