Skip to content

Commit

Permalink
Add support for v3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Tapia committed Jun 5, 2021
1 parent b112b84 commit 184cb34
Show file tree
Hide file tree
Showing 19 changed files with 58 additions and 61 deletions.
1 change: 0 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ workflows:
jobs:
- run-specs-with-postgres
- run-specs-with-mysql
- lint-code

"Weekly run specs against master":
triggers:
Expand Down
5 changes: 1 addition & 4 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# frozen_string_literal: true

require 'solidus_dev_support/rake_tasks'
require 'rubocop/rake_task'

SolidusDevSupport::RakeTasks.install
RuboCop::RakeTask.new

task default: %i(rubocop extension:specs)
task default: 'extension:specs'
2 changes: 1 addition & 1 deletion app/models/spree/locality.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ class Locality < Spree::Base
belongs_to :state, class_name: 'Spree::State'
has_one :country, through: :state

validates :name, presence: true, uniqueness: { scope: :state_id }
validates :name, presence: true
end
end
2 changes: 2 additions & 0 deletions db/migrate/20200903233530_create_locality.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class CreateLocality < ActiveRecord::Migration[5.2]
def change
create_table :spree_localities do |t|
Expand Down
2 changes: 2 additions & 0 deletions db/migrate/20200907165834_add_locality_id_to_address.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class AddLocalityIdToAddress < ActiveRecord::Migration[5.2]
def change
add_column :spree_addresses, :locality_id, :integer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class AddLocalityIdToStockLocations < ActiveRecord::Migration[5.2]
def change
add_column :spree_stock_locations, :locality_id, :integer, index: true
Expand Down
2 changes: 2 additions & 0 deletions lib/solidus_zones_by_city.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

require 'solidus_core'
require 'solidus_backend'
require 'solidus_support'
require 'deface'

require 'solidus_zones_by_city/version'
require 'solidus_zones_by_city/engine'
3 changes: 1 addition & 2 deletions lib/solidus_zones_by_city/engine.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# frozen_string_literal: true

require 'spree/core'
require 'solidus_zones_by_city'

module SolidusZonesByCity
class Engine < Rails::Engine
include SolidusSupport::EngineExtensions

isolate_namespace ::Spree
isolate_namespace Spree

engine_name 'solidus_zones_by_city'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
locality do |address|
state = address.state
Spree::Locality.find_by(name: city_name, state: state) ||
create(:city, name: city_name, state: state)
create(:locality, name: city_name, state: state)
end
end
end
Expand All @@ -45,7 +45,7 @@
locality do |stock_location|
state = stock_location.state
Spree::Locality.find_by(name: city_name, state: state) ||
create(:city, name: city_name, state: state)
create(:locality, name: city_name, state: state)
end
end
end
55 changes: 29 additions & 26 deletions solidus_zones_by_city.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,39 @@

require_relative 'lib/solidus_zones_by_city/version'

Gem::Specification.new do |spec|
spec.name = 'solidus_zones_by_city'
spec.version = SolidusZonesByCity::VERSION
spec.authors = ['César Carruitero']
spec.email = 'ccarruitero@protonmail.com'
Gem::Specification.new do |s|
s.name = 'solidus_zones_by_city'
s.version = SolidusZonesByCity::VERSION
s.authors = ['César Carruitero']
s.email = 'ccarruitero@protonmail.com'

spec.summary = 'Allow zones at city level'
spec.description = spec.summary
spec.homepage = 'https://github.com/magma-labs/solidus_zones_by_city'
spec.license = 'BSD-3-Clause'
s.summary = 'Allow zones at city level'
s.description = s.summary
s.homepage = 'http://github.com/magma-labs/solidus_zones_by_city'
s.license = 'BSD-3-Clause'

spec.metadata['homepage_uri'] = spec.homepage
spec.metadata['source_code_uri'] = 'https://github.com/magma-labs/solidus_zones_by_city'
spec.metadata['changelog_uri'] = 'https://github.com/magma-labs/solidus_zones_by_city/releases'
if s.respond_to?(:metadata)
s.metadata['homepage_uri'] = s.homepage if s.homepage
s.metadata['source_code_uri'] = s.homepage if s.homepage
end

