spree_br_common 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +14 -0
- data/Gemfile +20 -0
- data/LICENSE +26 -0
- data/README.md +55 -0
- data/Rakefile +21 -0
- data/app/assets/javascripts/spree/backend/spree_br_common.js +2 -0
- data/app/assets/javascripts/spree/frontend/address.js +119 -0
- data/app/assets/javascripts/spree/frontend/mask.js +21 -0
- data/app/assets/javascripts/spree/frontend/plugins/jquery.mask.extension.js +4 -0
- data/app/assets/javascripts/spree/frontend/plugins/jquery.mask.js +395 -0
- data/app/assets/javascripts/spree/frontend/routes.js.erb +4 -0
- data/app/assets/javascripts/spree/frontend/spree_br_common.js +1 -0
- data/app/assets/stylesheets/spree/backend/spree_br_common.css +4 -0
- data/app/assets/stylesheets/spree/frontend/spree_br_common.css +4 -0
- data/app/controllers/spree/addresses_controller.rb +24 -0
- data/app/controllers/spree/api/cities_controller.rb +38 -0
- data/app/controllers/spree/user_registrations_controller_decorator.rb +13 -0
- data/app/helpers/spree/api/api_helpers_decorator.rb +13 -0
- data/app/helpers/spree/base_helper_decorator.rb +5 -0
- data/app/models/spree/ability_decorator.rb +21 -0
- data/app/models/spree/address_decorator.rb +6 -0
- data/app/models/spree/city.rb +7 -0
- data/app/models/spree/permitted_attributes_decorator.rb +8 -0
- data/app/models/spree/state_decorator.rb +3 -0
- data/app/models/spree/user_decorator.rb +52 -0
- data/app/overrides/spree/address/_form/add_district.html.erb.deface +5 -0
- data/app/overrides/spree/address/_form/add_number.html.erb.deface +5 -0
- data/app/overrides/spree/address/_form/hide_country.html.erb.deface +4 -0
- data/app/overrides/spree/address/_form/move_city_to_after_state.deface +2 -0
- data/app/overrides/spree/address/_form/move_zipcode_after_last_name.deface +2 -0
- data/app/overrides/spree/address/_form/replace_city_input_text_by_select.html.erb.deface +18 -0
- data/app/overrides/spree/address/_form/set_data_uf_to_state.html.erb.deface +15 -0
- data/app/overrides/spree/admin/users/_form/add_extras_fields.html.erb.deface +39 -0
- data/app/overrides/spree/shared/_user_form/add_extra_fields.html.erb.deface +19 -0
- data/app/overrides/spree/users/show/add_details.html.erb.deface +13 -0
- data/app/views/spree/api/cities/index.v1.rabl +11 -0
- data/app/views/spree/api/cities/show.v1.rabl +2 -0
- data/bin/rails +7 -0
- data/config/locales/en.yml +11 -0
- data/config/locales/pt-BR.yml +14 -0
- data/config/routes.rb +7 -0
- data/db/default/country.rb +3 -0
- data/db/default/shipping_categories.rb +1 -0
- data/db/default/shipping_zones.rb +3 -0
- data/db/default/states.rb +31 -0
- data/db/default/states_cities_of_acre.rb +26 -0
- data/db/default/states_cities_of_alagoas.rb +107 -0
- data/db/default/states_cities_of_amapa.rb +20 -0
- data/db/default/states_cities_of_amazonas.rb +67 -0
- data/db/default/states_cities_of_bahia.rb +421 -0
- data/db/default/states_cities_of_ceara.rb +188 -0
- data/db/default/states_cities_of_distrito_federal.rb +5 -0
- data/db/default/states_cities_of_espirito_santo.rb +82 -0
- data/db/default/states_cities_of_goias.rb +250 -0
- data/db/default/states_cities_of_maranhao.rb +221 -0
- data/db/default/states_cities_of_mato_grosso.rb +145 -0
- data/db/default/states_cities_of_mato_grosso_do_sul.rb +82 -0
- data/db/default/states_cities_of_minas_gerais.rb +857 -0
- data/db/default/states_cities_of_para.rb +147 -0
- data/db/default/states_cities_of_paraiba.rb +227 -0
- data/db/default/states_cities_of_parana.rb +403 -0
- data/db/default/states_cities_of_pernambuco.rb +189 -0
- data/db/default/states_cities_of_piaui.rb +227 -0
- data/db/default/states_cities_of_rio_de_janeiro.rb +96 -0
- data/db/default/states_cities_of_rio_grande_do_norte.rb +171 -0
- data/db/default/states_cities_of_rio_grande_do_sul.rb +500 -0
- data/db/default/states_cities_of_rondonia.rb +56 -0
- data/db/default/states_cities_of_roraima.rb +19 -0
- data/db/default/states_cities_of_santa_catarina.rb +297 -0
- data/db/default/states_cities_of_sao_paulo.rb +649 -0
- data/db/default/states_cities_of_sergipe.rb +79 -0
- data/db/default/states_cities_of_tocantins.rb +144 -0
- data/db/default/stock.rb +1 -0
- data/db/default/tax_categories.rb +1 -0
- data/db/default/user.rb +100 -0
- data/db/migrate/20150503011715_create_spree_cities.rb +13 -0
- data/db/migrate/20150504004509_remove_city_from_spree_address.rb +5 -0
- data/db/migrate/20150504004648_add_city_to_spree_address.rb +5 -0
- data/db/migrate/20150505020218_add_number_and_district_to_spree_address.rb +6 -0
- data/db/migrate/20150505031019_add_details_to_spree_user.rb +10 -0
- data/db/seeds.rb +5 -0
- data/lib/generators/spree_br_common/install/install_generator.rb +31 -0
- data/lib/spree_br_common/engine.rb +20 -0
- data/lib/spree_br_common/factories/address_factory.rb +7 -0
- data/lib/spree_br_common/factories/city_factory.rb +8 -0
- data/lib/spree_br_common/factories/user_factory.rb +12 -0
- data/lib/spree_br_common/factories.rb +3 -0
- data/lib/spree_br_common.rb +2 -0
- data/spec/controllers/features/address_checkout_spec.rb +89 -0
- data/spec/controllers/features/user_account_spec.rb +46 -0
- data/spec/controllers/features/user_signup_spec.rb +24 -0
- data/spec/controllers/spree/addresses_controller_spec.rb +27 -0
- data/spec/controllers/spree/api/cities_controller_spec.rb +86 -0
- data/spec/fixtures/vcr_cassettes/Checkout/visitor_makes_checkout_as_guest_without_registration/full_checkout/does_not_break_the_per-item_shipping_method_calculator.yml +49 -0
- data/spec/fixtures/vcr_cassettes/Checkout/visitor_makes_checkout_as_guest_without_registration/full_checkout/in_Brazil/should_autocomplete_zipcode.yml +46 -0
- data/spec/fixtures/vcr_cassettes/Spree_AddressesController/_show/does_not_find_an_incorrect_cep.yml +38 -0
- data/spec/fixtures/vcr_cassettes/Spree_AddressesController/_show/shows_the_correct_address.yml +46 -0
- data/spec/models/spree/address_spec.rb +32 -0
- data/spec/models/spree/city_spec.rb +7 -0
- data/spec/models/spree/user_spec.rb +88 -0
- data/spec/spec_helper.rb +94 -0
- data/spec/support/controller_hacks.rb +33 -0
- data/spec/support/shared_context/checkout_setup.rb +9 -0
- data/spec/support/vcr.rb +8 -0
- data/spree_br_common.gemspec +33 -0
- metadata +351 -0
@@ -0,0 +1,79 @@
|
|
1
|
+
sergipe = Spree::State.find_by! abbr: 'SE'
|
2
|
+
|
3
|
+
Spree::City.create!([
|
4
|
+
{state: sergipe, ibge_code: 2801306, name: "Capela"},
|
5
|
+
{state: sergipe, ibge_code: 2802007, name: "Divina Pastora"},
|
6
|
+
{state: sergipe, ibge_code: 2806503, name: "Santa Rosa de Lima"},
|
7
|
+
{state: sergipe, ibge_code: 2803302, name: "Japaratuba"},
|
8
|
+
{state: sergipe, ibge_code: 2803401, name: "Japoatã"},
|
9
|
+
{state: sergipe, ibge_code: 2804904, name: "Pacatuba"},
|
10
|
+
{state: sergipe, ibge_code: 2805307, name: "Pirambu"},
|
11
|
+
{state: sergipe, ibge_code: 2806909, name: "São Francisco"},
|
12
|
+
{state: sergipe, ibge_code: 2803609, name: "Laranjeiras"},
|
13
|
+
{state: sergipe, ibge_code: 2804003, name: "Maruim"},
|
14
|
+
{state: sergipe, ibge_code: 2805901, name: "Riachuelo"},
|
15
|
+
{state: sergipe, ibge_code: 2804300, name: "Muribeca"},
|
16
|
+
{state: sergipe, ibge_code: 2807204, name: "Siriri"},
|
17
|
+
{state: sergipe, ibge_code: 2802601, name: "Gracho Cardoso"},
|
18
|
+
{state: sergipe, ibge_code: 2804607, name: "Nossa Senhora das Dores"},
|
19
|
+
{state: sergipe, ibge_code: 2805703, name: "Propriá"},
|
20
|
+
{state: sergipe, ibge_code: 2802502, name: "General Maynard"},
|
21
|
+
{state: sergipe, ibge_code: 2806305, name: "Santa Luzia do Itanhy"},
|
22
|
+
{state: sergipe, ibge_code: 2801504, name: "Carmópolis"},
|
23
|
+
{state: sergipe, ibge_code: 2806107, name: "Rosário do Catete"},
|
24
|
+
{state: sergipe, ibge_code: 2806701, name: "São Cristóvão"},
|
25
|
+
{state: sergipe, ibge_code: 2805109, name: "Pedrinhas"},
|
26
|
+
{state: sergipe, ibge_code: 2802106, name: "Estância"},
|
27
|
+
{state: sergipe, ibge_code: 2806602, name: "Santo Amaro das Brotas"},
|
28
|
+
{state: sergipe, ibge_code: 2800308, name: "Aracaju"},
|
29
|
+
{state: sergipe, ibge_code: 2800605, name: "Barra dos Coqueiros"},
|
30
|
+
{state: sergipe, ibge_code: 2804805, name: "Nossa Senhora do Socorro"},
|
31
|
+
{state: sergipe, ibge_code: 2800407, name: "Arauá"},
|
32
|
+
{state: sergipe, ibge_code: 2800670, name: "Boquim"},
|
33
|
+
{state: sergipe, ibge_code: 2801702, name: "Cristinápolis"},
|
34
|
+
{state: sergipe, ibge_code: 2803005, name: "Itabaianinha"},
|
35
|
+
{state: sergipe, ibge_code: 2806206, name: "Salgado"},
|
36
|
+
{state: sergipe, ibge_code: 2807501, name: "Tomar do Geru"},
|
37
|
+
{state: sergipe, ibge_code: 2807600, name: "Umbaúba"},
|
38
|
+
{state: sergipe, ibge_code: 2802809, name: "Indiaroba"},
|
39
|
+
{state: sergipe, ibge_code: 2803203, name: "Itaporanga d'Ajuda"},
|
40
|
+
{state: sergipe, ibge_code: 2801207, name: "Canindé de São Francisco"},
|
41
|
+
{state: sergipe, ibge_code: 2802205, name: "Feira Nova"},
|
42
|
+
{state: sergipe, ibge_code: 2802403, name: "Gararu"},
|
43
|
+
{state: sergipe, ibge_code: 2803104, name: "Itabi"},
|
44
|
+
{state: sergipe, ibge_code: 2804201, name: "Monte Alegre de Sergipe"},
|
45
|
+
{state: sergipe, ibge_code: 2804508, name: "Nossa Senhora da Glória"},
|
46
|
+
{state: sergipe, ibge_code: 2805406, name: "Poço Redondo"},
|
47
|
+
{state: sergipe, ibge_code: 2805604, name: "Porto da Folha"},
|
48
|
+
{state: sergipe, ibge_code: 2801405, name: "Carira"},
|
49
|
+
{state: sergipe, ibge_code: 2802304, name: "Frei Paulo"},
|
50
|
+
{state: sergipe, ibge_code: 2804458, name: "Nossa Senhora Aparecida"},
|
51
|
+
{state: sergipe, ibge_code: 2805000, name: "Pedra Mole"},
|
52
|
+
{state: sergipe, ibge_code: 2805208, name: "Pinhão"},
|
53
|
+
{state: sergipe, ibge_code: 2806008, name: "Ribeirópolis"},
|
54
|
+
{state: sergipe, ibge_code: 2800209, name: "Aquidabã"},
|
55
|
+
{state: sergipe, ibge_code: 2801900, name: "Cumbe"},
|
56
|
+
{state: sergipe, ibge_code: 2803807, name: "Malhada dos Bois"},
|
57
|
+
{state: sergipe, ibge_code: 2807006, name: "São Miguel do Aleixo"},
|
58
|
+
{state: sergipe, ibge_code: 2800506, name: "Areia Branca"},
|
59
|
+
{state: sergipe, ibge_code: 2801009, name: "Campo do Brito"},
|
60
|
+
{state: sergipe, ibge_code: 2802908, name: "Itabaiana"},
|
61
|
+
{state: sergipe, ibge_code: 2803708, name: "Macambira"},
|
62
|
+
{state: sergipe, ibge_code: 2803906, name: "Malhador"},
|
63
|
+
{state: sergipe, ibge_code: 2804102, name: "Moita Bonita"},
|
64
|
+
{state: sergipe, ibge_code: 2806800, name: "São Domingos"},
|
65
|
+
{state: sergipe, ibge_code: 2805505, name: "Poço Verde"},
|
66
|
+
{state: sergipe, ibge_code: 2807105, name: "Simão Dias"},
|
67
|
+
{state: sergipe, ibge_code: 2807402, name: "Tobias Barreto"},
|
68
|
+
{state: sergipe, ibge_code: 2803500, name: "Lagarto"},
|
69
|
+
{state: sergipe, ibge_code: 2805802, name: "Riachão do Dantas"},
|
70
|
+
{state: sergipe, ibge_code: 2800100, name: "Amparo de São Francisco"},
|
71
|
+
{state: sergipe, ibge_code: 2800704, name: "Brejo Grande"},
|
72
|
+
{state: sergipe, ibge_code: 2801108, name: "Canhoba"},
|
73
|
+
{state: sergipe, ibge_code: 2801603, name: "Cedro de São João"},
|
74
|
+
{state: sergipe, ibge_code: 2802700, name: "Ilha das Flores"},
|
75
|
+
{state: sergipe, ibge_code: 2804409, name: "Neópolis"},
|
76
|
+
{state: sergipe, ibge_code: 2804706, name: "Nossa Senhora de Lourdes"},
|
77
|
+
{state: sergipe, ibge_code: 2806404, name: "Santana do São Francisco"},
|
78
|
+
{state: sergipe, ibge_code: 2807303, name: "Telha"}
|
79
|
+
])
|
@@ -0,0 +1,144 @@
|
|
1
|
+
tocantins = Spree::State.find_by! abbr: 'TO'
|
2
|
+
|
3
|
+
Spree::City.create!([
|
4
|
+
{state: tocantins, ibge_code: 1713957, name: "Muricilândia"},
|
5
|
+
{state: tocantins, ibge_code: 1715507, name: "Oliveira de Fátima"},
|
6
|
+
{state: tocantins, ibge_code: 1707009, name: "Dianópolis"},
|
7
|
+
{state: tocantins, ibge_code: 1706506, name: "Darcinópolis"},
|
8
|
+
{state: tocantins, ibge_code: 1721208, name: "Tocantinópolis"},
|
9
|
+
{state: tocantins, ibge_code: 1722081, name: "Wanderlândia"},
|
10
|
+
{state: tocantins, ibge_code: 1713700, name: "Monte Santo do Tocantins"},
|
11
|
+
{state: tocantins, ibge_code: 1707652, name: "Figueirópolis"},
|
12
|
+
{state: tocantins, ibge_code: 1721109, name: "Tocantínia"},
|
13
|
+
{state: tocantins, ibge_code: 1702703, name: "Aurora do Tocantins"},
|
14
|
+
{state: tocantins, ibge_code: 1718451, name: "Pugmil"},
|
15
|
+
{state: tocantins, ibge_code: 1700350, name: "Aliança do Tocantins"},
|
16
|
+
{state: tocantins, ibge_code: 1700707, name: "Alvorada"},
|
17
|
+
{state: tocantins, ibge_code: 1703701, name: "Brejinho de Nazaré"},
|
18
|
+
{state: tocantins, ibge_code: 1703867, name: "Cariri do Tocantins"},
|
19
|
+
{state: tocantins, ibge_code: 1709500, name: "Gurupi"},
|
20
|
+
{state: tocantins, ibge_code: 1711506, name: "Jaú do Tocantins"},
|
21
|
+
{state: tocantins, ibge_code: 1715754, name: "Palmeirópolis"},
|
22
|
+
{state: tocantins, ibge_code: 1716604, name: "Peixe"},
|
23
|
+
{state: tocantins, ibge_code: 1720259, name: "São Salvador do Tocantins"},
|
24
|
+
{state: tocantins, ibge_code: 1720853, name: "Sucupira"},
|
25
|
+
{state: tocantins, ibge_code: 1720978, name: "Talismã"},
|
26
|
+
{state: tocantins, ibge_code: 1701101, name: "Aparecida do Rio Negro"},
|
27
|
+
{state: tocantins, ibge_code: 1703305, name: "Bom Jesus do Tocantins"},
|
28
|
+
{state: tocantins, ibge_code: 1712009, name: "Lajeado"},
|
29
|
+
{state: tocantins, ibge_code: 1713601, name: "Monte do Carmo"},
|
30
|
+
{state: tocantins, ibge_code: 1716505, name: "Pedro Afonso"},
|
31
|
+
{state: tocantins, ibge_code: 1718881, name: "Santa Maria do Tocantins"},
|
32
|
+
{state: tocantins, ibge_code: 1720655, name: "Silvanópolis"},
|
33
|
+
{state: tocantins, ibge_code: 1721000, name: "Palmas"},
|
34
|
+
{state: tocantins, ibge_code: 1703842, name: "Campos Lindos"},
|
35
|
+
{state: tocantins, ibge_code: 1704105, name: "Centenário"},
|
36
|
+
{state: tocantins, ibge_code: 1709005, name: "Goiatins"},
|
37
|
+
{state: tocantins, ibge_code: 1710508, name: "Itacajá"},
|
38
|
+
{state: tocantins, ibge_code: 1711951, name: "Lagoa do Tocantins"},
|
39
|
+
{state: tocantins, ibge_code: 1712405, name: "Lizarda"},
|
40
|
+
{state: tocantins, ibge_code: 1712702, name: "Mateiros"},
|
41
|
+
{state: tocantins, ibge_code: 1715101, name: "Novo Acordo"},
|
42
|
+
{state: tocantins, ibge_code: 1718501, name: "Recursolândia"},
|
43
|
+
{state: tocantins, ibge_code: 1718758, name: "Rio Sono"},
|
44
|
+
{state: tocantins, ibge_code: 1719004, name: "Santa Tereza do Tocantins"},
|
45
|
+
{state: tocantins, ibge_code: 1720150, name: "São Félix do Tocantins"},
|
46
|
+
{state: tocantins, ibge_code: 1700400, name: "Almas"},
|
47
|
+
{state: tocantins, ibge_code: 1705102, name: "Chapada da Natividade"},
|
48
|
+
{state: tocantins, ibge_code: 1705557, name: "Combinado"},
|
49
|
+
{state: tocantins, ibge_code: 1712157, name: "Lavandeira"},
|
50
|
+
{state: tocantins, ibge_code: 1714203, name: "Natividade"},
|
51
|
+
{state: tocantins, ibge_code: 1715150, name: "Novo Alegre"},
|
52
|
+
{state: tocantins, ibge_code: 1715259, name: "Novo Jardim"},
|
53
|
+
{state: tocantins, ibge_code: 1717008, name: "Pindorama do Tocantins"},
|
54
|
+
{state: tocantins, ibge_code: 1717800, name: "Ponte Alta do Bom Jesus"},
|
55
|
+
{state: tocantins, ibge_code: 1718006, name: "Porto Alegre do Tocantins"},
|
56
|
+
{state: tocantins, ibge_code: 1718907, name: "Santa Rosa do Tocantins"},
|
57
|
+
{state: tocantins, ibge_code: 1720499, name: "São Valério da Natividade"},
|
58
|
+
{state: tocantins, ibge_code: 1720903, name: "Taguatinga"},
|
59
|
+
{state: tocantins, ibge_code: 1720937, name: "Taipas do Tocantins"},
|
60
|
+
{state: tocantins, ibge_code: 1700251, name: "Abreulândia"},
|
61
|
+
{state: tocantins, ibge_code: 1703602, name: "Brasilândia do Tocantins"},
|
62
|
+
{state: tocantins, ibge_code: 1709302, name: "Guaraí"},
|
63
|
+
{state: tocantins, ibge_code: 1713205, name: "Miracema do Tocantins"},
|
64
|
+
{state: tocantins, ibge_code: 1718709, name: "Rio dos Bois"},
|
65
|
+
{state: tocantins, ibge_code: 1706100, name: "Cristalândia"},
|
66
|
+
{state: tocantins, ibge_code: 1715002, name: "Nova Rosalândia"},
|
67
|
+
{state: tocantins, ibge_code: 1718840, name: "Sandolândia"},
|
68
|
+
{state: tocantins, ibge_code: 1706258, name: "Crixás do Tocantins"},
|
69
|
+
{state: tocantins, ibge_code: 1718659, name: "Rio da Conceição"},
|
70
|
+
{state: tocantins, ibge_code: 1718899, name: "Santa Rita do Tocantins"},
|
71
|
+
{state: tocantins, ibge_code: 1709807, name: "Ipueiras"},
|
72
|
+
{state: tocantins, ibge_code: 1718204, name: "Porto Nacional"},
|
73
|
+
{state: tocantins, ibge_code: 1703073, name: "Barra do Ouro"},
|
74
|
+
{state: tocantins, ibge_code: 1710904, name: "Itapiratins"},
|
75
|
+
{state: tocantins, ibge_code: 1717909, name: "Ponte Alta do Tocantins"},
|
76
|
+
{state: tocantins, ibge_code: 1702406, name: "Arraias"},
|
77
|
+
{state: tocantins, ibge_code: 1705607, name: "Conceição do Tocantins"},
|
78
|
+
{state: tocantins, ibge_code: 1716208, name: "Paranã"},
|
79
|
+
{state: tocantins, ibge_code: 1700301, name: "Aguiarnópolis"},
|
80
|
+
{state: tocantins, ibge_code: 1701002, name: "Ananás"},
|
81
|
+
{state: tocantins, ibge_code: 1701051, name: "Angico"},
|
82
|
+
{state: tocantins, ibge_code: 1702208, name: "Araguatins"},
|
83
|
+
{state: tocantins, ibge_code: 1702554, name: "Augustinópolis"},
|
84
|
+
{state: tocantins, ibge_code: 1702901, name: "Axixá do Tocantins"},
|
85
|
+
{state: tocantins, ibge_code: 1703800, name: "Buriti do Tocantins"},
|
86
|
+
{state: tocantins, ibge_code: 1703826, name: "Cachoeirinha"},
|
87
|
+
{state: tocantins, ibge_code: 1703891, name: "Carrasco Bonito"},
|
88
|
+
{state: tocantins, ibge_code: 1707405, name: "Esperantina"},
|
89
|
+
{state: tocantins, ibge_code: 1710706, name: "Itaguatins"},
|
90
|
+
{state: tocantins, ibge_code: 1712454, name: "Luzinópolis"},
|
91
|
+
{state: tocantins, ibge_code: 1712801, name: "Maurilândia do Tocantins"},
|
92
|
+
{state: tocantins, ibge_code: 1713809, name: "Palmeiras do Tocantins"},
|
93
|
+
{state: tocantins, ibge_code: 1714302, name: "Nazaré"},
|
94
|
+
{state: tocantins, ibge_code: 1718303, name: "Praia Norte"},
|
95
|
+
{state: tocantins, ibge_code: 1718550, name: "Riachinho"},
|
96
|
+
{state: tocantins, ibge_code: 1718808, name: "Sampaio"},
|
97
|
+
{state: tocantins, ibge_code: 1720002, name: "Santa Terezinha do Tocantins"},
|
98
|
+
{state: tocantins, ibge_code: 1720101, name: "São Bento do Tocantins"},
|
99
|
+
{state: tocantins, ibge_code: 1720200, name: "São Miguel do Tocantins"},
|
100
|
+
{state: tocantins, ibge_code: 1720309, name: "São Sebastião do Tocantins"},
|
101
|
+
{state: tocantins, ibge_code: 1720804, name: "Sítio Novo do Tocantins"},
|
102
|
+
{state: tocantins, ibge_code: 1701309, name: "Aragominas"},
|
103
|
+
{state: tocantins, ibge_code: 1702109, name: "Araguaína"},
|
104
|
+
{state: tocantins, ibge_code: 1702158, name: "Araguanã"},
|
105
|
+
{state: tocantins, ibge_code: 1702307, name: "Arapoema"},
|
106
|
+
{state: tocantins, ibge_code: 1703008, name: "Babaçulândia"},
|
107
|
+
{state: tocantins, ibge_code: 1703057, name: "Bandeirantes do Tocantins"},
|
108
|
+
{state: tocantins, ibge_code: 1703883, name: "Carmolândia"},
|
109
|
+
{state: tocantins, ibge_code: 1705508, name: "Colinas do Tocantins"},
|
110
|
+
{state: tocantins, ibge_code: 1707702, name: "Filadélfia"},
|
111
|
+
{state: tocantins, ibge_code: 1714880, name: "Nova Olinda"},
|
112
|
+
{state: tocantins, ibge_code: 1715705, name: "Palmeirante"},
|
113
|
+
{state: tocantins, ibge_code: 1716307, name: "Pau D'Arco"},
|
114
|
+
{state: tocantins, ibge_code: 1717206, name: "Piraquê"},
|
115
|
+
{state: tocantins, ibge_code: 1718865, name: "Santa Fé do Araguaia"},
|
116
|
+
{state: tocantins, ibge_code: 1722107, name: "Xambioá"},
|
117
|
+
{state: tocantins, ibge_code: 1701903, name: "Araguacema"},
|
118
|
+
{state: tocantins, ibge_code: 1703107, name: "Barrolândia"},
|
119
|
+
{state: tocantins, ibge_code: 1703206, name: "Bernardo Sayão"},
|
120
|
+
{state: tocantins, ibge_code: 1703909, name: "Caseara"},
|
121
|
+
{state: tocantins, ibge_code: 1706001, name: "Couto de Magalhães"},
|
122
|
+
{state: tocantins, ibge_code: 1707108, name: "Divinópolis do Tocantins"},
|
123
|
+
{state: tocantins, ibge_code: 1707207, name: "Dois Irmãos do Tocantins"},
|
124
|
+
{state: tocantins, ibge_code: 1708254, name: "Fortaleza do Tabocão"},
|
125
|
+
{state: tocantins, ibge_code: 1708304, name: "Goianorte"},
|
126
|
+
{state: tocantins, ibge_code: 1711100, name: "Itaporã do Tocantins"},
|
127
|
+
{state: tocantins, ibge_code: 1711803, name: "Juarina"},
|
128
|
+
{state: tocantins, ibge_code: 1712504, name: "Marianópolis do Tocantins"},
|
129
|
+
{state: tocantins, ibge_code: 1713304, name: "Miranorte"},
|
130
|
+
{state: tocantins, ibge_code: 1716653, name: "Pequizeiro"},
|
131
|
+
{state: tocantins, ibge_code: 1716703, name: "Colméia"},
|
132
|
+
{state: tocantins, ibge_code: 1718402, name: "Presidente Kennedy"},
|
133
|
+
{state: tocantins, ibge_code: 1721257, name: "Tupirama"},
|
134
|
+
{state: tocantins, ibge_code: 1721307, name: "Tupiratins"},
|
135
|
+
{state: tocantins, ibge_code: 1702000, name: "Araguaçu"},
|
136
|
+
{state: tocantins, ibge_code: 1704600, name: "Chapada de Areia"},
|
137
|
+
{state: tocantins, ibge_code: 1707306, name: "Dueré"},
|
138
|
+
{state: tocantins, ibge_code: 1707553, name: "Fátima"},
|
139
|
+
{state: tocantins, ibge_code: 1708205, name: "Formoso do Araguaia"},
|
140
|
+
{state: tocantins, ibge_code: 1711902, name: "Lagoa da Confusão"},
|
141
|
+
{state: tocantins, ibge_code: 1716109, name: "Paraíso do Tocantins"},
|
142
|
+
{state: tocantins, ibge_code: 1717503, name: "Pium"}
|
143
|
+
])
|
144
|
+
|
data/db/default/stock.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Spree::StockLocation.create! name: 'Padrão', country: Spree::Country.first!
|
@@ -0,0 +1 @@
|
|
1
|
+
Spree::TaxCategory.create!(:name => 'Padrão', :description => 'Padrão', :is_default => true)
|
data/db/default/user.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'highline/import'
|
2
|
+
|
3
|
+
# see last line where we create an admin if there is none, asking for email and password
|
4
|
+
def prompt_for_admin_password
|
5
|
+
if ENV['ADMIN_PASSWORD']
|
6
|
+
password = ENV['ADMIN_PASSWORD'].dup
|
7
|
+
say "Admin Password #{password}"
|
8
|
+
else
|
9
|
+
password = ask('Password [spree123]: ') do |q|
|
10
|
+
q.echo = false
|
11
|
+
q.validate = /^(|.{5,40})$/
|
12
|
+
q.responses[:not_valid] = 'Invalid password. Must be at least 5 characters long.'
|
13
|
+
q.whitespace = :strip
|
14
|
+
end
|
15
|
+
password = 'spree123' if password.blank?
|
16
|
+
end
|
17
|
+
|
18
|
+
password
|
19
|
+
end
|
20
|
+
|
21
|
+
def prompt_for_admin_field(field_description, var_env, default_value)
|
22
|
+
|
23
|
+
if ENV[var_env]
|
24
|
+
field = ENV[var_env].dup
|
25
|
+
say "Admin #{field_description} #{field}"
|
26
|
+
else
|
27
|
+
field = ask("#{field_description} [#{default_value}]: ") do |q|
|
28
|
+
q.echo = true
|
29
|
+
q.whitespace = :strip
|
30
|
+
end
|
31
|
+
field = default_value if field.blank?
|
32
|
+
end
|
33
|
+
|
34
|
+
field
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
def create_admin_user
|
39
|
+
attributes = {
|
40
|
+
:password => 'fulano',
|
41
|
+
:email => 'admin@bluesoft.com.br',
|
42
|
+
:first_name => 'admin',
|
43
|
+
:last_name => 'admin',
|
44
|
+
:phone => '11 12212122',
|
45
|
+
:date_of_birth => 22.years.ago,
|
46
|
+
:cpf => CPF.generate,
|
47
|
+
:password_confirmation => nil,
|
48
|
+
:login => nil
|
49
|
+
}
|
50
|
+
|
51
|
+
if ENV['AUTO_ACCEPT']
|
52
|
+
puts 'User will be created with the properties:'
|
53
|
+
puts attributes
|
54
|
+
else
|
55
|
+
puts 'Create the admin user (press enter for defaults).'
|
56
|
+
attributes = {
|
57
|
+
:email => prompt_for_admin_field('Email', 'ADMIN_EMAIL', 'spree@example.com'),
|
58
|
+
:password => prompt_for_admin_password,
|
59
|
+
:first_name => prompt_for_admin_field('First Name', 'ADMIN_FIRST_NAME', 'admin'),
|
60
|
+
:last_name => prompt_for_admin_field('Last Name', 'ADMIN_LAST_NAME', 'admin'),
|
61
|
+
:phone => prompt_for_admin_field('Phone', 'ADMIN_PHONE', '11 12212122'),
|
62
|
+
:date_of_birth => prompt_for_admin_field('Date Of Birth', 'ADMIN_DATE_OF_BIRTH', 22.years.ago),
|
63
|
+
:cpf => prompt_for_admin_field('CPF', 'ADMIN_CPF', CPF.generate)
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
attributes[:password_confirmation] = attributes[:password]
|
68
|
+
attributes[:login] = attributes[:email]
|
69
|
+
|
70
|
+
load 'spree/user.rb'
|
71
|
+
|
72
|
+
if Spree::User.find_by_email(attributes[:email])
|
73
|
+
say "\nWARNING: There is already a user with the email: #{attributes[:email]}, so no account changes were made. If you wish to create an additional admin user, please run rake spree_auth:admin:create again with a different email.\n\n"
|
74
|
+
else
|
75
|
+
admin = Spree::User.new(attributes)
|
76
|
+
if admin.save
|
77
|
+
role = Spree::Role.find_or_create_by(name: 'admin')
|
78
|
+
admin.spree_roles << role
|
79
|
+
admin.save
|
80
|
+
admin.generate_spree_api_key!
|
81
|
+
say "Done!"
|
82
|
+
else
|
83
|
+
say "There was some problems with persisting new admin user:"
|
84
|
+
admin.errors.full_messages.each do |error|
|
85
|
+
say error
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
if Spree::User.admin.empty?
|
92
|
+
create_admin_user
|
93
|
+
else
|
94
|
+
puts 'Admin user has already been previously created.'
|
95
|
+
if agree('Would you like to create a new admin user? (yes/no)')
|
96
|
+
create_admin_user
|
97
|
+
else
|
98
|
+
puts 'No admin user created.'
|
99
|
+
end
|
100
|
+
end
|
data/db/seeds.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module SpreeBrCommon
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
|
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_br_common\n"
|
9
|
+
append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/spree_br_common\n"
|
10
|
+
end
|
11
|
+
|
12
|
+
def add_stylesheets
|
13
|
+
inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/spree_br_common\n", :before => /\*\//, :verbose => true
|
14
|
+
inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/spree_br_common\n", :before => /\*\//, :verbose => true
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_migrations
|
18
|
+
run 'bundle exec rake railties:install:migrations FROM=spree_br_common'
|
19
|
+
end
|
20
|
+
|
21
|
+
def run_migrations
|
22
|
+
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
|
23
|
+
if run_migrations
|
24
|
+
run 'bundle exec rake db:migrate'
|
25
|
+
else
|
26
|
+
puts 'Skipping rake db:migrate, don\'t forget to run it!'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module SpreeBrCommon
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
require 'spree/core'
|
4
|
+
isolate_namespace Spree
|
5
|
+
engine_name 'spree_br_common'
|
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,89 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Checkout', type: :feature, inaccessible: true do
|
4
|
+
include_context 'checkout setup'
|
5
|
+
|
6
|
+
let!(:city) { create(:city, state: Spree::State.first!) }
|
7
|
+
|
8
|
+
context 'visitor makes checkout as guest without registration' do
|
9
|
+
before(:each) do
|
10
|
+
stock_location.stock_items.update_all(count_on_hand: 1)
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'full checkout', :vcr do
|
14
|
+
before do
|
15
|
+
shipping_method.calculator.update!(preferred_amount: 10)
|
16
|
+
mug.shipping_category = shipping_method.shipping_categories.first
|
17
|
+
mug.save!
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'does not break the per-item shipping method calculator', :js => true do
|
21
|
+
add_mug_to_cart
|
22
|
+
click_button 'Checkout'
|
23
|
+
|
24
|
+
fill_in 'order_email', :with => 'test@example.com'
|
25
|
+
click_button 'Continue'
|
26
|
+
|
27
|
+
fill_in_address
|
28
|
+
click_button 'Save and Continue'
|
29
|
+
|
30
|
+
expect(page).not_to have_content("undefined method `promotion'")
|
31
|
+
click_button 'Save and Continue'
|
32
|
+
expect(page).to have_content('Shipping total: $10.00')
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'in Brazil' do
|
36
|
+
before do
|
37
|
+
brazil = create(:country, name: 'Brasil')
|
38
|
+
minas_gerais_state = create(:state, abbr: 'MG', name: 'Minas Gerais', country: brazil)
|
39
|
+
minas_gerais_city = create(:city, name: 'Minas Gerais', state: minas_gerais_state)
|
40
|
+
@sao_paulo_state = create(:state, abbr: 'SP', name: 'São Paulo', country: brazil)
|
41
|
+
@sao_paulo_city = create(:city, name: 'São Paulo', state: @sao_paulo_state)
|
42
|
+
|
43
|
+
Spree::Config[:default_country_id] = brazil.id
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should autocomplete zipcode', :js => true do
|
47
|
+
add_mug_to_cart
|
48
|
+
click_button 'Checkout'
|
49
|
+
|
50
|
+
fill_in 'order_email', :with => 'test@example.com'
|
51
|
+
click_button 'Continue'
|
52
|
+
|
53
|
+
address = 'order_bill_address_attributes'
|
54
|
+
fill_in "#{address}_zipcode", with: '04089000'
|
55
|
+
|
56
|
+
wait_for_ajax
|
57
|
+
|
58
|
+
expect(find_by_id("#{address}_address1").value).to eq('Alameda dos Maracatins')
|
59
|
+
expect(find_by_id("#{address}_district").value).to eq('Indianópolis')
|
60
|
+
expect(find_by_id("#{address}_state_id").value).to eq(@sao_paulo_state.id.to_s)
|
61
|
+
expect(find_by_id("#{address}_city_id").value).to eq(@sao_paulo_city.id.to_s)
|
62
|
+
end
|
63
|
+
|
64
|
+
after do
|
65
|
+
Spree::Config[:default_country_id] = nil
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def fill_in_address
|
72
|
+
address = 'order_bill_address_attributes'
|
73
|
+
fill_in "#{address}_firstname", with: 'Ryan'
|
74
|
+
fill_in "#{address}_lastname", with: 'Bigg'
|
75
|
+
fill_in "#{address}_address1", with: 'Swan Street'
|
76
|
+
fill_in "#{address}_number", with: '143'
|
77
|
+
fill_in "#{address}_district", with: 'Carville'
|
78
|
+
select 'Alabama', from: "#{address}_state_id"
|
79
|
+
select city.name, from: "#{address}_city_id"
|
80
|
+
fill_in "#{address}_zipcode", with: '12345'
|
81
|
+
fill_in "#{address}_phone", with: '(555) 555-5555'
|
82
|
+
end
|
83
|
+
|
84
|
+
def add_mug_to_cart
|
85
|
+
visit spree.root_path
|
86
|
+
click_link mug.name
|
87
|
+
click_button 'add-to-cart-button'
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Accounts', type: :feature, inaccessible: true, js: true do
|
4
|
+
def login_as(user)
|
5
|
+
visit spree.login_path
|
6
|
+
fill_in 'Email', with: user.email
|
7
|
+
fill_in 'Password', with: user.password
|
8
|
+
click_button 'Login'
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:user) { create(:user) }
|
12
|
+
|
13
|
+
before do
|
14
|
+
login_as(user)
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'editing' do
|
18
|
+
scenario 'should rename user with success' do
|
19
|
+
Spree::Auth::Config.set(signout_after_password_change: false)
|
20
|
+
click_link 'My Account'
|
21
|
+
|
22
|
+
expect(page).to have_text user.email
|
23
|
+
click_link 'Edit'
|
24
|
+
fill_in 'First Name', with: 'Diego'
|
25
|
+
fill_in 'Last Name', with: 'Domingues'
|
26
|
+
fill_in Spree.t(:date_of_birth), with: 19.years.ago.strftime(Spree.t('date_picker.format', default: '%Y/%m/%d'))
|
27
|
+
click_button 'Update'
|
28
|
+
|
29
|
+
expect(page).to have_text 'Diego Domingues'
|
30
|
+
expect(page).to have_text 'Account updated'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'showing' do
|
35
|
+
scenario 'should show details of user' do
|
36
|
+
click_link 'My Account'
|
37
|
+
|
38
|
+
expect(page).to have_text user.full_name
|
39
|
+
expect(page).to have_text user.cpf_formatted
|
40
|
+
expect(page).to have_text user.phone
|
41
|
+
expect(page).to have_text user.alternative_phone if user.alternative_phone.present?
|
42
|
+
expect(page).to have_text user.date_of_birth.to_date
|
43
|
+
expect(page).to have_text user.email
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Sign Up', type: :feature, inaccessible: true do
|
4
|
+
context 'with valid data' do
|
5
|
+
scenario 'create a user with success', js: true do
|
6
|
+
visit spree.signup_path
|
7
|
+
|
8
|
+
fill_in Spree.t(:first_name), with: 'Carlos'
|
9
|
+
fill_in Spree.t(:last_name), with: 'Andrade'
|
10
|
+
fill_in Spree.t(:cpf), with: '53229124367'
|
11
|
+
fill_in Spree.t(:date_of_birth), with: 18.years.ago.strftime(Spree.t('date_picker.format', default: '%Y/%m/%d'))
|
12
|
+
fill_in Spree.t(:email), with: 'email@person.com'
|
13
|
+
fill_in Spree.t(:phone), with: '11 12211221'
|
14
|
+
fill_in Spree.t(:alternative_phone), with: '11 12211221'
|
15
|
+
fill_in Spree.t(:password), with: 'password'
|
16
|
+
fill_in 'Password Confirmation', with: 'password'
|
17
|
+
|
18
|
+
click_button 'Create'
|
19
|
+
|
20
|
+
expect(page).to have_text 'You have signed up successfully.'
|
21
|
+
expect(Spree::User.count).to eq(1)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|