Skip to content

Commit

Permalink
Fix rubocop warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
CloCkWeRX committed Oct 4, 2021
1 parent 9d636bf commit 81fe30b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 2 additions & 0 deletions app/helpers/accounts_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,13 @@ def brief_account_info(contact)
# - a helper that abstracts the logic to the backend
def display_value(value)
return "N/A" if value.zero?

number_to_currency(value, precision: 0)
end

def display_assigned(account)
return truncate(account.assignee.full_name, length: 16) if account.assigned_to

nil
end
end
7 changes: 3 additions & 4 deletions app/models/setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,9 @@ def [](name)
return cache[name] if cache.key?(name)

# Check database
if database_and_table_exists?
if setting = find_by_name(name.to_s)
return cache[name] = setting.value unless setting.value.nil?
if database_and_table_exists? && setting = find_by_name(name.to_s) && !setting.value.nil?
return cache[name] = setting.value
end
end
# Check YAML settings
return cache[name] = yaml_settings[name] if yaml_settings.key?(name)
end
Expand All @@ -73,6 +71,7 @@ def []=(name, value)
raise ArgumentError, "name cannot be blank" if name.blank?

return nil unless database_and_table_exists?

setting = find_by_name(name.to_s) || new(name: name.to_s)
setting.value = value
setting.save
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
expect(response).to render_template("users/update")
end
end

describe "with a email with whitespace" do
it "should update the user information and render [update] template" do
put :update, params: { id: @user.id, user: { first_name: "Billy", last_name: "Bones", alt_email: " john@email.com " } }, xhr: true
Expand All @@ -140,7 +140,7 @@
expect(assigns[:user]).to eq(@user)
expect(response).to render_template("users/update")
expect(@user.alt_email).to eq("john@email.com")
end
end
end

describe "with invalid params" do
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/user_factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
# For unit tests, we dont need to enforce uniqueness
to_create { |instance| instance.save(validate: false) }
end

factory :admin do
admin { true }
end
Expand Down

0 comments on commit 81fe30b

Please sign in to comment.