spec.required_ruby_version = Gem::Requirement.new('~> 2.5')
s.required_ruby_version = Gem::Requirement.new('>= 2.5')

# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
files = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0") }

spec.files = files.grep_v(%r{^(test|spec|features)/})
spec.test_files = files.grep(%r{^(test|spec|features)/})
spec.bindir = "exe"
spec.executables = files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 3']
spec.add_dependency 'solidus_support', '~> 0.5'

spec.add_development_dependency 'shoulda-matchers'
spec.add_development_dependency 'solidus_dev_support'
s.files = files.grep_v(%r{^(test|spec|features)/})
s.test_files = files.grep(%r{^(test|spec|features)/})
s.bindir = "exe"
s.executables = files.grep(%r{^exe/}) { |f| File.basename(f) }
s.require_paths = ["lib"]

s.add_dependency 'deface', '~> 1.0'
s.add_dependency 'solidus_backend', ['>= 2.5', '< 4']
s.add_dependency 'solidus_core', ['>= 2.5', '< 4']
s.add_dependency 'solidus_support', '~> 0.5'

s.add_development_dependency 'autoprefixer-rails', '~> 10.2.5'
s.add_development_dependency 'rspec-activemodel-mocks'
s.add_development_dependency 'shoulda-matchers'
s.add_development_dependency 'solidus_dev_support', '~> 2.3'
end
4 changes: 1 addition & 3 deletions spec/features/admin/zones_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'Zones admin page', type: :feature, js: true do
RSpec.describe 'Zones admin page', type: :feature, js: true do
stub_authorization!

let!(:city) { create(:city) }
Expand Down
2 changes: 0 additions & 2 deletions spec/models/spree/address_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Spree::Address, type: :model do
describe 'associations' do
it { is_expected.to belong_to(:locality).optional }
Expand Down
3 changes: 0 additions & 3 deletions spec/models/spree/locality_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Spree::Locality, type: :model do
describe 'associations' do
it { is_expected.to belong_to(:state) }
end

describe 'validations' do
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_uniqueness_of(:name).scoped_to(:state_id) }
end
end
2 changes: 0 additions & 2 deletions spec/models/spree/state_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Spree::State, type: :model do
describe 'associations' do
it { is_expected.to have_many(:localities) }
Expand Down
2 changes: 0 additions & 2 deletions spec/models/spree/stock_location_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Spree::StockLocation, type: :model do
describe 'associations' do
it { is_expected.to belong_to(:locality).optional }
Expand Down
2 changes: 0 additions & 2 deletions spec/models/spree/zone_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Spree::Zone do
context 'when zone is city type' do
let(:zone) { create(:zone, name: 'CityZone') }
Expand Down
13 changes: 2 additions & 11 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# Configure Rails Environment
ENV['RAILS_ENV'] = 'test'

require 'shoulda/matchers'

# Run Coverage report
require 'solidus_dev_support/rspec/coverage'

Expand All @@ -20,8 +18,8 @@
# in spec/support/ and its subdirectories.
Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f }

# Requires factories defined in lib/solidus_zones_by_city/factories.rb
require 'solidus_zones_by_city/factories'
# Requires factories defined in lib/solidus_related_products/testing_support/factories.rb
SolidusDevSupport::TestingSupport::Factories.load_for(SolidusZonesByCity::Engine)

RSpec.configure do |config|
config.infer_spec_type_from_file_location!
Expand All @@ -31,10 +29,3 @@
config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :system
end
end

Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :rspec
with.library :rails
end
end
3 changes: 3 additions & 0 deletions spec/support/activemodel_mocks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# frozen_string_literal: true

require 'rspec-activemodel-mocks'
10 changes: 10 additions & 0 deletions spec/support/shoulda_matchers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

require 'shoulda-matchers'

Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :rspec
with.library :rails
end
end

0 comments on commit 184cb34

Please sign in to comment.