Skip to content

Commit

Permalink
Fix rubocop's Lint/ParenthesesAsGroupedExpression
Browse files Browse the repository at this point in the history
This fixes lines like

  foo ( 1 + 2 ) + 3

Which is unclear
  • Loading branch information
jhawthorn committed Feb 16, 2016
1 parent 0822a35 commit 99c89da
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ module Admin
total_inventory_count = 4
rma_return_items_count = 1
customer_return_return_items_count = 1
expect(assigns(:new_return_items).length).to eq (total_inventory_count - rma_return_items_count - customer_return_return_items_count)
expect(assigns(:new_return_items).length).to eq(total_inventory_count - rma_return_items_count - customer_return_return_items_count)
end

it "builds new return items" do
Expand Down
4 changes: 2 additions & 2 deletions backend/spec/features/admin/users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
[:total_sales, :num_orders, :average_order_value, :member_since].each do |stat_name|
expect(page).to have_content Spree.t(stat_name)
end
expect(page).to have_content (order.total + order_2.total)
expect(page).to have_content(order.total + order_2.total)
expect(page).to have_content orders.count
expect(page).to have_content (orders.sum(&:total) / orders.count)
expect(page).to have_content(orders.sum(&:total) / orders.count)
expect(page).to have_content I18n.l(user_a.created_at.to_date)
end
end
Expand Down
2 changes: 1 addition & 1 deletion core/lib/spree/testing_support/common_rake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace :common do
task :test_app, :user_class do |_t, args|
args.with_defaults(user_class: "Spree::LegacyUser")
require (ENV['LIB_NAME']).to_s
require ENV['LIB_NAME']

