Skip to content

Commit

Permalink
Rubocop auto
Browse files Browse the repository at this point in the history
  • Loading branch information
jhawthorn committed Mar 8, 2018
1 parent e0ab0c2 commit b3007bb
Show file tree
Hide file tree
Showing 113 changed files with 190 additions and 202 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ end

gem 'rspec_junit_formatter', require: false, group: :ci

custom_gemfile = File.expand_path("../Gemfile-custom", __FILE__)
custom_gemfile = File.expand_path('Gemfile-custom', __dir__)
eval File.read(custom_gemfile) if File.exist?(custom_gemfile)
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ desc "Run backend JS specs"
subproject_task("backend", "spec:js", title: "backend JS", task_name: "spec:backend:js")

# Add backend JS specs to `rake spec` dependencies
task :spec => 'spec:backend:js'
task spec: 'spec:backend:js'

task test: :spec
task test_app: 'db:reset'
Expand Down Expand Up @@ -67,7 +67,7 @@ namespace :gem do

desc "Build all solidus gems"
task :build do
pkgdir = File.expand_path("../pkg", __FILE__)
pkgdir = File.expand_path('pkg', __dir__)
FileUtils.mkdir_p pkgdir

%w(core api backend frontend sample).each do |gem_name|
Expand Down
2 changes: 1 addition & 1 deletion api/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RSpec::Core::RakeTask.new
task default: :spec

DummyApp::RakeTasks.new(
gem_root: File.expand_path('../', __FILE__),
gem_root: File.expand_path(__dir__),
lib_name: 'solidus_api'
)

Expand Down
2 changes: 1 addition & 1 deletion api/app/controllers/spree/api/payments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def create

def update
authorize! params[:action], @payment
if ! @payment.pending?
if !@payment.pending?
render 'update_forbidden', status: 403
elsif @payment.update_attributes(payment_params)
respond_with(@payment, default_template: :show)
Expand Down
4 changes: 2 additions & 2 deletions api/app/controllers/spree/api/states_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def show
def scope
if params[:country_id]
@country = Spree::Country.accessible_by(current_ability, :read).find(params[:country_id])
return @country.states.accessible_by(current_ability, :read)
@country.states.accessible_by(current_ability, :read)
else
return Spree::State.accessible_by(current_ability, :read)
Spree::State.accessible_by(current_ability, :read)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions api/script/rails
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.

ENGINE_ROOT = File.expand_path('../..', __FILE__)
ENGINE_PATH = File.expand_path('../../lib/spree/api/engine', __FILE__)
ENGINE_ROOT = File.expand_path('..', __dir__)
ENGINE_PATH = File.expand_path('../lib/spree/api/engine', __dir__)

require 'rails/all'
require 'rails/engine/commands'
4 changes: 2 additions & 2 deletions api/solidus_api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Gem::Specification.new do |gem|
gem.required_ruby_version = '>= 2.2.2'
gem.required_rubygems_version = '>= 1.8.23'

gem.add_dependency 'solidus_core', gem.version
gem.add_dependency 'responders'
gem.add_dependency 'jbuilder', '~> 2.6'
gem.add_dependency 'kaminari-activerecord', '~> 1.1'
gem.add_dependency 'responders'
gem.add_dependency 'solidus_core', gem.version
end
4 changes: 2 additions & 2 deletions api/spec/controllers/spree/api/resource_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def permitted_widget_attributes
get :index, params: { token: admin_user.spree_api_key }, as: :json
expect(response).to be_successful
expect(json_response['widgets']).to include(hash_including(
'name' => 'a widget',
'position' => 1
'name' => 'a widget',
'position' => 1
))
end

Expand Down
1 change: 0 additions & 1 deletion api/spec/requests/spree/api/addresses_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Spree
describe Api::AddressesController, type: :request do

before do
stub_authentication!
@address = create(:address)
Expand Down
1 change: 0 additions & 1 deletion api/spec/requests/spree/api/checkouts_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Spree
describe Api::CheckoutsController, type: :request do

before(:each) do
stub_authentication!
Spree::Config[:track_inventory_levels] = false
Expand Down
2 changes: 1 addition & 1 deletion api/spec/requests/spree/api/config_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module Spree
describe Api::ConfigController, type: :request do
let!(:default_country) { create :country, iso: "US"}
let!(:default_country) { create :country, iso: "US" }

before do
stub_authentication!
Expand Down
1 change: 0 additions & 1 deletion api/spec/requests/spree/api/countries_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Spree
describe Api::CountriesController, type: :request do

