Skip to content

Commit 3f0ba7b

Browse files
authored
Merge pull request #6491 from rubyforgood/abachman/edit-org-placement-types
Add Placement Types management functionality
2 parents 2caa6a8 + 1dba7ec commit 3f0ba7b

File tree

3 files changed

+8
-31
lines changed

3 files changed

+8
-31
lines changed

spec/views/casa_orgs/edit.html.erb_spec.rb

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
require "rails_helper"
22

33
RSpec.describe "casa_org/edit", type: :view do
4+
let(:organization) { build_stubbed(:casa_org) }
5+
46
before do
57
assign(:contact_type_groups, [])
68
assign(:contact_types, [])
@@ -13,13 +15,12 @@
1315
assign(:custom_org_links, [])
1416
assign(:placement_types, [])
1517

18+
allow(view).to receive(:current_organization).and_return(organization)
19+
1620
sign_in build_stubbed(:casa_admin)
1721
end
1822

1923
it "has casa org edit page text" do
20-
organization = build_stubbed(:casa_org)
21-
allow(view).to receive(:current_organization).and_return(organization)
22-
2324
render template: "casa_org/edit"
2425

2526
expect(rendered).to have_text "Editing CASA Organization"
@@ -28,8 +29,6 @@
2829
end
2930

3031
it "has contact topic content" do
31-
organization = build_stubbed(:casa_org)
32-
allow(view).to receive(:current_organization).and_return(organization)
3332
contact_topic = build_stubbed(:contact_topic, question: "Test Question", details: "Test details")
3433
assign(:contact_topics, [contact_topic])
3534

@@ -45,8 +44,6 @@
4544
end
4645

4746
it "has contact types content" do
48-
organization = build_stubbed(:casa_org)
49-
allow(view).to receive(:current_organization).and_return(organization)
5047
contact_type = build_stubbed(:contact_type, name: "Contact type 1")
5148
assign(:contact_types, [contact_type])
5249

@@ -62,8 +59,6 @@
6259
end
6360

6461
it "has contact type groups content" do
65-
organization = build_stubbed(:casa_org)
66-
allow(view).to receive(:current_organization).and_return(organization)
6762
contact_type_group = build_stubbed(:contact_type_group, casa_org: organization, name: "Contact type group 1")
6863
assign(:contact_type_groups, [contact_type_group])
6964

@@ -78,8 +73,6 @@
7873
end
7974

8075
it "has hearing types content" do
81-
organization = build_stubbed(:casa_org)
82-
allow(view).to receive(:current_organization).and_return(organization)
8376
hearing_type = build_stubbed(:hearing_type, casa_org: organization, name: "Hearing type 1")
8477
assign(:hearing_types, [hearing_type])
8578

@@ -94,8 +87,6 @@
9487
end
9588

9689
it "has judge content" do
97-
organization = build_stubbed(:casa_org)
98-
allow(view).to receive(:current_organization).and_return(organization)
9990
judge = build_stubbed(:judge, casa_org: organization, name: "Joey Tom")
10091
assign(:judges, [judge])
10192

@@ -105,8 +96,6 @@
10596
end
10697

10798
it "has placement types content" do
108-
organization = build_stubbed(:casa_org)
109-
allow(view).to receive(:current_organization).and_return(organization)
11099
placement_type = build_stubbed(:placement_type, name: "Placement type 1")
111100
placement_type_2 = build_stubbed(:placement_type, name: "Placement type 2")
112101
assign(:placement_types, [placement_type, placement_type_2])
@@ -123,18 +112,13 @@
123112
end
124113

125114
it "does not show download prompt with no custom template" do
126-
organization = build_stubbed(:casa_org)
127-
allow(view).to receive(:current_organization).and_return(organization)
128-
129115
render template: "casa_org/edit"
130116

131117
expect(rendered).not_to have_text("Download Current Template")
132118
end
133119

134120
it "has sent emails content" do
135-
organization = build_stubbed(:casa_org)
136121
admin = build_stubbed(:casa_admin, casa_org: organization)
137-
allow(view).to receive(:current_organization).and_return(organization)
138122
without_partial_double_verification do
139123
allow(view).to receive(:to_user_timezone).and_return(Time.zone.local(2021, 1, 2, 12, 30, 0))
140124
end
@@ -152,10 +136,11 @@
152136
end
153137

154138
context "with a template uploaded" do
155-
it "renders a prompt to download current template" do
156-
organization = create(:casa_org)
157-
allow(view).to receive(:current_organization).and_return(organization)
139+
# NOTE(@abachman): Use create instead of build_stubbed because ActiveStorage
140+
# needs to save to the DB
141+
let(:organization) { create(:casa_org) }
158142

143+
it "renders a prompt to download current template" do
159144
organization.court_report_template.attach(io: File.open("#{Rails.root.join("app/documents/templates/default_report_template.docx")}"), filename: 'default_report_template
160145
.docx', content_type: "application/docx")
161146

@@ -169,8 +154,6 @@
169154
context "enabled" do
170155
it "has option to enable additional expenses" do
171156
allow(Flipper).to receive(:enabled?).with(:show_additional_expenses).and_return(true)
172-
organization = build_stubbed(:casa_org)
173-
allow(view).to receive(:current_organization).and_return(organization)
174157

175158
render template: "casa_org/edit"
176159

@@ -181,8 +164,6 @@
181164
context "disabled" do
182165
it "has option to enable additional expenses" do
183166
allow(Flipper).to receive(:enabled?).with(:show_additional_expenses).and_return(false)
184-
organization = build_stubbed(:casa_org)
185-
allow(view).to receive(:current_organization).and_return(organization)
186167

187168
render template: "casa_org/edit"
188169

spec/views/placement_types/edit.html.erb_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
before do
99
enable_pundit(view, admin)
10-
allow(view).to receive(:current_user).and_return(admin)
11-
allow(view).to receive(:current_organization).and_return(organization)
1210
sign_in admin
1311
end
1412

spec/views/placement_types/new.html.erb_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
before do
99
enable_pundit(view, admin)
10-
allow(view).to receive(:current_user).and_return(admin)
11-
allow(view).to receive(:current_organization).and_return(organization)
1210
sign_in admin
1311
end
1412

0 commit comments

Comments
 (0)