Skip to content

Commit 97ad9f5

Browse files
committed
refactor:linter issue fix
1 parent 9e0df56 commit 97ad9f5

File tree

3 files changed

+78
-78
lines changed

3 files changed

+78
-78
lines changed

app/controllers/application_controller.rb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def handle_short_url(url_list)
7070
# volunteer/supervisor/casa_admin controller uses to send SMS
7171
# returns appropriate flash notice for SMS
7272
def deliver_sms_to(resource, body_msg)
73-
return 'blank' if resource.phone_number.blank? || !resource.casa_org.twilio_enabled?
73+
return "blank" if resource.phone_number.blank? || !resource.casa_org.twilio_enabled?
7474

7575
body = body_msg
7676
to = resource.phone_number
@@ -85,30 +85,30 @@ def deliver_sms_to(resource, body_msg)
8585

8686
begin
8787
twilio_res = @twilio.send_sms(req_params)
88-
twilio_res.error_code.nil? ? 'sent' : 'error'
88+
twilio_res.error_code.nil? ? "sent" : "error"
8989
rescue Twilio::REST::RestError => e
9090
@error = e
91-
'error'
92-
rescue StandardError # unverfied error isnt picked up by Twilio::Rest::RestError
91+
"error"
92+
rescue # unverfied error isnt picked up by Twilio::Rest::RestError
9393
# https://www.twilio.com/docs/errors/21608
94-
@error = 'Phone number is unverifiied'
95-
'error'
94+
@error = "Phone number is unverifiied"
95+
"error"
9696
end
9797
end
9898

9999
def sms_acct_creation_notice(resource_name, sms_status)
100100
case sms_status
101-
when 'blank'
101+
when "blank"
102102
"New #{resource_name} created successfully."
103-
when 'error'
103+
when "error"
104104
"New #{resource_name} created successfully. SMS not sent. Error: #{@error}."
105-
when 'sent'
105+
when "sent"
106106
"New #{resource_name} created successfully. SMS has been sent!"
107107
end
108108
end
109109

110110
def store_referring_location
111-
return unless request.referer && !request.referer.end_with?('users/sign_in') && params[:ignore_referer].blank?
111+
return unless request.referer && !request.referer.end_with?("users/sign_in") && params[:ignore_referer].blank?
112112

113113
session[:return_to] = request.referer
114114
end
@@ -149,10 +149,10 @@ def set_current_organization
149149
end
150150

151151
def not_authorized
152-
message = 'Sorry, you are not authorized to perform this action.'
152+
message = "Sorry, you are not authorized to perform this action."
153153
respond_to do |format|
154154
format.json do
155-
render json: { error: message }, status: :unauthorized
155+
render json: {error: message}, status: :unauthorized
156156
end
157157
format.any do
158158
session[:user_return_to] = nil
@@ -165,10 +165,10 @@ def not_authorized
165165
def unsupported_media_type
166166
respond_to do |format|
167167
format.json do
168-
render json: { error: 'json unsupported' }, status: :unsupported_media_type
168+
render json: {error: "json unsupported"}, status: :unsupported_media_type
169169
end
170170
format.any do
171-
flash[:alert] = 'Page not found'
171+
flash[:alert] = "Page not found"
172172
redirect_back_or_to root_url
173173
end
174174
end
@@ -181,7 +181,7 @@ def log_and_reraise(error)
181181

182182
def check_unconfirmed_email_notice(user)
183183
notice = "#{user.role} was successfully updated."
184-
notice += ' Confirmation Email Sent.' if user.saved_changes.include?('unconfirmed_email')
184+
notice += " Confirmation Email Sent." if user.saved_changes.include?("unconfirmed_email")
185185
notice
186186
end
187187
end

spec/policies/custom_link_policy.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'rails_helper'
1+
require "rails_helper"
22

33
RSpec.describe CustomLinkPolicy do
44
subject { described_class }
@@ -11,24 +11,24 @@
1111
let(:casa_admin) { create :casa_admin, casa_org: organization }
1212
let(:all_casa_admin) { create :all_casa_admin }
1313
let(:custom_link) { create(:custom_link, casa_org: organization) }
14-
let(:valid_attributes) { { text: 'Link Text', url: 'http://example.com', active: true, casa_org: organization } }
15-
let(:invalid_attributes) { { text: '', url: 'invalid', active: nil } }
14+
let(:valid_attributes) { {text: "Link Text", url: "http://example.com", active: true, casa_org: organization} }
15+
let(:invalid_attributes) { {text: "", url: "invalid", active: nil} }
1616
let(:other_org_admin) { create(:casa_admin) }
1717

1818
permissions :create?, :edit?, :new?, :show?, :update? do
19-
it 'allows same org casa_admins' do
19+
it "allows same org casa_admins" do
2020
expect(subject).to permit(casa_admin, custom_link)
2121
end
2222

