spree_counties 2.3.4 → 2.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.bundle/config +2 -0
  3. data/.gitignore +14 -0
  4. data/.rspec +1 -0
  5. data/Gemfile +7 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +43 -0
  8. data/Rakefile +21 -0
  9. data/app/assets/javascripts/spree/backend/spree_counties.js +30 -0
  10. data/app/assets/javascripts/spree/frontend/spree_counties.js.coffee +58 -0
  11. data/app/assets/stylesheets/spree/backend/spree_counties.css +4 -0
  12. data/app/assets/stylesheets/spree/frontend/spree_counties.css +4 -0
  13. data/app/controllers/spree/api/counties_controller.rb +38 -0
  14. data/app/models/county_ability.rb +10 -0
  15. data/app/models/spree/address_decorator.rb +7 -0
  16. data/app/models/spree/county.rb +13 -0
  17. data/app/models/spree/state_decorator.rb +3 -0
  18. data/app/views/spree/address/_form.html.erb +86 -0
  19. data/app/views/spree/admin/shared/_address_form.html.erb +81 -0
  20. data/app/views/spree/api/counties/index.v1.rabl +11 -0
  21. data/app/views/spree/api/counties/show.v1.rabl +2 -0
  22. data/bin/rails +7 -0
  23. data/config/locales/en.yml +5 -0
  24. data/config/routes.rb +6 -0
  25. data/db/migrate/20140729200830_create_spree_counties.rb +10 -0
  26. data/db/migrate/20140729203900_add_spree_county_reference_to_spree_address.rb +5 -0
  27. data/db/migrate/20141119225426_add_county_name_to_spree_address.rb +5 -0
  28. data/lib/generators/spree_counties/install/install_generator.rb +41 -0
  29. data/lib/generators/spree_counties/install/templates/1.png +0 -0
  30. data/lib/generators/spree_counties/install/templates/2.png +0 -0
  31. data/lib/generators/spree_counties/install/templates/seeds/counties.rb +367 -0
  32. data/lib/spree_counties/engine.rb +20 -0
  33. data/lib/spree_counties/factories.rb +6 -0
  34. data/lib/spree_counties/version.rb +3 -0
  35. data/lib/spree_counties.rb +2 -0
  36. data/spec/spec_helper.rb +87 -0
  37. data/spree_counties.gemspec +32 -0
  38. metadata +43 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6c71b5a1f71f3baaaa9bd89bf0581bf6ff884f9
4
- data.tar.gz: d758c82e8636930aad7b75faacae6b47ea9e67e6
3
+ metadata.gz: 25881b248e39b2a67d0e8e546d40d5ffa03dda50
4
+ data.tar.gz: 1043627dba3248c68b9eb34c019681473c105aff
5
5
  SHA512:
6
- metadata.gz: 62e008d8600704d51b5b6d29c4ae9881023ee5f33d55024454e1c385bb6b52b34955c8c95dc1f4cfa7318c7a945175a94aa472a655bc8fc1335c2590ec1c6c0b
7
- data.tar.gz: 0af28e91675522fd0be407da2cc1b028241bb019289f5d78dc35af47e39f9b32872a89355fcdd1a4e0ec8eb127cab80d27f527a38bd609c1e972ddf2329fb1d8
6
+ metadata.gz: 4a92b03b687f26fc0da52e6a410d1336b786bfdc7dfe08ab24cc0bd6d316dd578615cf523992cd527a04d1edc8cdc8888f90c959cae1b2251c4a59fa97c77624
7
+ data.tar.gz: e4fd5d8c82a9fb6b573cb470f920075ed492f740fb1ac618de7014bda6f487b8b1fbabb477fb3d79476594decbda42de885a8b22a02daf447cbb7d2a4b1fb08f
data/.bundle/config ADDED
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_JOBS: 8
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ \#*
2
+ *~
3
+ .#*
4
+ .DS_Store
5
+ .idea
6
+ .project
7
+ .sass-cache
8
+ coverage
9
+ Gemfile.lock
10
+ tmp
11
+ nbproject
12
+ pkg
13
+ *.swp
14
+ spec/dummy
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'spree', github: 'spree/spree', branch: '2-3-stable'
4
+ # Provides basic authentication functionality for testing parts of your engine
5
+ gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-3-stable'
6
+
7
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Gonzalo Moreno
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ Spree Counties
2
+ =============
3
+
4
+ Lets your users pick counties from states list in address's step
5
+
6
+ ![alt tag](https://raw.githubusercontent.com/ronzalo/spree_counties/master/lib/generators/spree_counties/install/templates/1.png)
7
+
8
+ ![alt tag](https://raw.githubusercontent.com/ronzalo/spree_counties/master/lib/generators/spree_counties/install/templates/2.png)
9
+
10
+ Installation
11
+ ------------
12
+
13
+ Add spree_counties to your Gemfile:
14
+
15
+ ```ruby
16
+ gem 'spree_counties'
17
+ ```
18
+
19
+ Bundle your dependencies and run the installation generator:
20
+
21
+ ```shell
22
+ bundle
23
+ bundle exec rails g spree_counties:install
24
+ ```
25
+
26
+ Testing
27
+ -------
28
+
29
+ First bundle your dependencies, then run `rake`. `rake` will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using `rake test_app`.
30
+
31
+ ```shell
32
+ bundle
33
+ bundle exec rake
34
+ ```
35
+
36
+ When testing your applications integration with this extension you may use it's factories.
37
+ Simply add this require statement to your spec_helper:
38
+
39
+ ```ruby
40
+ require 'spree_counties/factories'
41
+ ```
42
+
43
+ Copyright (c) 2014 Gonzalo Moreno C, released under the New BSD License
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ require 'spree/testing_support/extension_rake'
6
+
7
+ RSpec::Core::RakeTask.new
8
+
9
+ task :default do
10
+ if Dir["spec/dummy"].empty?
11
+ Rake::Task[:test_app].invoke
12
+ Dir.chdir("../../")
13
+ end
14
+ Rake::Task[:spec].invoke
15
+ end
16
+
17
+ desc 'Generates a dummy app for testing'
18
+ task :test_app do
19
+ ENV['LIB_NAME'] = 'spree_counties'
20
+ Rake::Task['extension:test_app'].invoke
21
+ end
@@ -0,0 +1,30 @@
1
+ var update_county = function (region, done) {
2
+ 'use strict';
3
+
4
+ var state = $('span#' + region + 'state .select2').select2('val');
5
+ var county_select = $('span#' + region + 'county select.select2');
6
+
7
+ $.get('/api/counties?state_id=' + state, function (data) {
8
+ var counties = data.counties;
9
+ if (counties.length > 0) {
10
+ county_select.html('');
11
+ var counties_with_blank = [{
12
+ name: '',
13
+ id: ''
14
+ }].concat(counties);
15
+ $.each(counties_with_blank, function (pos, county) {
16
+ var opt = $(document.createElement('option'))
17
+ .prop('value', state.id)
18
+ .html(county.name);
19
+ county_select.append(opt);
20
+ });
21
+ county_select.prop('disabled', false).show();
22
+ county_select.select2();
23
+
24
+ } else {
25
+ county_select.select2('destroy').hide();
26
+ }
27
+
28
+ if(done) done();
29
+ });
30
+ };
@@ -0,0 +1,58 @@
1
+ Spree.ready ($) ->
2
+ ($ '#bstate select').change ->
3
+ updateCounty 'b'
4
+
5
+ ($ '#sstate select').change ->
6
+ updateCounty 's'
7
+
8
+ updateCounty = (region) ->
9
+ stateId = getStateId(region)
10
+ if stateId?
11
+ $.get '/api/counties', {state_id: stateId}, (data) ->
12
+ Spree.Checkout[stateId] =
13
+ counties: data.counties
14
+ fillCounties(Spree.Checkout[stateId], region)
15
+
16
+ getStateId = (region) ->
17
+ $('#' + region + 'state select').val()
18
+
19
+ fillCounties = (data, region) ->
20
+ countiesRequired = true
21
+ counties = data.counties
22
+
23
+ countyPara = ($ '#' + region + 'county')
24
+ countySelect = countyPara.find('select')
25
+ countyInput = countyPara.find('input')
26
+ countySpanRequired = countyPara.find('county-required')
27
+ if counties.length > 0
28
+ selected = parseInt countySelect.val()
29
+ countySelect.html ''
30
+ countyWithBlank = [{ name: '', id: ''}].concat(counties)
31
+ $.each countyWithBlank, (idx, county) ->
32
+ opt = ($ document.createElement('option')).attr('value', county.id).html(county.name)
33
+ opt.prop 'selected', true if selected is county.id
34
+ countySelect.append opt
35
+
36
+ countySelect.prop('disabled', false).show()
37
+ countyInput.hide().prop 'disabled', true
38
+ countyPara.show()
39
+ countySpanRequired.show()
40
+ countySelect.addClass('required') if countiesRequired
41
+ countySelect.removeClass('hidden')
42
+ countyInput.removeClass('required')
43
+ else
44
+ countySelect.hide().prop 'disabled', true
45
+ countyInput.show()
46
+ if countiesRequired
47
+ countySpanRequired.show()
48
+ countyInput.addClass('required')
49
+ else
50
+ countyInput.val ''
51
+ countySpanRequired.hide()
52
+ countyInput.removeClass('required')
53
+ countyPara.toggle(!!countiesRequired)
54
+ countyInput.prop('disabled', !countiesRequired)
55
+ countyInput.removeClass('hidden')
56
+ countySelect.removeClass('required')
57
+
58
+ updateCounty 'b'
@@ -0,0 +1,4 @@
1
+ /*
2
+ Placeholder manifest file.
3
+ the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/backend/all.css'
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Placeholder manifest file.
3
+ the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/frontend/all.css'
4
+ */
@@ -0,0 +1,38 @@
1
+ module Spree
2
+ module Api
3
+ class CountiesController < Spree::Api::BaseController
4
+ skip_before_filter :set_expiry
5
+ skip_before_filter :check_for_user_or_api_key
6
+ skip_before_filter :authenticate_user
7
+
8
+ def index
9
+ @counties = scope.ransack(params[:q]).result.
10
+ includes(:state).order('name ASC')
11
+
12
+ if params[:page] || params[:per_page]
13
+ @counties = @counties.page(params[:page]).per(params[:per_page])
14
+ end
15
+
16
+ county = @counties.last
17
+ if stale?(county)
18
+ respond_with(@counties)
19
+ end
20
+ end
21
+
22
+ def show
23
+ @county = scope.find(params[:id])
24
+ respond_with(@county)
25
+ end
26
+
27
+ private
28
+ def scope
29
+ if params[:state_id]
30
+ @state = Spree::State.accessible_by(current_ability, :read).find(params[:state_id])
31
+ return @state.counties.accessible_by(current_ability, :read)
32
+ else
33
+ return Spree::County.accessible_by(current_ability, :read)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,10 @@
1
+ class CountyAbility
2
+ include CanCan::Ability
3
+
4
+ def initialize(user)
5
+ user ||= Spree::User.new
6
+ unless user.has_spree_role? 'admin'
7
+ can [:index, :read], Spree::County
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ module Spree
2
+ Address.class_eval do
3
+ belongs_to :county, class_name: "Spree::County"
4
+ Spree::PermittedAttributes.address_attributes << :county_id
5
+ Spree::PermittedAttributes.address_attributes << :county_name
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ class Spree::County < ActiveRecord::Base
2
+ belongs_to :state
3
+ has_many :addresses, dependent: :nullify
4
+ Spree::Ability.register_ability(CountyAbility)
5
+
6
+ def <=>(other)
7
+ name <=> other.name
8
+ end
9
+
10
+ def to_s
11
+ name
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ Spree::State.class_eval do
2
+ has_many :counties, -> { order('name ASC') }, dependent: :destroy
3
+ end
@@ -0,0 +1,86 @@
1
+ <% address_id = address_type.chars.first %>
2
+ <div class="inner" data-hook=<%="#{address_type}_inner" %>>
3
+ <p class="field" id=<%="#{address_id}firstname" %>>
4
+ <%= form.label :firstname, Spree.t(:first_name) %><span class="required">*</span><br />
5
+ <%= form.text_field :firstname, :class => 'required' %>
6
+ </p>
7
+ <p class="field" id=<%="#{address_id}lastname" %>>
8
+ <%= form.label :lastname, Spree.t(:last_name) %><span class="required">*</span><br />
9
+ <%= form.text_field :lastname, :class => 'required' %>
10
+ </p>
11
+ <% if Spree::Config[:company] %>
12
+ <p class="field" id=<%="#{address_id}company" %>>
13
+ <%= form.label :company, Spree.t(:company) %><br />
14
+ <%= form.text_field :company %>
15
+ </p>
16
+ <% end %>
17
+ <p class="field" id=<%="#{address_id}address1" %>>
18
+ <%= form.label :address1, Spree.t(:street_address) %><span class="required">*</span><br />
19
+ <%= form.text_field :address1, :class => 'required' %>
20
+ </p>
21
+ <p class="field" id=<%="#{address_id}address2" %>>
22
+ <%= form.label :address2, Spree.t(:street_address_2) %><br />
23
+ <%= form.text_field :address2 %>
24
+ </p>
25
+ <p class="field" id=<%="#{address_id}city" %>>
26
+ <%= form.label :city, Spree.t(:city) %><span class="required">*</span><br />
27
+ <%= form.text_field :city, :class => 'required' %>
28
+ </p>
29
+ <p class="field" id=<%="#{address_id}country" %>>
30
+ <%= form.label :country_id, Spree.t(:country) %><span class="required">*</span><br />
31
+ <span id=<%="#{address_id}country-selection" %>>
32
+ <%= form.collection_select :country_id, available_countries, :id, :name, {}, {:class => 'required'} %>
33
+ </span>
34
+ </p>
35
+
36
+ <% if Spree::Config[:address_requires_state] %>
37
+ <p class="field" id=<%="#{address_id}state" %>>
38
+ <% have_states = !address.country.states.empty? %>
39
+ <%= form.label :state, Spree.t(:state) %><span class='required' id=<%="#{address_id}state-required"%>>*</span><br/>
40
+
41
+ <% state_elements = [
42
+ form.collection_select(:state_id, address.country.states,
43
+ :id, :name,
44
+ {:include_blank => true},
45
+ {:class => have_states ? 'required' : 'hidden',
46
+ :disabled => !have_states}) +
47
+ form.text_field(:state_name,
48
+ :class => !have_states ? 'required' : 'hidden',
49
+ :disabled => have_states)
50
+ ].join.gsub('"', "'").gsub("\n", "")
51
+ %>
52
+ <%= javascript_tag do -%>
53
+ $('#<%="#{address_id}state" %>').append("<%== state_elements %>");
54
+ <% end %>
55
+ </p>
56
+ <noscript>
57
+ <%= form.text_field :state_name, :class => 'required' %>
58
+ </noscript>
59
+
60
+ <p class="field" id=<%="#{address_id}county" %>>
61
+ <%= form.label :county do %>
62
+ <%= Spree.t(:county) %>
63
+ <span class="required" id=<%="#{address_id}county-required"%>>*</span>
64
+ <% end %>
65
+ <%= form.collection_select(:county_id, [],
66
+ :id, :name,
67
+ {:include_blank => true},
68
+ {:class => "form-control required",}) %>
69
+ </p>
70
+ <% end %>
71
+
72
+ <p class="field" id=<%="#{address_id}zipcode" %>>
73
+ <%= form.label :zipcode, Spree.t(:zip) %><% if address.require_zipcode? %><span class="required">*</span><br /><% end %>
74
+ <%= form.text_field :zipcode, :class => "#{'required' if address.require_zipcode?}" %>
75
+ </p>
76
+ <p class="field" id=<%="#{address_id}phone" %>>
77
+ <%= form.label :phone, Spree.t(:phone) %><% if address.require_phone? %><span class="required">*</span><br /><% end %>
78
+ <%= form.phone_field :phone, :class => "#{'required' if address.require_phone?}" %>
79
+ </p>
80
+ <% if Spree::Config[:alternative_shipping_phone] %>
81
+ <p class="field" id=<%="#{address_id}altphone" %>>
82
+ <%= form.label :alternative_phone, Spree.t(:alternative_phone) %><br />
83
+ <%= form.phone_field :alternative_phone %>
84
+ </p>
85
+ <% end %>
86
+ </div>
@@ -0,0 +1,81 @@
1
+ <% s_or_b = type.chars.first %>
2
+
3
+ <div id="<%= type %>" data-hook="address_fields">
4
+ <div class="field <%= "#{type}-row" %>">
5
+ <%= f.label :firstname, Spree.t(:first_name) %>
6
+ <%= f.text_field :firstname, :class => 'fullwidth' %>
7
+ </div>
8
+
9
+ <div class="field <%= "#{type}-row" %>">
10
+ <%= f.label :lastname, Spree.t(:last_name) %>
11
+ <%= f.text_field :lastname, :class => 'fullwidth' %>
12
+ </div>
13
+
14
+ <% if Spree::Config[:company] %>
15
+ <div class="field <%= "#{type}-row" %>">
16
+ <%= f.label :company, Spree.t(:company) %>
17
+ <%= f.text_field :company, :class => 'fullwidth' %>
18
+ </div>
19
+ <% end %>
20
+
21
+ <div class="field <%= "#{type}-row" %>">
22
+ <%= f.label :address1, Spree.t(:street_address) %>
23
+ <%= f.text_field :address1, :class => 'fullwidth' %>
24
+ </div>
25
+
26
+ <div class="field <%= "#{type}-row" %>">
27
+ <%= f.label :address2, Spree.t(:street_address_2) %>
28
+ <%= f.text_field :address2, :class => 'fullwidth' %>
29
+ </div>
30
+
31
+ <div class="field <%= "#{type}-row" %>">
32
+ <%= f.label :city, Spree.t(:city) %>
33
+ <%= f.text_field :city, :class => 'fullwidth' %>
34
+ </div>
35
+
36
+ <div class="field <%= "#{type}-row" %>">
37
+ <%= f.label :zipcode, Spree.t(:zip) %>
38
+ <%= f.text_field :zipcode, :class => 'fullwidth' %>
39
+ </div>
40
+
41
+ <div class="field <%= "#{type}-row" %>">
42
+ <%= f.label :country_id, Spree.t(:country) %>
43
+ <span id="<%= s_or_b %>country">
44
+ <%= f.collection_select :country_id, available_countries, :id, :name, {}, {:class => 'select2 fullwidth'} %>
45
+ </span>
46
+ </div>
47
+
48
+ <div class="field <%= "#{type}-row" %>">
49
+ <%= f.label :state_id, Spree.t(:state) %>
50
+ <span id="<%= s_or_b %>state">
51
+ <%= f.text_field :state_name,
52
+ :style => "display: #{f.object.country.states.empty? ? 'block' : 'none' };",
53
+ :disabled => !f.object.country.states.empty?, :class => 'fullwidth state_name' %>
54
+ <%= f.collection_select :state_id, f.object.country.states.sort, :id, :name, {:include_blank => true}, {:class => 'select2 fullwidth', :style => "display: #{f.object.country.states.empty? ? 'none' : 'block' };", :disabled => f.object.country.states.empty?} %>
55
+ </span>
56
+ </div>
57
+
58
+ <div class="field <%= "#{type}-row" %>">
59
+ <%= f.label :county_id, Spree.t(:county) %>
60
+ <span id="<%= s_or_b %>county">
61
+ <%= f.text_field :county_name,
62
+ :style => "display: #{f.object.state.counties.empty? ? 'block' : 'none' };",
63
+ :disabled => !f.object.state.counties.empty?, :class => 'fullwidth county_name' %>
64
+ <%= f.collection_select :county_id, f.object.state.counties.sort, :id, :name, {:include_blank => true}, {:class => 'select2 fullwidth', :style => "display: #{f.object.state.counties.empty? ? 'none' : 'block' };", :disabled => f.object.state.counties.empty?} %>
65
+ </span>
66
+ </div>
67
+
68
+ <div class="field <%= "#{type}-row" %>">
69
+ <%= f.label :phone, Spree.t(:phone) %>
70
+ <%= f.phone_field :phone, :class => 'fullwidth' %>
71
+ </div>
72
+ </div>
73
+
74
+ <% content_for :head do %>
75
+ <%= javascript_tag do -%>
76
+ $(document).ready(function(){
77
+ $('span#<%= s_or_b %>country .select2').on('change', function() { update_state('<%= s_or_b %>'); });
78
+ $('span#<%= s_or_b %>state .select2').on('change', function() { update_county('<%= s_or_b %>'); });
79
+ });
80
+ <% end -%>
81
+ <% end %>
@@ -0,0 +1,11 @@
1
+ object false
2
+
3
+ child(@counties => :counties) do
4
+ attributes :id, :name
5
+ end
6
+
7
+ if @counties.respond_to?(:num_pages)
8
+ node(:count) { @counties.count }
9
+ node(:current_page) { params[:page] || 1 }
10
+ node(:pages) { @counties.num_pages }
11
+ end
@@ -0,0 +1,2 @@
1
+ object @county
2
+ attributes :id, :name
data/bin/rails ADDED
@@ -0,0 +1,7 @@
1
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
2
+
3
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
4
+ ENGINE_PATH = File.expand_path('../../lib/spree_counties/engine', __FILE__)
5
+
6
+ require 'rails/all'
7
+ require 'rails/engine/commands'
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
data/config/routes.rb ADDED
@@ -0,0 +1,6 @@
1
+ Spree::Core::Engine.routes.draw do
2
+ # Add your extension routes here
3
+ namespace :api, :defaults => { :format => 'json' } do
4
+ resources :counties, :only => [:index, :show]
5
+ end
6
+ end
@@ -0,0 +1,10 @@
1
+ class CreateSpreeCounties < ActiveRecord::Migration
2
+ def change
3
+ create_table :spree_counties do |t|
4
+ t.string :name
5
+ t.references :state, index: true
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ class AddSpreeCountyReferenceToSpreeAddress < ActiveRecord::Migration
2
+ def change
3
+ add_reference :spree_addresses, :county, index: true
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddCountyNameToSpreeAddress < ActiveRecord::Migration
2
+ def change
3
+ add_column :spree_addresses, :county_name, :string
4
+ end
5
+ end
@@ -0,0 +1,41 @@
1
+ module SpreeCounties
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../templates", __FILE__)
5
+ class_option :auto_run_migrations, :type => :boolean, :default => false
6
+
7
+ def add_javascripts
8
+ append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/spree_counties\n"
9
+ append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/spree_counties\n"
10
+ end
11
+
12
+ def add_stylesheets
13
+ inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/spree_counties\n", :before => /\*\//, :verbose => true
14
+ inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/spree_counties\n", :before => /\*\//, :verbose => true
15
+ end
16
+
17
+ def add_migrations
18
+ run 'bundle exec rake railties:install:migrations FROM=spree_counties'
19
+ end
20
+
21
+ def run_seeds
22
+ run_seeds = options[:auto_run_seeds] || ['', 'y', 'Y'].include?(ask 'Would you like to load chilean example seeds now? [Y/n]')
23
+ if run_seeds
24
+ copy_file "seeds/counties.rb", "db/seeds/counties.rb"
25
+ run 'bundle exec rails runner db/seeds/counties.rb'
26
+ else
27
+ puts 'Skipping bundle exec rails runner, don\'t forget to run it!'
28
+ end
29
+ end
30
+
31
+ def run_migrations
32
+ run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
33
+ if run_migrations
34
+ run 'bundle exec rake db:migrate'
35
+ else
36
+ puts 'Skipping rake db:migrate, don\'t forget to run it!'
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,367 @@
1
+ # encoding: utf-8
2
+
3
+ country = Spree::Country.find_or_create_by name:'Chile', iso_name: "CHILE", iso: "CL", iso3: "CHL", numcode: 152, states_required: false
4
+
5
+ #Chilean states
6
+ xi = Spree::State.find_or_create_by name: 'Aysén del General Carlos Ibanez', abbr: 'AI', country: country
7
+ ii = Spree::State.find_or_create_by name: 'Antofagasta', abbr: 'AN', country: country
8
+ ix = Spree::State.find_or_create_by name: 'Araucanía', abbr: 'AR', country: country
9
+ xv = Spree::State.find_or_create_by name: 'Arica y Parinacota', abbr: 'AP', country: country
10
+ iii = Spree::State.find_or_create_by name: 'Atacama', abbr: 'AT', country: country
11
+ viii = Spree::State.find_or_create_by name: 'Bio-Bío', abbr: 'BI', country: country
12
+ iv = Spree::State.find_or_create_by name: 'Coquimbo', abbr: 'CO', country: country
13
+ vi = Spree::State.find_or_create_by name: 'Libertador General Bernardo O\'Higgins', abbr: 'LI', country: country
14
+ x = Spree::State.find_or_create_by name: 'Los Lagos', abbr: 'LL', country: country
15
+ xii = Spree::State.find_or_create_by name: 'Magallanes y de la Antártica Chilena', abbr: 'MA', country: country
16
+ vii = Spree::State.find_or_create_by name: 'Maule', abbr: 'ML', country: country
17
+ rm = Spree::State.find_or_create_by name: 'Metropolitana', abbr: 'RM', country: country
18
+ xiv = Spree::State.find_or_create_by name: 'Los Ríos', abbr: 'LR', country: country
19
+ i = Spree::State.find_or_create_by name: 'Tarapacá', abbr: 'TA', country: country
20
+ v = Spree::State.find_or_create_by name: 'Valparaíso', abbr: 'VS', country: country
21
+
22
+ Spree::County.find_or_create_by(name: 'Arica', state: xv)
23
+ Spree::County.find_or_create_by(name: 'Camarones', state: xv)
24
+ Spree::County.find_or_create_by(name: 'Putre', state: xv)
25
+ Spree::County.find_or_create_by(name: 'General Lagos', state: xv)
26
+ Spree::County.find_or_create_by(name: 'Iquique', state: i)
27
+ Spree::County.find_or_create_by(name: 'Alto Hospicio', state: i)
28
+ Spree::County.find_or_create_by(name: 'Pozo Almonte', state: i)
29
+ Spree::County.find_or_create_by(name: 'Camiña', state: i)
30
+ Spree::County.find_or_create_by(name: 'Colchane', state: i)
31
+ Spree::County.find_or_create_by(name: 'Huara', state: i)
32
+ Spree::County.find_or_create_by(name: 'Pica', state: i)
33
+ Spree::County.find_or_create_by(name: 'Antofagasta', state: ii)
34
+ Spree::County.find_or_create_by(name: 'Mejillones', state: ii)
35
+ Spree::County.find_or_create_by(name: 'Sierra Gorda', state: ii)
36
+ Spree::County.find_or_create_by(name: 'Taltal', state: ii)
37
+ Spree::County.find_or_create_by(name: 'Calama', state: ii)
38
+ Spree::County.find_or_create_by(name: 'Ollagüe', state: ii)
39
+ Spree::County.find_or_create_by(name: 'San Pedro de Atacama', state: ii)
40
+ Spree::County.find_or_create_by(name: 'Tocopilla', state: ii)
41
+ Spree::County.find_or_create_by(name: 'María Elena', state: ii)
42
+ Spree::County.find_or_create_by(name: 'Copiapó', state: iii)
43
+ Spree::County.find_or_create_by(name: 'Caldera', state: iii)
44
+ Spree::County.find_or_create_by(name: 'Tierra Amarilla', state: iii)
45
+ Spree::County.find_or_create_by(name: 'Chañaral', state: iii)
46
+ Spree::County.find_or_create_by(name: 'Diego de Almagro', state: iii)
47
+ Spree::County.find_or_create_by(name: 'Vallenar', state: iii)
48
+ Spree::County.find_or_create_by(name: 'Alto del Carmen', state: iii)
49
+ Spree::County.find_or_create_by(name: 'Freirina', state: iii)
50
+ Spree::County.find_or_create_by(name: 'Huasco', state: iii)
51
+ Spree::County.find_or_create_by(name: 'La Serena', state: iv)
52
+ Spree::County.find_or_create_by(name: 'Coquimbo', state: iv)
53
+ Spree::County.find_or_create_by(name: 'Andacollo', state: iv)
54
+ Spree::County.find_or_create_by(name: 'La Higuera', state: iv)
55
+ Spree::County.find_or_create_by(name: 'Paiguano', state: iv)
56
+ Spree::County.find_or_create_by(name: 'Vicuña', state: iv)
57
+ Spree::County.find_or_create_by(name: 'Illapel', state: iv)
58
+ Spree::County.find_or_create_by(name: 'Canela', state: iv)
59
+ Spree::County.find_or_create_by(name: 'Los Vilos', state: iv)
60
+ Spree::County.find_or_create_by(name: 'Salamanca', state: iv)
61
+ Spree::County.find_or_create_by(name: 'Ovalle', state: iv)
62
+ Spree::County.find_or_create_by(name: 'Combarbalá', state: iv)
63
+ Spree::County.find_or_create_by(name: 'Monte Patria', state: iv)
64
+ Spree::County.find_or_create_by(name: 'Punitaqui', state: iv)
65
+ Spree::County.find_or_create_by(name: 'Río Hurtado', state: iv)
66
+ Spree::County.find_or_create_by(name: 'Valparaíso', state: v)
67
+ Spree::County.find_or_create_by(name: 'Casablanca', state: v)
68
+ Spree::County.find_or_create_by(name: 'Concón', state: v)
69
+ Spree::County.find_or_create_by(name: 'Juan Fernández', state: v)
70
+ Spree::County.find_or_create_by(name: 'Puchuncaví', state: v)
71
+ Spree::County.find_or_create_by(name: 'Quintero', state: v)
72
+ Spree::County.find_or_create_by(name: 'Viña del Mar', state: v)
73
+ Spree::County.find_or_create_by(name: 'Isla de Pascua', state: v)
74
+ Spree::County.find_or_create_by(name: 'Los Andes', state: v)
75
+ Spree::County.find_or_create_by(name: 'Calle Larga', state: v)
76
+ Spree::County.find_or_create_by(name: 'Rinconada', state: v)
77
+ Spree::County.find_or_create_by(name: 'San Esteban', state: v)
78
+ Spree::County.find_or_create_by(name: 'La Ligua', state: v)
79
+ Spree::County.find_or_create_by(name: 'Cabildo', state: v)
80
+ Spree::County.find_or_create_by(name: 'Papudo', state: v)
81
+ Spree::County.find_or_create_by(name: 'Petorca', state: v)
82
+ Spree::County.find_or_create_by(name: 'Zapallar', state: v)
83
+ Spree::County.find_or_create_by(name: 'Quillota', state: v)
84
+ Spree::County.find_or_create_by(name: 'Calera', state: v)
85
+ Spree::County.find_or_create_by(name: 'Hijuelas', state: v)
86
+ Spree::County.find_or_create_by(name: 'La Cruz', state: v)
87
+ Spree::County.find_or_create_by(name: 'Nogales', state: v)
88
+ Spree::County.find_or_create_by(name: 'San Antonio', state: v)
89
+ Spree::County.find_or_create_by(name: 'Algarrobo', state: v)
90
+ Spree::County.find_or_create_by(name: 'Cartagena', state: v)
91
+ Spree::County.find_or_create_by(name: 'El Quisco', state: v)
92
+ Spree::County.find_or_create_by(name: 'El Tabo', state: v)
93
+ Spree::County.find_or_create_by(name: 'Santo Domingo', state: v)
94
+ Spree::County.find_or_create_by(name: 'San Felipe', state: v)
95
+ Spree::County.find_or_create_by(name: 'Catemu', state: v)
96
+ Spree::County.find_or_create_by(name: 'Llaillay', state: v)
97
+ Spree::County.find_or_create_by(name: 'Panquehue', state: v)
98
+ Spree::County.find_or_create_by(name: 'Putaendo', state: v)
99
+ Spree::County.find_or_create_by(name: 'Santa María', state: v)
100
+ Spree::County.find_or_create_by(name: 'Limache', state: v)
101
+ Spree::County.find_or_create_by(name: 'Quilpué', state: v)
102
+ Spree::County.find_or_create_by(name: 'Villa Alemana', state: v)
103
+ Spree::County.find_or_create_by(name: 'Olmué', state: v)
104
+ Spree::County.find_or_create_by(name: 'Rancagua', state: vi)
105
+ Spree::County.find_or_create_by(name: 'Codegua', state: vi)
106
+ Spree::County.find_or_create_by(name: 'Coinco', state: vi)
107
+ Spree::County.find_or_create_by(name: 'Coltauco', state: vi)
108
+ Spree::County.find_or_create_by(name: 'Doñihue', state: vi)
109
+ Spree::County.find_or_create_by(name: 'Graneros', state: vi)
110
+ Spree::County.find_or_create_by(name: 'Las Cabras', state: vi)
111
+ Spree::County.find_or_create_by(name: 'Machalí', state: vi)
112
+ Spree::County.find_or_create_by(name: 'Malloa', state: vi)
113
+ Spree::County.find_or_create_by(name: 'Mostazal', state: vi)
114
+ Spree::County.find_or_create_by(name: 'Olivar', state: vi)
115
+ Spree::County.find_or_create_by(name: 'Peumo', state: vi)
116
+ Spree::County.find_or_create_by(name: 'Pichidegua', state: vi)
117
+ Spree::County.find_or_create_by(name: 'Quinta de Tilcoco', state: vi)
118
+ Spree::County.find_or_create_by(name: 'Rengo', state: vi)
119
+ Spree::County.find_or_create_by(name: 'Requínoa', state: vi)
120
+ Spree::County.find_or_create_by(name: 'San Vicente', state: vi)
121
+ Spree::County.find_or_create_by(name: 'Pichilemu', state: vi)
122
+ Spree::County.find_or_create_by(name: 'La Estrella', state: vi)
123
+ Spree::County.find_or_create_by(name: 'Litueche', state: vi)
124
+ Spree::County.find_or_create_by(name: 'Marchihue', state: vi)
125
+ Spree::County.find_or_create_by(name: 'Navidad', state: vi)
126
+ Spree::County.find_or_create_by(name: 'Paredones', state: vi)
127
+ Spree::County.find_or_create_by(name: 'San Fernando', state: vi)
128
+ Spree::County.find_or_create_by(name: 'Chépica', state: vi)
129
+ Spree::County.find_or_create_by(name: 'Chimbarongo', state: vi)
130
+ Spree::County.find_or_create_by(name: 'Lolol', state: vi)
131
+ Spree::County.find_or_create_by(name: 'Nancagua', state: vi)
132
+ Spree::County.find_or_create_by(name: 'Palmilla', state: vi)
133
+ Spree::County.find_or_create_by(name: 'Peralillo', state: vi)
134
+ Spree::County.find_or_create_by(name: 'Placilla', state: vi)
135
+ Spree::County.find_or_create_by(name: 'Pumanque', state: vi)
136
+ Spree::County.find_or_create_by(name: 'Santa Cruz', state: vi)
137
+ Spree::County.find_or_create_by(name: 'Talca', state: vii)
138
+ Spree::County.find_or_create_by(name: 'Constitución', state: vii)
139
+ Spree::County.find_or_create_by(name: 'Curepto', state: vii)
140
+ Spree::County.find_or_create_by(name: 'Empedrado', state: vii)
141
+ Spree::County.find_or_create_by(name: 'Maule', state: vii)
142
+ Spree::County.find_or_create_by(name: 'Pelarco', state: vii)
143
+ Spree::County.find_or_create_by(name: 'Pencahue', state: vii)
144
+ Spree::County.find_or_create_by(name: 'Río Claro', state: vii)
145
+ Spree::County.find_or_create_by(name: 'San Clemente', state: vii)
146
+ Spree::County.find_or_create_by(name: 'San Rafael', state: vii)
147
+ Spree::County.find_or_create_by(name: 'Cauquenes', state: vii)
148
+ Spree::County.find_or_create_by(name: 'Chanco', state: vii)
149
+ Spree::County.find_or_create_by(name: 'Pelluhue', state: vii)
150
+ Spree::County.find_or_create_by(name: 'Curicó', state: vii)
151
+ Spree::County.find_or_create_by(name: 'Hualañé', state: vii)
152
+ Spree::County.find_or_create_by(name: 'Licantén', state: vii)
153
+ Spree::County.find_or_create_by(name: 'Molina', state: vii)
154
+ Spree::County.find_or_create_by(name: 'Rauco', state: vii)
155
+ Spree::County.find_or_create_by(name: 'Romeral', state: vii)
156
+ Spree::County.find_or_create_by(name: 'Sagrada Familia', state: vii)
157
+ Spree::County.find_or_create_by(name: 'Teno', state: vii)
158
+ Spree::County.find_or_create_by(name: 'Vichuquén', state: vii)
159
+ Spree::County.find_or_create_by(name: 'Linares', state: vii)
160
+ Spree::County.find_or_create_by(name: 'Colbún', state: vii)
161
+ Spree::County.find_or_create_by(name: 'Longaví', state: vii)
162
+ Spree::County.find_or_create_by(name: 'Parral', state: vii)
163
+ Spree::County.find_or_create_by(name: 'Retiro', state: vii)
164
+ Spree::County.find_or_create_by(name: 'San Javier', state: vii)
165
+ Spree::County.find_or_create_by(name: 'Villa Alegre', state: vii)
166
+ Spree::County.find_or_create_by(name: 'Yerbas Buenas', state: vii)
167
+ Spree::County.find_or_create_by(name: 'Concepción', state: viii)
168
+ Spree::County.find_or_create_by(name: 'Coronel', state: viii)
169
+ Spree::County.find_or_create_by(name: 'Chiguayante', state: viii)
170
+ Spree::County.find_or_create_by(name: 'Florida', state: viii)
171
+ Spree::County.find_or_create_by(name: 'Hualqui', state: viii)
172
+ Spree::County.find_or_create_by(name: 'Lota', state: viii)
173
+ Spree::County.find_or_create_by(name: 'Penco', state: viii)
174
+ Spree::County.find_or_create_by(name: 'San Pedro de la Paz', state: viii)
175
+ Spree::County.find_or_create_by(name: 'Santa Juana', state: viii)
176
+ Spree::County.find_or_create_by(name: 'Talcahuano', state: viii)
177
+ Spree::County.find_or_create_by(name: 'Tomé', state: viii)
178
+ Spree::County.find_or_create_by(name: 'Hualpén', state: viii)
179
+ Spree::County.find_or_create_by(name: 'Lebu', state: viii)
180
+ Spree::County.find_or_create_by(name: 'Arauco', state: viii)
181
+ Spree::County.find_or_create_by(name: 'Cañete', state: viii)
182
+ Spree::County.find_or_create_by(name: 'Contulmo', state: viii)
183
+ Spree::County.find_or_create_by(name: 'Curanilahue', state: viii)
184
+ Spree::County.find_or_create_by(name: 'Los Alamos', state: viii)
185
+ Spree::County.find_or_create_by(name: 'Tirúa', state: viii)
186
+ Spree::County.find_or_create_by(name: 'Los Angeles', state: viii)
187
+ Spree::County.find_or_create_by(name: 'Antuco', state: viii)
188
+ Spree::County.find_or_create_by(name: 'Cabrero', state: viii)
189
+ Spree::County.find_or_create_by(name: 'Laja', state: viii)
190
+ Spree::County.find_or_create_by(name: 'Mulchén', state: viii)
191
+ Spree::County.find_or_create_by(name: 'Nacimiento', state: viii)
192
+ Spree::County.find_or_create_by(name: 'Negrete', state: viii)
193
+ Spree::County.find_or_create_by(name: 'Quilaco', state: viii)
194
+ Spree::County.find_or_create_by(name: 'Quilleco', state: viii)
195
+ Spree::County.find_or_create_by(name: 'San Rosendo', state: viii)
196
+ Spree::County.find_or_create_by(name: 'Santa Bárbara', state: viii)
197
+ Spree::County.find_or_create_by(name: 'Tucapel', state: viii)
198
+ Spree::County.find_or_create_by(name: 'Yumbel', state: viii)
199
+ Spree::County.find_or_create_by(name: 'Alto Biobío', state: viii)
200
+ Spree::County.find_or_create_by(name: 'Chillán', state: viii)
201
+ Spree::County.find_or_create_by(name: 'Bulnes', state: viii)
202
+ Spree::County.find_or_create_by(name: 'Cobquecura', state: viii)
203
+ Spree::County.find_or_create_by(name: 'Coelemu', state: viii)
204
+ Spree::County.find_or_create_by(name: 'Coihueco', state: viii)
205
+ Spree::County.find_or_create_by(name: 'Chillán Viejo', state: viii)
206
+ Spree::County.find_or_create_by(name: 'El Carmen', state: viii)
207
+ Spree::County.find_or_create_by(name: 'Ninhue', state: viii)
208
+ Spree::County.find_or_create_by(name: 'Ñiquén', state: viii)
209
+ Spree::County.find_or_create_by(name: 'Pemuco', state: viii)
210
+ Spree::County.find_or_create_by(name: 'Pinto', state: viii)
211
+ Spree::County.find_or_create_by(name: 'Portezuelo', state: viii)
212
+ Spree::County.find_or_create_by(name: 'Quillón', state: viii)
213
+ Spree::County.find_or_create_by(name: 'Quirihue', state: viii)
214
+ Spree::County.find_or_create_by(name: 'Ránquil', state: viii)
215
+ Spree::County.find_or_create_by(name: 'San Carlos', state: viii)
216
+ Spree::County.find_or_create_by(name: 'San Fabián', state: viii)
217
+ Spree::County.find_or_create_by(name: 'San Ignacio', state: viii)
218
+ Spree::County.find_or_create_by(name: 'San Nicolás', state: viii)
219
+ Spree::County.find_or_create_by(name: 'Treguaco', state: viii)
220
+ Spree::County.find_or_create_by(name: 'Yungay', state: viii)
221
+ Spree::County.find_or_create_by(name: 'Temuco', state: ix)
222
+ Spree::County.find_or_create_by(name: 'Carahue', state: ix)
223
+ Spree::County.find_or_create_by(name: 'Cunco', state: ix)
224
+ Spree::County.find_or_create_by(name: 'Curarrehue', state: ix)
225
+ Spree::County.find_or_create_by(name: 'Freire', state: ix)
226
+ Spree::County.find_or_create_by(name: 'Galvarino', state: ix)
227
+ Spree::County.find_or_create_by(name: 'Gorbea', state: ix)
228
+ Spree::County.find_or_create_by(name: 'Lautaro', state: ix)
229
+ Spree::County.find_or_create_by(name: 'Loncoche', state: ix)
230
+ Spree::County.find_or_create_by(name: 'Melipeuco', state: ix)
231
+ Spree::County.find_or_create_by(name: 'Nueva Imperial', state: ix)
232
+ Spree::County.find_or_create_by(name: 'Padre Las Casas', state: ix)
233
+ Spree::County.find_or_create_by(name: 'Perquenco', state: ix)
234
+ Spree::County.find_or_create_by(name: 'Pitrufquén', state: ix)
235
+ Spree::County.find_or_create_by(name: 'Pucón', state: ix)
236
+ Spree::County.find_or_create_by(name: 'Saavedra', state: ix)
237
+ Spree::County.find_or_create_by(name: 'Teodoro Schmidt', state: ix)
238
+ Spree::County.find_or_create_by(name: 'Toltén', state: ix)
239
+ Spree::County.find_or_create_by(name: 'Vilcún', state: ix)
240
+ Spree::County.find_or_create_by(name: 'Villarrica', state: ix)
241
+ Spree::County.find_or_create_by(name: 'Cholchol', state: ix)
242
+ Spree::County.find_or_create_by(name: 'Angol', state: ix)
243
+ Spree::County.find_or_create_by(name: 'Collipulli', state: ix)
244
+ Spree::County.find_or_create_by(name: 'Curacautín', state: ix)
245
+ Spree::County.find_or_create_by(name: 'Ercilla', state: ix)
246
+ Spree::County.find_or_create_by(name: 'Lonquimay', state: ix)
247
+ Spree::County.find_or_create_by(name: 'Los Sauces', state: ix)
248
+ Spree::County.find_or_create_by(name: 'Lumaco', state: ix)
249
+ Spree::County.find_or_create_by(name: 'Purén', state: ix)
250
+ Spree::County.find_or_create_by(name: 'Renaico', state: ix)
251
+ Spree::County.find_or_create_by(name: 'Traiguén', state: ix)
252
+ Spree::County.find_or_create_by(name: 'Victoria', state: ix)
253
+ Spree::County.find_or_create_by(name: 'Valdivia', state: xiv)
254
+ Spree::County.find_or_create_by(name: 'Corral', state: xiv)
255
+ Spree::County.find_or_create_by(name: 'Lanco', state: xiv)
256
+ Spree::County.find_or_create_by(name: 'Los Lagos', state: xiv)
257
+ Spree::County.find_or_create_by(name: 'Máfil', state: xiv)
258
+ Spree::County.find_or_create_by(name: 'Mariquina', state: xiv)
259
+ Spree::County.find_or_create_by(name: 'Paillaco', state: xiv)
260
+ Spree::County.find_or_create_by(name: 'Panguipulli', state: xiv)
261
+ Spree::County.find_or_create_by(name: 'La Unión', state: xiv)
262
+ Spree::County.find_or_create_by(name: 'Futrono', state: xiv)
263
+ Spree::County.find_or_create_by(name: 'Lago Ranco', state: xiv)
264
+ Spree::County.find_or_create_by(name: 'Río Bueno', state: xiv)
265
+ Spree::County.find_or_create_by(name: 'Puerto Montt', state: x)
266
+ Spree::County.find_or_create_by(name: 'Calbuco', state: x)
267
+ Spree::County.find_or_create_by(name: 'Cochamó', state: x)
268
+ Spree::County.find_or_create_by(name: 'Fresia', state: x)
269
+ Spree::County.find_or_create_by(name: 'Frutillar', state: x)
270
+ Spree::County.find_or_create_by(name: 'Los Muermos', state: x)
271
+ Spree::County.find_or_create_by(name: 'Llanquihue', state: x)
272
+ Spree::County.find_or_create_by(name: 'Maullín', state: x)
273
+ Spree::County.find_or_create_by(name: 'Puerto Varas', state: x)
274
+ Spree::County.find_or_create_by(name: 'Castro', state: x)
275
+ Spree::County.find_or_create_by(name: 'Ancud', state: x)
276
+ Spree::County.find_or_create_by(name: 'Chonchi', state: x)
277
+ Spree::County.find_or_create_by(name: 'Curaco de Vélez', state: x)
278
+ Spree::County.find_or_create_by(name: 'Dalcahue', state: x)
279
+ Spree::County.find_or_create_by(name: 'Puqueldón', state: x)
280
+ Spree::County.find_or_create_by(name: 'Queilén', state: x)
281
+ Spree::County.find_or_create_by(name: 'Quellón', state: x)
282
+ Spree::County.find_or_create_by(name: 'Quemchi', state: x)
283
+ Spree::County.find_or_create_by(name: 'Quinchao', state: x)
284
+ Spree::County.find_or_create_by(name: 'Osorno', state: x)
285
+ Spree::County.find_or_create_by(name: 'Puerto Octay', state: x)
286
+ Spree::County.find_or_create_by(name: 'Purranque', state: x)
287
+ Spree::County.find_or_create_by(name: 'Puyehue', state: x)
288
+ Spree::County.find_or_create_by(name: 'Río Negro', state: x)
289
+ Spree::County.find_or_create_by(name: 'San Juan de la Costa', state: x)
290
+ Spree::County.find_or_create_by(name: 'San Pablo', state: x)
291
+ Spree::County.find_or_create_by(name: 'Chaitén', state: x)
292
+ Spree::County.find_or_create_by(name: 'Futaleufú', state: x)
293
+ Spree::County.find_or_create_by(name: 'Hualaihué', state: x)
294
+ Spree::County.find_or_create_by(name: 'Palena', state: x)
295
+ Spree::County.find_or_create_by(name: 'Coihaique', state: xi)
296
+ Spree::County.find_or_create_by(name: 'Lago Verde', state: xi)
297
+ Spree::County.find_or_create_by(name: 'Aisén', state: xi)
298
+ Spree::County.find_or_create_by(name: 'Cisnes', state: xi)
299
+ Spree::County.find_or_create_by(name: 'Guaitecas', state: xi)
300
+ Spree::County.find_or_create_by(name: 'Cochrane', state: xi)
301
+ Spree::County.find_or_create_by(name: 'O\'Higgins', state: xi)
302
+ Spree::County.find_or_create_by(name: 'Tortel', state: xi)
303
+ Spree::County.find_or_create_by(name: 'Chile Chico', state: xi)
304
+ Spree::County.find_or_create_by(name: 'Río Ibáñez', state: xi)
305
+ Spree::County.find_or_create_by(name: 'Punta Arenas', state: xii)
306
+ Spree::County.find_or_create_by(name: 'Laguna Blanca', state: xii)
307
+ Spree::County.find_or_create_by(name: 'Río Verde', state: xii)
308
+ Spree::County.find_or_create_by(name: 'San Gregorio', state: xii)
309
+ Spree::County.find_or_create_by(name: 'Cabo de Hornos', state: xii)
310
+ Spree::County.find_or_create_by(name: 'Antártica', state: xii)
311
+ Spree::County.find_or_create_by(name: 'Porvenir', state: xii)
312
+ Spree::County.find_or_create_by(name: 'Primavera', state: xii)
313
+ Spree::County.find_or_create_by(name: 'Timaukel', state: xii)
314
+ Spree::County.find_or_create_by(name: 'Natales', state: xii)
315
+ Spree::County.find_or_create_by(name: 'Torres del Paine', state: xii)
316
+ Spree::County.find_or_create_by(name: 'Colina', state: rm)
317
+ Spree::County.find_or_create_by(name: 'Lampa', state: rm)
318
+ Spree::County.find_or_create_by(name: 'Tiltil', state: rm)
319
+ Spree::County.find_or_create_by(name: 'Pirque', state: rm)
320
+ Spree::County.find_or_create_by(name: 'Puente Alto', state: rm)
321
+ Spree::County.find_or_create_by(name: 'San José de Maipo', state: rm)
322
+ Spree::County.find_or_create_by(name: 'Buin', state: rm)
323
+ Spree::County.find_or_create_by(name: 'Calera de Tango', state: rm)
324
+ Spree::County.find_or_create_by(name: 'Paine', state: rm)
325
+ Spree::County.find_or_create_by(name: 'San Bernardo', state: rm)
326
+ Spree::County.find_or_create_by(name: 'Alhué', state: rm)
327
+ Spree::County.find_or_create_by(name: 'Curacaví', state: rm)
328
+ Spree::County.find_or_create_by(name: 'María Pinto', state: rm)
329
+ Spree::County.find_or_create_by(name: 'Melipilla', state: rm)
330
+ Spree::County.find_or_create_by(name: 'San Pedro', state: rm)
331
+ Spree::County.find_or_create_by(name: 'Cerrillos', state: rm)
332
+ Spree::County.find_or_create_by(name: 'Cerro Navia', state: rm)
333
+ Spree::County.find_or_create_by(name: 'Conchalí', state: rm)
334
+ Spree::County.find_or_create_by(name: 'El Bosque', state: rm)
335
+ Spree::County.find_or_create_by(name: 'Estación Central', state: rm)
336
+ Spree::County.find_or_create_by(name: 'Huechuraba', state: rm)
337
+ Spree::County.find_or_create_by(name: 'Independencia', state: rm)
338
+ Spree::County.find_or_create_by(name: 'La Cisterna', state: rm)
339
+ Spree::County.find_or_create_by(name: 'La Granja', state: rm)
340
+ Spree::County.find_or_create_by(name: 'La Florida', state: rm)
341
+ Spree::County.find_or_create_by(name: 'La Pintana', state: rm)
342
+ Spree::County.find_or_create_by(name: 'La Reina', state: rm)
343
+ Spree::County.find_or_create_by(name: 'Las Condes', state: rm)
344
+ Spree::County.find_or_create_by(name: 'Lo Barnechea', state: rm)
345
+ Spree::County.find_or_create_by(name: 'Lo Espejo', state: rm)
346
+ Spree::County.find_or_create_by(name: 'Lo Prado', state: rm)
347
+ Spree::County.find_or_create_by(name: 'Macul', state: rm)
348
+ Spree::County.find_or_create_by(name: 'Maipú', state: rm)
349
+ Spree::County.find_or_create_by(name: 'Ñuñoa', state: rm)
350
+ Spree::County.find_or_create_by(name: 'Pedro Aguirre Cerda', state: rm)
351
+ Spree::County.find_or_create_by(name: 'Peñalolén', state: rm)
352
+ Spree::County.find_or_create_by(name: 'Providencia', state: rm)
353
+ Spree::County.find_or_create_by(name: 'Pudahuel', state: rm)
354
+ Spree::County.find_or_create_by(name: 'Quilicura', state: rm)
355
+ Spree::County.find_or_create_by(name: 'Quinta Normal', state: rm)
356
+ Spree::County.find_or_create_by(name: 'Recoleta', state: rm)
357
+ Spree::County.find_or_create_by(name: 'Renca', state: rm)
358
+ Spree::County.find_or_create_by(name: 'San Miguel', state: rm)
359
+ Spree::County.find_or_create_by(name: 'San Joaquín', state: rm)
360
+ Spree::County.find_or_create_by(name: 'San Ramón', state: rm)
361
+ Spree::County.find_or_create_by(name: 'Santiago', state: rm)
362
+ Spree::County.find_or_create_by(name: 'Vitacura', state: rm)
363
+ Spree::County.find_or_create_by(name: 'El Monte', state: rm)
364
+ Spree::County.find_or_create_by(name: 'Isla de Maipo', state: rm)
365
+ Spree::County.find_or_create_by(name: 'Padre Hurtado', state: rm)
366
+ Spree::County.find_or_create_by(name: 'Peñaflor', state: rm)
367
+ Spree::County.find_or_create_by(name: 'Talagante', state: rm)
@@ -0,0 +1,20 @@
1
+ module SpreeCounties
2
+ class Engine < Rails::Engine
3
+ require 'spree/core'
4
+ isolate_namespace Spree
5
+ engine_name 'spree_counties'
6
+
7
+ # use rspec for tests
8
+ config.generators do |g|
9
+ g.test_framework :rspec
10
+ end
11
+
12
+ def self.activate
13
+ Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
14
+ Rails.configuration.cache_classes ? require(c) : load(c)
15
+ end
16
+ end
17
+
18
+ config.to_prepare &method(:activate).to_proc
19
+ end
20
+ end
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ # Define your Spree extensions Factories within this file to enable applications, and other extensions to use and override them.
3
+ #
4
+ # Example adding this to your spec_helper will load these Factories for use:
5
+ # require 'spree_counties/factories'
6
+ end
@@ -0,0 +1,3 @@
1
+ module SpreeCounties
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,2 @@
1
+ require 'spree_core'
2
+ require 'spree_counties/engine'
@@ -0,0 +1,87 @@
1
+ # Run Coverage report
2
+ require 'simplecov'
3
+ SimpleCov.start do
4
+ add_filter 'spec/dummy'
5
+ add_group 'Controllers', 'app/controllers'
6
+ add_group 'Helpers', 'app/helpers'
7
+ add_group 'Mailers', 'app/mailers'
8
+ add_group 'Models', 'app/models'
9
+ add_group 'Views', 'app/views'
10
+ add_group 'Libraries', 'lib'
11
+ end
12
+
13
+ # Configure Rails Environment
14
+ ENV['RAILS_ENV'] = 'test'
15
+
16
+ require File.expand_path('../dummy/config/environment.rb', __FILE__)
17
+
18
+ require 'rspec/rails'
19
+ require 'database_cleaner'
20
+ require 'ffaker'
21
+
22
+ # Requires supporting ruby files with custom matchers and macros, etc,
23
+ # in spec/support/ and its subdirectories.
24
+ Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
25
+
26
+ # Requires factories and other useful helpers defined in spree_core.
27
+ require 'spree/testing_support/authorization_helpers'
28
+ require 'spree/testing_support/capybara_ext'
29
+ require 'spree/testing_support/controller_requests'
30
+ require 'spree/testing_support/factories'
31
+ require 'spree/testing_support/url_helpers'
32
+
33
+ # Requires factories defined in lib/spree_counties/factories.rb
34
+ require 'spree_counties/factories'
35
+
36
+ RSpec.configure do |config|
37
+ config.include FactoryGirl::Syntax::Methods
38
+
39
+ # Infer an example group's spec type from the file location.
40
+ config.infer_spec_type_from_file_location!
41
+
42
+ # == URL Helpers
43
+ #
44
+ # Allows access to Spree's routes in specs:
45
+ #
46
+ # visit spree.admin_path
47
+ # current_path.should eql(spree.products_path)
48
+ config.include Spree::TestingSupport::UrlHelpers
49
+
50
+ # == Mock Framework
51
+ #
52
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
53
+ #
54
+ # config.mock_with :mocha
55
+ # config.mock_with :flexmock
56
+ # config.mock_with :rr
57
+ config.mock_with :rspec
58
+ config.color = true
59
+
60
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
61
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
62
+
63
+ # Capybara javascript drivers require transactional fixtures set to false, and we use DatabaseCleaner
64
+ # to cleanup after each test instead. Without transactional fixtures set to false the records created
65
+ # to setup a test will be unavailable to the browser, which runs under a separate server instance.
66
+ config.use_transactional_fixtures = false
67
+
68
+ # Ensure Suite is set to use transactions for speed.
69
+ config.before :suite do
70
+ DatabaseCleaner.strategy = :transaction
71
+ DatabaseCleaner.clean_with :truncation
72
+ end
73
+
74
+ # Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary.
75
+ config.before :each do
76
+ DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction
77
+ DatabaseCleaner.start
78
+ end
79
+
80
+ # After each spec clean the database.
81
+ config.after :each do
82
+ DatabaseCleaner.clean
83
+ end
84
+
85
+ config.fail_fast = ENV['FAIL_FAST'] || false
86
+ config.order = "random"
87
+ end
@@ -0,0 +1,32 @@
1
+ # encoding: UTF-8
2
+ Gem::Specification.new do |s|
3
+ s.platform = Gem::Platform::RUBY
4
+ s.name = 'spree_counties'
5
+ s.version = '2.3.5'
6
+ s.summary = 'Lets your users pick counties from states list in address\'s step'
7
+ s.description = 'Add county model to address'
8
+ s.required_ruby_version = '>= 1.9.3'
9
+
10
+ s.author = 'Gonzalo Moreno'
11
+ s.email = 'gmoreno@acid.cl'
12
+ s.homepage = 'http://www.acid.cl'
13
+ s.license = 'MIT'
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.require_path = 'lib'
18
+ s.requirements << 'none'
19
+
20
+ s.add_dependency('spree_core', '~> 2.1')
21
+
22
+ s.add_development_dependency 'capybara', '~> 2.4'
23
+ s.add_development_dependency 'coffee-rails'
24
+ s.add_development_dependency 'database_cleaner'
25
+ s.add_development_dependency 'factory_girl', '~> 4.4'
26
+ s.add_development_dependency 'ffaker'
27
+ s.add_development_dependency 'rspec-rails', '~> 3.1'
28
+ s.add_development_dependency 'sass-rails', '~> 4.0.2'
29
+ s.add_development_dependency 'selenium-webdriver'
30
+ s.add_development_dependency 'simplecov'
31
+ s.add_development_dependency 'sqlite3'
32
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_counties
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.4
4
+ version: 2.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gonzalo Moreno
@@ -164,14 +164,51 @@ dependencies:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
- description: Lets your users pick counties from states list in address's step
167
+ description: Add county model to address
168
168
  email: gmoreno@acid.cl
169
169
  executables: []
170
170
  extensions: []
171
171
  extra_rdoc_files: []
172
- files: []
172
+ files:
173
+ - ".bundle/config"
174
+ - ".gitignore"
175
+ - ".rspec"
176
+ - Gemfile
177
+ - LICENSE.txt
178
+ - README.md
179
+ - Rakefile
180
+ - app/assets/javascripts/spree/backend/spree_counties.js
181
+ - app/assets/javascripts/spree/frontend/spree_counties.js.coffee
182
+ - app/assets/stylesheets/spree/backend/spree_counties.css
183
+ - app/assets/stylesheets/spree/frontend/spree_counties.css
184
+ - app/controllers/spree/api/counties_controller.rb
185
+ - app/models/county_ability.rb
186
+ - app/models/spree/address_decorator.rb
187
+ - app/models/spree/county.rb
188
+ - app/models/spree/state_decorator.rb
189
+ - app/views/spree/address/_form.html.erb
190
+ - app/views/spree/admin/shared/_address_form.html.erb
191
+ - app/views/spree/api/counties/index.v1.rabl
192
+ - app/views/spree/api/counties/show.v1.rabl
193
+ - bin/rails
194
+ - config/locales/en.yml
195
+ - config/routes.rb
196
+ - db/migrate/20140729200830_create_spree_counties.rb
197
+ - db/migrate/20140729203900_add_spree_county_reference_to_spree_address.rb
198
+ - db/migrate/20141119225426_add_county_name_to_spree_address.rb
199
+ - lib/generators/spree_counties/install/install_generator.rb
200
+ - lib/generators/spree_counties/install/templates/1.png
201
+ - lib/generators/spree_counties/install/templates/2.png
202
+ - lib/generators/spree_counties/install/templates/seeds/counties.rb
203
+ - lib/spree_counties.rb
204
+ - lib/spree_counties/engine.rb
205
+ - lib/spree_counties/factories.rb
206
+ - lib/spree_counties/version.rb
207
+ - spec/spec_helper.rb
208
+ - spree_counties.gemspec
173
209
  homepage: http://www.acid.cl
174
- licenses: []
210
+ licenses:
211
+ - MIT
175
212
  metadata: {}
176
213
  post_install_message:
177
214
  rdoc_options: []
@@ -194,4 +231,5 @@ rubygems_version: 2.4.2
194
231
  signing_key:
195
232
  specification_version: 4
196
233
  summary: Lets your users pick counties from states list in address's step
197
- test_files: []
234
+ test_files:
235
+ - spec/spec_helper.rb