Skip to content

Commit 32c8118

Browse files
committed
Change Client#wrap_status and ClientAction#wrap_action enums' ':open' option to ':opened' to avoid conflict with reserved #open method.
1 parent 3c201c9 commit 32c8118

File tree

6 files changed

+18
-11
lines changed

6 files changed

+18
-11
lines changed

app/helpers/client_actions_helper.rb

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ def client_wrap_action_prettified
88
end
99

1010
def wrap_situation_prettified(wrap_text)
11-
"<span class='#{wrap_text.to_s}_wrap bold_text'>
12-
#{wrap_text.upcase.gsub(/_/,' ')}
11+
if wrap_text.downcase == "opened"
12+
new_wrap_text = "open"
13+
else
14+
new_wrap_text = wrap_text
15+
end
16+
17+
"<span class='#{new_wrap_text.to_s}_wrap bold_text'>
18+
#{new_wrap_text.upcase.gsub(/_/,' ')}
1319
</span>".html_safe
1420
end
1521

app/models/client.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class Client < ApplicationRecord
22
has_many :appointments, dependent: :destroy
33
has_many :client_actions
44
belongs_to :user, optional: true
5-
enum wrap_status: [:open, :closed, :completed, :non_wrap]
5+
enum wrap_status: [:opened, :closed, :completed, :non_wrap]
66
after_initialize :set_default_wrap_status, if: :new_record?
77

88
def set_default_wrap_status

app/models/client_action.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ class ClientAction < ApplicationRecord
22
belongs_to :client
33
accepts_nested_attributes_for :client
44
enum wrap_session: [:no, :yes]
5-
enum wrap_action: [:open, :closed, :completed, :non_wrap, :no_change]
5+
enum wrap_action: [:opened, :closed, :completed, :non_wrap, :no_change]
66
end

app/views/client_actions/_form.html.erb

+3-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@
4444
<%= f.fields_for(client) do |fc| %>
4545
<%= fc.form_group :wrap_status,
4646
label: { text: "Change WRAP Status" } do %>
47-
<span class="glyphicon glyphicon-folder-open" aria-hidden="true"></span>
48-
<%= fc.radio_button :wrap_status, :open, label: "Open WRAP case",
47+
<span class="glyphicon glyphicon-folder-open" aria-hidden="true">
48+
</span>
49+
<%= fc.radio_button :wrap_status, :opened, label: "Open WRAP case",
4950
inline: true %>
5051
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
5152
<%= fc.radio_button :wrap_status, :closed, label: "Close WRAP case",

db/seeds.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
client_action.wrap_session = [0, 1].sample
2727
client_action.notes = Faker::Lorem.sentence
2828
client_action.client_id = client_id_array.sample
29-
client_action.wrap_action = [:open, :closed, :completed, :non_wrap,
29+
client_action.wrap_action = [:opened, :closed, :completed, :non_wrap,
3030
:no_change].sample
3131
random_date = Faker::Date.between(3.months.ago, Date.today)
3232
client_action.created_at = random_date

spec/features/create_client_action_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
scenario "wrap_action should reflect changes to wrap_status" do
3030
visit client_path(@client)
3131
find_link("New Action").click
32-
choose("client_action_client_wrap_status_open")
32+
choose("client_action_client_wrap_status_opened")
3333
choose("client_action_wrap_session_yes")
3434
find_button("save_client_action").click
3535
expect(page).to have_content "Action saved successfully"
36-
expect(ClientAction.find(1).wrap_action).to eq "open"
37-
expect(Client.find(1).wrap_status).to eq "open"
36+
expect(ClientAction.find(1).wrap_action).to eq "opened"
37+
expect(Client.find(1).wrap_status).to eq "opened"
3838

3939
within("div#client_action_#{@client_action.id}") do
4040
find_link("client_action_#{@client_action.id}_link").click
@@ -51,6 +51,6 @@
5151
find_link("client_action_2_link").click
5252
end
5353
expect(ClientAction.find(2).wrap_action).to eq "no_change"
54-
expect(Client.find(1).wrap_status).to eq "open"
54+
expect(Client.find(1).wrap_status).to eq "opened"
5555
end
5656
end

0 commit comments

Comments
 (0)