23-
it 'does not allow different org casa_admins' do
23+
it "does not allow different org casa_admins" do
2424
expect(subject).not_to permit(other_org_admin, custom_link)
2525
end
2626

27-
it 'does not permit supervisor' do
27+
it "does not permit supervisor" do
2828
expect(subject).not_to permit(supervisor, custom_link)
2929
end
3030

31-
it 'does not permit volunteer' do
31+
it "does not permit volunteer" do
3232
expect(subject).not_to permit(volunteer, custom_link)
3333
end
3434
end

spec/requests/custom_links_spec.rb

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

33
RSpec.describe CustomLinksController, type: :request do
44
let(:user) { create(:user) }
55
let(:admin) { create(:casa_admin, casa_org: user.casa_org) }
66
let(:custom_link) { create(:custom_link, casa_org_id: user.casa_org_id) }
7-
let(:valid_attributes) { { text: 'Link Text', url: 'http://example.com', active: true, casa_org_id: user.casa_org_id } }
8-
let(:invalid_attributes) { { text: '', url: 'invalid', active: nil } }
7+
let(:valid_attributes) { {text: "Link Text", url: "http://example.com", active: true, casa_org_id: user.casa_org_id} }
8+
let(:invalid_attributes) { {text: "", url: "invalid", active: nil} }
99

1010
before do
1111
sign_in user
@@ -16,134 +16,134 @@
1616
allow_any_instance_of(CustomLinkPolicy).to receive(:destroy?).and_return(true)
1717
end
1818

19-
describe 'GET #new' do
20-
it 'authorizes the action' do
21-
expect_any_instance_of(CustomLinkPolicy).to receive(:new?).and_return(true)
19+
describe "GET #new" do
20+
it "authorizes the action" do
21+
allow_any_instance_of(CustomLinkPolicy).to receive(:new?).and_return(true)
2222
get new_custom_link_path
2323
end
2424

25-
it 'assigns a new CustomLink with the current user\'s casa_org_id to @custom_link' do
25+
it "assigns a new CustomLink with the current user's casa_org_id to @custom_link" do
2626
get new_custom_link_path
2727
expect(assigns(:custom_link)).to be_a_new(CustomLink)
2828
expect(assigns(:custom_link).casa_org_id).to eq(user.casa_org_id)
2929
end
3030

31-
it 'renders the new template' do
31+
it "renders the new template" do
3232
get new_custom_link_path
3333
expect(response).to render_template(:new)
3434
end
3535
end
3636

37-
describe 'GET #edit' do
38-
it 'assigns the requested custom_link as @custom_link' do
37+
describe "GET #edit" do
38+
it "assigns the requested custom_link as @custom_link" do
3939
get edit_custom_link_path(custom_link)
4040
expect(assigns(:custom_link)).to eq(custom_link)
4141
end
4242

43-
it 'authorizes the action' do
44-
expect_any_instance_of(CustomLinkPolicy).to receive(:edit?).and_return(true)
43+
it "authorizes the action" do
44+
allow_any_instance_of(CustomLinkPolicy).to receive(:edit?).and_return(true)
4545
get edit_custom_link_path(custom_link)
4646
end
4747
end
4848

49-
describe 'POST #create' do
50-
context 'with valid parameters' do
51-
it 'creates a new CustomLink' do
49+
describe "POST #create" do
50+
context "with valid parameters" do
51+
it "creates a new CustomLink" do
5252
expect do
53-
post custom_links_path, params: { custom_link: valid_attributes }
53+
post custom_links_path, params: {custom_link: valid_attributes}
5454
end.to change(CustomLink, :count).by(1)
5555
end
5656

57-
it 'redirects to the edit_casa_org_path' do
58-
post custom_links_path, params: { custom_link: valid_attributes }
57+
it "redirects to the edit_casa_org_path" do
58+
post custom_links_path, params: {custom_link: valid_attributes}
5959
expect(response).to redirect_to(edit_casa_org_path(user.casa_org))
6060
end
6161

62-
it 'sets a success notice' do
63-
post custom_links_path, params: { custom_link: valid_attributes }
64-
expect(flash[:notice]).to eq('Custom link was successfully created.')
62+
it "sets a success notice" do
63+
post custom_links_path, params: {custom_link: valid_attributes}
64+
expect(flash[:notice]).to eq("Custom link was successfully created.")
6565
end
6666

67-
it 'authorizes the action' do
68-
expect_any_instance_of(CustomLinkPolicy).to receive(:create?).and_return(true)
69-
post custom_links_path, params: { custom_link: valid_attributes }
67+
it "authorizes the action" do
68+
allow_any_instance_of(CustomLinkPolicy).to receive(:create?).and_return(true)
69+
post custom_links_path, params: {custom_link: valid_attributes}
7070
end
7171
end
7272