ENV["RAILS_ENV"] = 'test'

Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/spree/migrations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module Spree
context "no missing migrations" do
it "says nothing" do
expect(Dir).to receive(:entries).with(engine_dir).and_return engine_migrations
expect(Dir).to receive(:entries).with(app_dir).and_return (app_migrations + engine_migrations)
expect(Dir).to receive(:entries).with(app_dir).and_return(app_migrations + engine_migrations)
expect(subject.check).to eq nil
end
end
Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/tasks/exchanges_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
Spree::Shipment.last.ship!
return_item_1.lost!
return_item_2.give!
Timecop.travel (Spree::Config[:expedited_exchanges_days_window] + 1).days
Timecop.travel((Spree::Config[:expedited_exchanges_days_window] + 1).days)
end
after { Timecop.return }
it { expect { subject.invoke }.not_to change { Spree::Order.count } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
order.adjustments.first.update_attributes(amount: adjustment_amount)
end

it { is_expected.to eq (pre_tax_amount - adjustment_amount.abs) / line_item_quantity }
it { is_expected.to eq((pre_tax_amount - adjustment_amount.abs) / line_item_quantity) }
end

context "shipping adjustments" do
Expand Down
4 changes: 2 additions & 2 deletions core/spec/models/spree/customer_return_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
subject { customer_return.total }

it "returns the sum of the return item's total amount" do
expect(subject).to eq ((pre_tax_amount * 2) + (tax_amount * 2))
expect(subject).to eq((pre_tax_amount * 2) + (tax_amount * 2))
end
end

Expand All @@ -108,7 +108,7 @@
subject { customer_return.pre_tax_total }

it "returns the sum of the return item's pre_tax_amount" do
expect(subject).to eq (pre_tax_amount * 2)
expect(subject).to eq(pre_tax_amount * 2)
end
end

Expand Down
12 changes: 6 additions & 6 deletions core/spec/models/spree/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ def merge!(other_order, user = nil)
subject { order }

it "returns the sum of the payment amounts" do
expect(subject.total_applicable_store_credit).to eq (payment.amount + second_payment.amount)
expect(subject.total_applicable_store_credit).to eq(payment.amount + second_payment.amount)
end
end

Expand Down Expand Up @@ -1225,7 +1225,7 @@ def merge!(other_order, user = nil)
let(:applicable_store_credit) { 10.0 }

it "deducts the applicable store credit" do
expect(subject.order_total_after_store_credit).to eq (order_total - applicable_store_credit)
expect(subject.order_total_after_store_credit).to eq(order_total - applicable_store_credit)
end
end

Expand Down Expand Up @@ -1309,7 +1309,7 @@ def merge!(other_order, user = nil)
end

it "returns a negative amount" do
expect(subject.display_total_applicable_store_credit.money.cents).to eq (total_applicable_store_credit * -100.0)
expect(subject.display_total_applicable_store_credit.money.cents).to eq(total_applicable_store_credit * -100.0)
end
end

Expand All @@ -1325,7 +1325,7 @@ def merge!(other_order, user = nil)
end

it "returns the order_total_after_store_credit amount" do
expect(subject.display_order_total_after_store_credit.money.cents).to eq (order_total_after_store_credit * 100.0)
expect(subject.display_order_total_after_store_credit.money.cents).to eq(order_total_after_store_credit * 100.0)
end
end

Expand All @@ -1341,7 +1341,7 @@ def merge!(other_order, user = nil)
end

it "returns the total_available_store_credit amount" do
expect(subject.display_total_available_store_credit.money.cents).to eq (total_available_store_credit * 100.0)
expect(subject.display_total_available_store_credit.money.cents).to eq(total_available_store_credit * 100.0)
end
end

Expand All @@ -1362,7 +1362,7 @@ def merge!(other_order, user = nil)

it "returns all of the user's available store credit minus what's applied to the order amount" do
amount_remaining = total_available_store_credit - total_applicable_store_credit
expect(subject.display_store_credit_remaining_after_capture.money.cents).to eq (amount_remaining * 100.0)
expect(subject.display_store_credit_remaining_after_capture.money.cents).to eq(amount_remaining * 100.0)
end
end

Expand Down
4 changes: 2 additions & 2 deletions core/spec/models/spree/reimbursement_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@
return_item.reload
expect(return_item.included_tax_total).to be > 0
expect(return_item.included_tax_total).to eq line_item.included_tax_total
expect(reimbursement.total).to eq (line_item.pre_tax_amount + line_item.included_tax_total).round(2, :down)
expect(Spree::Refund.last.amount).to eq (line_item.pre_tax_amount + line_item.included_tax_total).round(2, :down)
expect(reimbursement.total).to eq((line_item.pre_tax_amount + line_item.included_tax_total).round(2, :down))
expect(Spree::Refund.last.amount).to eq((line_item.pre_tax_amount + line_item.included_tax_total).round(2, :down))
end
end

Expand Down
6 changes: 3 additions & 3 deletions core/spec/models/spree/return_authorization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
subject { return_authorization.pre_tax_total }

it "sums it's associated return_item's pre-tax amounts" do
expect(subject).to eq (pre_tax_amount_1 + pre_tax_amount_2 + pre_tax_amount_3)
expect(subject).to eq(pre_tax_amount_1 + pre_tax_amount_2 + pre_tax_amount_3)
end
end

Expand Down Expand Up @@ -192,14 +192,14 @@
context "no promotions" do
let(:promo_total) { 0.0 }
it "returns the pre-tax line item total" do
expect(subject).to eq (weighted_line_item_pre_tax_amount * line_item_count)
expect(subject).to eq(weighted_line_item_pre_tax_amount * line_item_count)
end
end

context "promotions" do
let(:promo_total) { -10.0 }
it "returns the pre-tax line item total minus the order level promotion value" do
expect(subject).to eq (weighted_line_item_pre_tax_amount * line_item_count) + promo_total
expect(subject).to eq((weighted_line_item_pre_tax_amount * line_item_count) + promo_total)
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions core/spec/models/spree/store_credit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
before { store_credit.update_attributes(amount_authorized: authorized_amount) }

it "subtracts the authorized amount from the credited amount" do
expect(store_credit.amount_remaining).to eq (store_credit.amount - authorized_amount)
expect(store_credit.amount_remaining).to eq(store_credit.amount - authorized_amount)
end
end
end
Expand All @@ -177,7 +177,7 @@

context "the authorized amount is not defined" do
it "subtracts the amount used from the credited amount" do
expect(store_credit.amount_remaining).to eq (store_credit.amount - amount_used)
expect(store_credit.amount_remaining).to eq(store_credit.amount - amount_used)
end
end

Expand All @@ -187,7 +187,7 @@
before { store_credit.update_attributes(amount_authorized: authorized_amount) }

it "subtracts the amount used and the authorized amount from the credited amount" do
expect(store_credit.amount_remaining).to eq (store_credit.amount - amount_used - authorized_amount)
expect(store_credit.amount_remaining).to eq(store_credit.amount - amount_used - authorized_amount)
end
end
end
Expand All @@ -208,7 +208,7 @@

it "adds the new amount to authorized amount" do
store_credit.authorize(added_authorization_amount, store_credit.currency)
expect(store_credit.reload.amount_authorized).to eq (authorization_amount + added_authorization_amount)
expect(store_credit.reload.amount_authorized).to eq(authorization_amount + added_authorization_amount)
end

context "originator is present" do
Expand Down Expand Up @@ -555,7 +555,7 @@

it "credits the passed amount to the store credit amount used" do
subject
expect(store_credit.reload.amount_used).to eq (amount_used - credit_amount)
expect(store_credit.reload.amount_used).to eq(amount_used - credit_amount)
end

it "creates a new store credit event" do
Expand Down Expand Up @@ -767,7 +767,7 @@
subject { create(:store_credit, user: user, amount: additional_store_credit_amount) }

it "saves the user's total store credit in the event" do
expect(subject.store_credit_events.first.user_total_amount).to eq (store_credit_amount + additional_store_credit_amount)
expect(subject.store_credit_events.first.user_total_amount).to eq(store_credit_amount + additional_store_credit_amount)
end
end

Expand Down
12 changes: 6 additions & 6 deletions core/spec/models/spree/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def load_orders
context "with orders" do
before { load_orders }
it "returns the total of completed orders for the user" do
expect(subject.lifetime_value).to eq (order_count * order_value)
expect(subject.lifetime_value).to eq(order_count * order_value)
end
end
context "without orders" do
Expand Down Expand Up @@ -206,13 +206,13 @@ def load_orders
before { additional_store_credit.update_attributes(amount_authorized: authorized_amount) }

it "returns sum of amounts minus used amount and authorized amount" do
expect(subject.total_available_store_credit.to_f).to eq (amount + additional_amount - amount_used - authorized_amount)
expect(subject.total_available_store_credit.to_f).to eq(amount + additional_amount - amount_used - authorized_amount)
end
end

context "there are no authorized amounts on any of the store credits" do
it "returns sum of amounts minus used amount" do
expect(subject.total_available_store_credit.to_f).to eq (amount + additional_amount - amount_used)
expect(subject.total_available_store_credit.to_f).to eq(amount + additional_amount - amount_used)
end
end
end
Expand All @@ -224,20 +224,20 @@ def load_orders
before { additional_store_credit.update_attributes(amount_authorized: authorized_amount) }

it "returns sum of amounts minus authorized amount" do
expect(subject.total_available_store_credit.to_f).to eq (amount + additional_amount - authorized_amount)
expect(subject.total_available_store_credit.to_f).to eq(amount + additional_amount - authorized_amount)
end
end

context "there are no authorized amounts on any of the store credits" do
it "returns sum of amounts" do
expect(subject.total_available_store_credit.to_f).to eq (amount + additional_amount)
expect(subject.total_available_store_credit.to_f).to eq(amount + additional_amount)
end
end
end

context "all store credits have never been used or authorized" do
it "returns sum of amounts" do
expect(subject.total_available_store_credit.to_f).to eq (amount + additional_amount)
expect(subject.total_available_store_credit.to_f).to eq(amount + additional_amount)
end
end
end
Expand Down

0 comments on commit 99c89da

Please sign in to comment.