before do
stub_authentication!
@state = create(:state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
module Spree
describe Api::CreditCardsController, type: :request do
describe '#index' do

let!(:admin_user) do
create(:admin_user)
end
Expand Down
1 change: 0 additions & 1 deletion api/spec/requests/spree/api/images_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Spree
describe Spree::Api::ImagesController, type: :request do

let!(:product) { create(:product) }
let!(:attributes) {
[:id, :position, :attachment_content_type,
Expand Down
1 change: 0 additions & 1 deletion api/spec/requests/spree/api/line_items_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ module Spree
end

describe Api::LineItemsController, type: :request do

let!(:order) { create(:order_with_line_items, line_items_count: 1) }

let(:product) { create(:product) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Spree
describe Api::OptionTypesController, type: :request do

let(:attributes) { [:id, :name, :position, :presentation] }
let!(:option_value) { create(:option_value) }
let!(:option_type) { option_value.option_type }
Expand Down
3 changes: 1 addition & 2 deletions api/spec/requests/spree/api/option_values_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Spree
describe Api::OptionValuesController, type: :request do

let(:attributes) { [:id, :name, :presentation, :option_type_name, :option_type_name] }
let!(:option_value) { create(:option_value) }
let!(:option_type) { option_value.option_type }
Expand Down Expand Up @@ -103,7 +102,7 @@ def check_option_values(option_values)
end

it "cannot create an option type with invalid attributes" do
post spree.api_option_type_option_values_path(option_type), params: { option_value: {name: ""} }
post spree.api_option_type_option_values_path(option_type), params: { option_value: { name: "" } }
expect(response.status).to eq(422)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

module Spree
describe Spree::Api::ProductPropertiesController, type: :request do

let!(:product) { create(:product) }
let!(:property_1) { product.product_properties.create(property_name: "My Property 1", value: "my value 1", position: 0) }
let!(:property_2) { product.product_properties.create(property_name: "My Property 2", value: "my value 2", position: 1) }
Expand Down
5 changes: 2 additions & 3 deletions api/spec/requests/spree/api/products_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

module Spree
describe Spree::Api::ProductsController, type: :request do

let!(:product) { create(:product) }
let!(:inactive_product) { create(:product, available_on: Time.current.tomorrow, name: "inactive") }
let(:base_attributes) { Api::ApiHelpers.product_attributes }
Expand Down Expand Up @@ -351,7 +350,7 @@ module Spree
expect(response.status).to eq 200
expect(json_response['variants'].count).to eq(2) # 2 variants

variants = json_response['variants'].select { |v| !v['is_master'] }
variants = json_response['variants'].reject { |v| v['is_master'] }
size_option_value = variants.last['option_values'].detect{ |x| x['option_type_name'] == 'size' }
expect(size_option_value['name']).to eq('small')

Expand All @@ -375,7 +374,7 @@ module Spree
} }

expect(json_response['variants'].count).to eq(1)
variants = json_response['variants'].select { |v| !v['is_master'] }
variants = json_response['variants'].reject { |v| v['is_master'] }
expect(variants.last['option_values'][0]['name']).to eq('large')
expect(variants.last['sku']).to eq('456')
expect(variants.count).to eq(1)
Expand Down
1 change: 0 additions & 1 deletion api/spec/requests/spree/api/promotion_application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Spree::Api
describe OrdersController, type: :request do

before do
stub_authentication!
end
Expand Down
1 change: 0 additions & 1 deletion api/spec/requests/spree/api/promotions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Spree
describe Spree::Api::PromotionsController, type: :request do

shared_examples "a JSON response" do
it 'should be ok' do
subject
Expand Down
1 change: 0 additions & 1 deletion api/spec/requests/spree/api/properties_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
require 'spec_helper'
module Spree
describe Spree::Api::PropertiesController, type: :request do

let!(:property_1) { Property.create!(name: "foo", presentation: "Foo") }
let!(:property_2) { Property.create!(name: "bar", presentation: "Bar") }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Spree
describe Api::ReturnAuthorizationsController, type: :request do

let!(:order) { create(:shipped_order) }

let(:product) { create(:product) }
Expand Down
1 change: 0 additions & 1 deletion api/spec/requests/spree/api/states_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Spree
describe Api::StatesController, type: :request do

let!(:state) { create(:state, name: "Victoria") }
let(:attributes) { [:id, :name, :abbr, :country_id] }

Expand Down
1 change: 0 additions & 1 deletion api/spec/requests/spree/api/stock_items_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Spree
describe Api::StockItemsController, type: :request do

let!(:stock_location) { create(:stock_location_with_items) }
let!(:stock_item) { stock_location.stock_items.order(:id).first }
let!(:attributes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Spree
describe Api::StockLocationsController, type: :request do

let!(:stock_location) { create(:stock_location) }
let!(:attributes) { [:id, :name, :address1, :address2, :city, :state_id, :state_name, :country_id, :zipcode, :phone, :active] }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Spree
describe Api::StockMovementsController, type: :request do

let!(:stock_location) { create(:stock_location_with_items) }
let!(:stock_item) { stock_location.stock_items.order(:id).first }
let!(:stock_movement) { create(:stock_movement, stock_item: stock_item) }
Expand Down
4 changes: 1 addition & 3 deletions api/spec/requests/spree/api/stores_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Spree
describe Api::StoresController, type: :request do

let!(:store) do
create(:store, name: "My Spree Store", url: "spreestore.example.com")
end
Expand All @@ -20,8 +19,7 @@ module Spree
create(:store,
name: "Extra Store",
url: "spreestore-5.example.com",
default: false
)
default: false)
end

it "can list the available stores" do
Expand Down
1 change: 0 additions & 1 deletion api/spec/requests/spree/api/taxonomies_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Spree
describe Api::TaxonomiesController, type: :request do

let(:taxonomy) { create(:taxonomy) }
let(:taxon) { create(:taxon, name: "Ruby", taxonomy: taxonomy) }
let(:taxon2) { create(:taxon, name: "Rails", taxonomy: taxonomy) }
Expand Down
1 change: 0 additions & 1 deletion api/spec/requests/spree/api/taxons_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Spree
describe Api::TaxonsController, type: :request do

let(:taxonomy) { create(:taxonomy) }
let(:taxon) { create(:taxon, name: "Ruby", taxonomy: taxonomy) }
let(:taxon2) { create(:taxon, name: "Rails", taxonomy: taxonomy) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

module Spree
describe Spree::Api::ProductsController, type: :request do

let!(:product) { create(:product) }
let(:attributes) { [:id, :name, :description, :price, :available_on, :slug, :meta_description, :meta_keywords, :taxon_ids, :meta_title] }

Expand Down
1 change: 0 additions & 1 deletion api/spec/requests/spree/api/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Spree
describe Api::UsersController, type: :request do

let(:user) { create(:user, spree_api_key: SecureRandom.hex) }
let(:stranger) { create(:user, email: '[email protected]') }
let(:attributes) { [:id, :email, :created_at, :updated_at] }
Expand Down
2 changes: 0 additions & 2 deletions api/spec/requests/spree/api/variants_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Spree
describe Api::VariantsController, type: :request do

let!(:product) { create(:product) }
let!(:variant) do
variant = product.master
Expand Down Expand Up @@ -89,7 +88,6 @@ module Spree
end

context "stock filtering" do

context "only variants in stock" do
subject { get spree.api_variants_path, params: { in_stock_only: "true" } }

Expand Down
1 change: 0 additions & 1 deletion api/spec/requests/spree/api/zones_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module Spree
describe Api::ZonesController, type: :request do

let!(:attributes) { [:id, :name, :zone_members] }
let!(:zone) { create(:zone, name: 'Europe') }

Expand Down
2 changes: 1 addition & 1 deletion api/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
require 'solidus_api'
require 'spree/testing_support/dummy_app'
DummyApp.setup(
gem_root: File.expand_path('../../', __FILE__),
gem_root: File.expand_path('..', __dir__),
lib_name: 'solidus_api'
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# frozen_string_literal: true

json.(widget, :id, :name, :position)
2 changes: 1 addition & 1 deletion api/spec/test_views/spree/api/widgets/index.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ json.widgets(@collection) do |widget|
json.partial!("spree/api/widgets/widget", widget: widget)
end
json.count @collection.count
json.current_page (params[:page] or 1)
json.current_page (params[:page] || 1)
json.pages @collection.total_pages
6 changes: 3 additions & 3 deletions backend/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RSpec::Core::RakeTask.new
task default: [:spec, 'spec:js']

DummyApp::RakeTasks.new(
gem_root: File.expand_path('../', __FILE__),
gem_root: File.expand_path(__dir__),
lib_name: 'solidus_backend'
)

Expand All @@ -28,7 +28,7 @@ task :teaspoon do
driver_options: ENV["driver_options"],
}

options.delete_if { |k, v| v.nil? }
options.delete_if { |_k, v| v.nil? }

abort("rake teaspoon failed") if Teaspoon::Console.new(options).failures?
end
Expand All @@ -37,7 +37,7 @@ desc "Run javascript specs"
task 'spec:js' => :teaspoon

namespace :teaspoon do
task :server do
task :server do
require 'teaspoon'
Rake::Task['dummy_environment'].invoke
require 'teaspoon/server'
Expand Down
Loading

0 comments on commit b3007bb

Please sign in to comment.