73-
context 'with invalid parameters' do
74-
it 'does not create a new CustomLink' do
73+
context "with invalid parameters" do
74+
it "does not create a new CustomLink" do
7575
expect do
76-
post custom_links_path, params: { custom_link: invalid_attributes }
77-
end.to change(CustomLink, :count).by(0)
76+
post custom_links_path, params: {custom_link: invalid_attributes}
77+
end.not_to change(CustomLink, :count)
7878
end
7979

80-
it 'renders the new template' do
81-
post custom_links_path, params: { custom_link: invalid_attributes }
80+
it "renders the new template" do
81+
post custom_links_path, params: {custom_link: invalid_attributes}
8282
expect(response).to render_template(:new)
8383
end
8484
end
8585
end
8686

87-
describe 'PATCH/PUT #update' do
88-
context 'with valid parameters' do
89-
let(:new_attributes) { { text: 'Updated Text', url: 'http://updated.com' } }
87+
describe "PATCH/PUT #update" do
88+
context "with valid parameters" do
89+
let(:new_attributes) { {text: "Updated Text", url: "http://updated.com"} }
9090

91-
it 'updates the requested custom_link' do
92-
patch custom_link_path(custom_link), params: { custom_link: new_attributes }
91+
it "updates the requested custom_link" do
92+
patch custom_link_path(custom_link), params: {custom_link: new_attributes}
9393
custom_link.reload
94-
expect(custom_link.text).to eq('Updated Text')
94+
expect(custom_link.text).to eq("Updated Text")
9595
end
9696

97-
it 'redirects to the edit_casa_org_path' do
98-
patch custom_link_path(custom_link), params: { custom_link: new_attributes }
97+
it "redirects to the edit_casa_org_path" do
98+
patch custom_link_path(custom_link), params: {custom_link: new_attributes}
9999
expect(response).to redirect_to(edit_casa_org_path(user.casa_org))
100100
end
101101

102-
it 'sets a success notice' do
103-
patch custom_link_path(custom_link), params: { custom_link: new_attributes }
104-
expect(flash[:notice]).to eq('Custom link was successfully updated.')
102+
it "sets a success notice" do
103+
patch custom_link_path(custom_link), params: {custom_link: new_attributes}
104+
expect(flash[:notice]).to eq("Custom link was successfully updated.")
105105
end
106106

107-
it 'authorizes the action' do
108-
expect_any_instance_of(CustomLinkPolicy).to receive(:update?).and_return(true)
109-
patch custom_link_path(custom_link), params: { custom_link: new_attributes }
107+
it "authorizes the action" do
108+
allow_any_instance_of(CustomLinkPolicy).to receive(:update?).and_return(true)
109+
patch custom_link_path(custom_link), params: {custom_link: new_attributes}
110110
end
111111
end
112112

113-
context 'with invalid parameters' do
114-
it 'does not update the requested custom_link' do
115-
patch custom_link_path(custom_link), params: { custom_link: invalid_attributes }
113+
context "with invalid parameters" do
114+
it "does not update the requested custom_link" do
115+
patch custom_link_path(custom_link), params: {custom_link: invalid_attributes}
116116
custom_link.reload
117117
expect(custom_link.text).not_to be_empty
118118
end
119119

120-
it 'renders the edit template' do
121-
patch custom_link_path(custom_link), params: { custom_link: invalid_attributes }
120+
it "renders the edit template" do
121+
patch custom_link_path(custom_link), params: {custom_link: invalid_attributes}
122122
expect(response).to render_template(:edit)
123123
end
124124
end
125125
end
126126

127-
describe 'DELETE #destroy' do
128-
it 'destroys the requested custom_link' do
127+
describe "DELETE #destroy" do
128+
it "destroys the requested custom_link" do
129129
custom_link
130130
expect do
131131
delete custom_link_path(custom_link)
132132
end.to change(CustomLink, :count).by(-1)
133133
end
134134

135-
it 'redirects to the edit_casa_org_path' do
135+
it "redirects to the edit_casa_org_path" do
136136
delete custom_link_path(custom_link)
137137
expect(response).to redirect_to(edit_casa_org_path(user.casa_org))
138138
end
139139

140-
it 'sets a success notice' do
140+
it "sets a success notice" do
141141
delete custom_link_path(custom_link)
142-
expect(flash[:notice]).to eq('Custom link was successfully removed.')
142+
expect(flash[:notice]).to eq("Custom link was successfully removed.")
143143
end
144144

145-
it 'authorizes the action' do
146-
expect_any_instance_of(CustomLinkPolicy).to receive(:destroy?).and_return(true)
145+
it "authorizes the action" do
146+
allow_any_instance_of(CustomLinkPolicy).to receive(:destroy?).and_return(true)
147147
delete custom_link_path(custom_link)
148148
end
149149
end

0 commit comments

Comments
 (0)