spree_retailers 0.70.0.0 → 1.0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/.travis.yml +5 -1
  2. data/LICENSE +1 -1
  3. data/README.md +66 -26
  4. data/Versionfile +1 -0
  5. data/app/controllers/spree/admin/retailers_controller.rb +19 -0
  6. data/app/controllers/spree/retailers_controller.rb +11 -0
  7. data/app/helpers/{retailers_helper.rb → spree/retailers_helper.rb} +4 -7
  8. data/app/models/{retailer.rb → spree/retailer.rb} +1 -1
  9. data/app/overrides/spree_retailers.rb +2 -2
  10. data/app/views/{admin → spree/admin}/hooks/_retailers_tab.html.erb +0 -0
  11. data/app/views/{admin → spree/admin}/retailers/_form.html.erb +0 -0
  12. data/app/views/{admin → spree/admin}/retailers/edit.html.erb +2 -0
  13. data/app/views/{admin → spree/admin}/retailers/index.html.erb +3 -5
  14. data/app/views/{admin → spree/admin}/retailers/new.html.erb +2 -1
  15. data/app/views/{admin → spree/admin}/retailers/show.html.erb +0 -0
  16. data/app/views/{retailers → spree/retailers}/_list.html.erb +0 -0
  17. data/app/views/{retailers → spree/retailers}/_retailer.html.erb +0 -0
  18. data/app/views/{retailers → spree/retailers}/index.html.erb +1 -1
  19. data/config/locales/en.yml +8 -12
  20. data/config/routes.rb +5 -5
  21. data/{lib/generators/templates/db/migrate/install_spree_retailers.rb → db/migrate/20111213000442_install_spree_retailers.rb} +0 -0
  22. data/db/migrate/20111213000450_add_spree_namespace_to_retailers.rb +5 -0
  23. data/lib/generators/spree_retailers/install_generator.rb +2 -20
  24. data/lib/spree_retailers.rb +4 -21
  25. data/lib/spree_retailers/engine.rb +21 -0
  26. data/lib/spree_retailers/version.rb +1 -1
  27. data/spree_retailers.gemspec +6 -6
  28. data/test/dummy_hooks/before_migrate.rb +19 -10
  29. data/test/dummy_hooks/templates/spree_user_error_fix.rb +3 -0
  30. data/test/dummy_hooks/templates/store/screen.css +749 -0
  31. data/test/fixtures/{retailers.yml → spree/retailers.yml} +3 -3
  32. data/test/fixtures/{states.yml → spree/states.yml} +0 -0
  33. data/test/integration/spree/admin/retailers_integration_test.rb +88 -0
  34. data/test/integration/spree/retailers_integration_test.rb +21 -0
  35. data/test/support/files/1.jpg +0 -0
  36. data/test/support/integration_case.rb +70 -0
  37. data/test/test_helper.rb +22 -5
  38. data/test/unit/{retailer_test.rb → spree/retailer_test.rb} +3 -10
  39. metadata +68 -53
  40. data/app/controllers/admin/retailers_controller.rb +0 -19
  41. data/app/controllers/retailers_controller.rb +0 -11
  42. data/lib/spree_core/action_callbacks.rb +0 -26
  43. data/test/functional/admin/retailers_controller_test.rb +0 -54
  44. data/test/functional/retailers_controller_test.rb +0 -12
@@ -5,4 +5,8 @@ rvm:
5
5
  - rbx
6
6
  - ree
7
7
 
8
- script: "bundle exec dummier && bundle exec rake test"
8
+ before_script:
9
+ - "sh -e /etc/init.d/xvfb start"
10
+ - "bundle exec dummier"
11
+
12
+ script: "DISPLAY=:99.0 bundle exec rake"
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Spencer Steffen and Citrus Media Group.
1
+ Copyright (c) 2011 - 2012 Spencer Steffen and Citrus Media Group.
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without modification,
data/README.md CHANGED
@@ -1,51 +1,91 @@
1
- Spree Retailers
2
- ===============
1
+ # Spree Retailers [![Build Status](https://secure.travis-ci.org/citrus/spree_retailers.png)](http://travis-ci.org/citrus/spree_retailers)
3
2
 
4
3
  Spree Retailers is a Spree extension for listing your company's retail stores on your web site.
5
4
 
6
5
 
6
+ ------------------------------------------------------------------------------
7
7
  Installation
8
- ------------
8
+ ------------------------------------------------------------------------------
9
9
 
10
10
  As usual, add 'spree_retailers' to your Gemfile and run bundle install:
11
-
12
- # Spree 0.70.x
13
- gem 'spree_retailers', '0.70.0.0'
14
-
15
- # Spree 0.50.x, 0.60.x
16
- gem 'spree_retailers', '0.50.0.0'
17
-
18
- # Spree 0.40.x
19
- gem 'spree_retailers', '0.40.0.4'
20
-
21
- # install from git
22
- gem 'spree_retailers', :git => 'git://github.com/citrus/spree_retailers.git'
11
+
12
+ ```ruby
13
+ # Spree 1.0.x
14
+ gem 'spree_retailers', '1.0.0.0'
15
+
16
+ # Spree 0.70.x
17
+ gem 'spree_retailers', '0.70.0.0'
18
+
19
+ # Spree 0.50.x, 0.60.x
20
+ gem 'spree_retailers', '0.50.0.0'
21
+
22
+ # Spree 0.40.x
23
+ gem 'spree_retailers', '0.40.0.4'
24
+
25
+ # install from source
26
+ gem 'spree_retailers', :git => 'git://github.com/citrus/spree_retailers.git'
27
+ ```
23
28
 
24
29
 
25
30
  Next, copy the migration file to your project:
26
31
 
27
- # Spree 0.40.x, 0.50.x and 0.60.x
28
- rake spree_retailers:install
29
-
30
- # 0.70.x and above
31
- rails g spree_retailers:install
32
+ ```bash
33
+ # Spree 0.40.x, 0.50.x and 0.60.x
34
+ rake spree_retailers:install
35
+
36
+ # 0.70.x and above
37
+ rails g spree_retailers:install
38
+ ```
32
39
 
33
40
 
34
41
  Now, migrate your database with:
35
42
 
36
- rake db:migrate
43
+ ```bash
44
+ rake db:migrate
45
+ ```
46
+
47
+ ------------------------------------------------------------------------------
48
+ Testing
49
+ ------------------------------------------------------------------------------
50
+
51
+ If you'd like to run tests:
52
+
53
+ ```bash
54
+ git clone git://github.com/citrus/spree_retailers.git
55
+ cd spree_retailers
56
+ bundle install
57
+ bundle exec dummier
58
+ bundle exec rake
59
+ ```
60
+
61
+
62
+ ------------------------------------------------------------------------------
63
+ Demo
64
+ ------------------------------------------------------------------------------
65
+
66
+ If you'd like a demo of spree_retailers:
67
+
68
+ ```bash
69
+ git clone git://github.com/citrus/spree_retailers.git
70
+ cd spree_retailers
71
+ cp test/dummy_hooks/after_migrate.rb.sample test/dummy_hooks/after_migrate.rb
72
+ bundle install
73
+ bundle exec dummier
74
+ cd test/dummy
75
+ rails s
76
+ ```
37
77
 
38
78
 
79
+ ------------------------------------------------------------------------------
39
80
  To Do
40
- -----
81
+ ------------------------------------------------------------------------------
41
82
 
42
- * Write controller tests
43
- * Write admin tests
44
83
  * Google map integration (we're already geocoding, so why not?)
45
84
  * Add (better) International Support
46
85
 
47
86
 
87
+ ------------------------------------------------------------------------------
48
88
  License
49
- -------
89
+ ------------------------------------------------------------------------------
50
90
 
51
- Copyright (c) 2011 Spencer Steffen and Citrus, released under the New BSD License All rights reserved.
91
+ Copyright (c) 2011 - 2012 Spencer Steffen and Citrus, released under the New BSD License All rights reserved.
@@ -1,3 +1,4 @@
1
+ "1.0.x" => { :version => "1.0.0.0" }
1
2
  "0.70.x" => { :version => "0.70.0.0" }
2
3
  "0.60.x" => { :version => "0.50.0.0" }
3
4
  "0.50.x" => { :version => "0.50.0.0" }
@@ -0,0 +1,19 @@
1
+ class Spree::Admin::RetailersController < Spree::Admin::ResourceController
2
+
3
+ before_filter :get_locations, :except => [:index, :destroy]
4
+
5
+ private
6
+
7
+ def collection
8
+ params[:search] ||= {}
9
+ params[:search][:meta_sort] ||= "name.asc"
10
+ @search = super.search(params[:search])
11
+ @collection = @search.page(params[:page]).per(Spree::Config[:orders_per_page])
12
+ end
13
+
14
+ def get_locations
15
+ @countries = Spree::Country.all.collect{|country| country.name }.sort
16
+ @states = Spree::State.where(:country_id => 214).collect{|state| [state.name, state.abbr] }.sort
17
+ end
18
+
19
+ end
@@ -0,0 +1,11 @@
1
+ class Spree::RetailersController < Spree::BaseController
2
+
3
+ def index
4
+ @retailers = Spree::Retailer.order(:country, :state, :name)
5
+ @states = {}
6
+ Spree::State.where(:abbr => @retailers.collect(&:state).uniq).all.each do |state|
7
+ @states[state.abbr] = state.name
8
+ end
9
+ end
10
+
11
+ end
@@ -1,12 +1,9 @@
1
- module RetailersHelper
1
+ module Spree::RetailersHelper
2
2
 
3
3
  def state_nav_helper(retailers=[])
4
4
  states = retailers.collect(&:state).uniq
5
-
6
- puts states
7
-
8
- return "" unless 1 < states.length
5
+ return "" if states.empty?
9
6
  states.collect{|state| link_to(state, "##{state.downcase}") }.join(" | ").html_safe
10
- end
7
+ end
11
8
 
12
- end
9
+ end
@@ -1,4 +1,4 @@
1
- class Retailer < ActiveRecord::Base
1
+ class Spree::Retailer < ActiveRecord::Base
2
2
 
3
3
  validates :name, :address, :city, :presence => true
4
4
  validates :state, :zipcode, :presence => true, :if => Proc.new{|record| record.country == "United States" }
@@ -1,5 +1,5 @@
1
- Deface::Override.new(:virtual_path => "layouts/admin",
1
+ Deface::Override.new(:virtual_path => "spree/layouts/admin",
2
2
  :name => "converted_admin_tabs_for_spree_retailers",
3
3
  :insert_bottom => "[data-hook='admin_tabs'], #admin_tabs[data-hook]",
4
- :partial => "admin/hooks/retailers_tab",
4
+ :partial => "spree/admin/hooks/retailers_tab",
5
5
  :disabled => false)
@@ -1,5 +1,7 @@
1
1
  <h1>Edit Retailer</h1>
2
2
 
3
+ <%= render "spree/shared/error_messages", :target => @retailer %>
4
+
3
5
  <%= form_for(@retailer, :url => object_url, :html => { :multipart => true, :method => :put }) do |f| %>
4
6
  <%= render :partial => "form", :locals => { :f => f } %>
5
7
  <p class="form-buttons">
@@ -29,7 +29,7 @@
29
29
  <td><%= retailer.state %></td>
30
30
  <td><%= retailer.email %></td>
31
31
  <td><%= number_to_phone retailer.phone %></td>
32
- <td>
32
+ <td class="actions">
33
33
  <%= link_to_edit retailer %> &nbsp;
34
34
  <%= link_to_delete retailer %> &nbsp;
35
35
  </td>
@@ -41,13 +41,11 @@
41
41
  <%= paginate @collection %>
42
42
 
43
43
 
44
-
45
-
46
44
  <% content_for :sidebar do %>
47
45
  <div class="box">
48
46
  <h3><%= t(:search) %></h3>
49
47
 
50
- <% @retailer = Retailer.metasearch %>
48
+ <% @retailer = Spree::Retailer.metasearch %>
51
49
  <%= form_for [:admin, @retailer] do |f| %>
52
50
  <p>
53
51
  <label><%= t '.name_contains' %></label><br />
@@ -68,4 +66,4 @@
68
66
  <p><%= button t("search") %></p>
69
67
  <% end %>
70
68
  </div>
71
- <% end %>
69
+ <% end %>
@@ -1,5 +1,7 @@
1
1
  <h1>New Retailer</h1>
2
2
 
3
+ <%= render "spree/shared/error_messages", :target => @retailer %>
4
+
3
5
  <%= form_for(@retailer, :url => collection_url, :html => { :multipart => true }) do |f| %>
4
6
  <%= render :partial => "form", :locals => { :f => f } %>
5
7
 
@@ -7,4 +9,3 @@
7
9
  <%= button t("create") %> <%= link_to t('cancel'), collection_url %>
8
10
  </p>
9
11
  <% end %>
10
-
@@ -1,6 +1,6 @@
1
1
  <h1><%= t('retailers') %></h1>
2
2
 
3
- <div class="left">
3
+ <div class="left" data-hook="retailers-index">
4
4
  <p>Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Proin vel ante a orci tempus eleifend ut et magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus luctus urna sed urna ultricies ac tempor dui sagittis. In condimentum facilisis porta. Sed nec diam eu diam mattis viverra. Nulla fringilla, orci ac euismod semper, magna diam porttitor mauris, quis sollicitudin sapien justo in libero. Vestibulum mollis mauris enim. Morbi euismod magna ac lorem rutrum elementum. Donec viverra auctor lobortis. Pellentesque eu est.</p>
5
5
  </div>
6
6
 
@@ -2,16 +2,12 @@ en:
2
2
 
3
3
  retailer: Retailer
4
4
  retailers: Retailers
5
-
6
- successfully_created: "%{resource} was successfully created."
7
- successfully_updated: "%{resource} was successfully updated."
8
- successfully_removed: "%{resource} was successfully removed."
9
5
 
10
-
11
- admin:
12
- retailers:
13
- index:
14
- name_contains: Name Contains
15
- email_contains: Email Contains
16
- country_contains: Country Contains
17
- state_contains: State Contains
6
+ spree:
7
+ admin:
8
+ retailers:
9
+ index:
10
+ name_contains: Name Contains
11
+ email_contains: Email Contains
12
+ country_contains: Country Contains
13
+ state_contains: State Contains
@@ -1,10 +1,10 @@
1
- Rails.application.routes.draw do
2
-
3
- get '/retailers/:id/:country' => 'retailers#index', :as => :country_retailers
4
- resources :retailers, :only => :index
1
+ Spree::Core::Engine.routes.draw do
5
2
 
6
3
  namespace :admin do
7
4
  resources :retailers
8
5
  end
9
6
 
10
- end
7
+ get '/retailers/:id/:country' => 'retailers#index', :as => :country_retailers
8
+ resources :retailers, :only => :index
9
+
10
+ end
@@ -0,0 +1,5 @@
1
+ class AddSpreeNamespaceToRetailers < ActiveRecord::Migration
2
+ def change
3
+ rename_table :retailers, :spree_retailers
4
+ end
5
+ end
@@ -2,31 +2,13 @@ module SpreeRetailers
2
2
  module Generators
3
3
  class InstallGenerator < Rails::Generators::Base
4
4
 
5
- include Rails::Generators::Migration
6
-
7
- def self.count
8
- @count ||= 0
9
- (@count += 1) * 3
10
- end
11
-
12
- def self.next_migration_number(path)
13
- @time ||= Time.new.utc
14
- if ActiveRecord::Base.timestamped_migrations
15
- (@time + self.count).strftime("%Y%m%d%H%M%S")
16
- else
17
- "%.3d" % (current_migration_number(dirname) + 1)
18
- end
19
- end
20
-
21
5
  desc "Installs required migrations for spree_retailers"
22
6
  source_root File.expand_path("../../templates/db/migrate", __FILE__)
23
7
 
24
8
  def copy_migrations
25
-
26
- migration_template "install_spree_retailers.rb", "db/migrate/install_spree_retailers.rb"
27
-
9
+ rake "spree_retailers:install:migrations"
28
10
  end
29
11
 
30
12
  end
31
13
  end
32
- end
14
+ end
@@ -1,25 +1,8 @@
1
- require 'spree_core'
1
+ require "spree_core"
2
+ require "geokit"
2
3
 
3
- require 'geokit'
4
- require 'spree_retailers/version'
4
+ require "spree_retailers/version"
5
+ require "spree_retailers/engine"
5
6
 
6
7
  module SpreeRetailers
7
-
8
- class Engine < Rails::Engine
9
-
10
- config.to_prepare do
11
- #loads application's model / class decorators
12
- Dir.glob File.expand_path("../../app/**/*_decorator*.rb") do |c|
13
- Rails.configuration.cache_classes ? require(c) : load(c)
14
- end
15
-
16
- #loads application's deface view overrides
17
- Dir.glob File.expand_path("../../app/overrides/*.rb", __FILE__) do |c|
18
- Rails.application.config.cache_classes ? require(c) : load(c)
19
- end
20
- end
21
-
22
- config.autoload_paths += %W(#{config.root}/lib)
23
-
24
- end
25
8
  end
@@ -0,0 +1,21 @@
1
+ module SpreeRetailers
2
+ class Engine < Rails::Engine
3
+
4
+ engine_name "spree_retailers"
5
+
6
+ config.to_prepare do
7
+ #loads application's model / class decorators
8
+ Dir.glob File.expand_path("../../../app/**/*_decorator.rb", __FILE__) do |c|
9
+ Rails.configuration.cache_classes ? require(c) : load(c)
10
+ end
11
+
12
+ #loads application's deface view overrides
13
+ Dir.glob File.expand_path("../../../app/overrides/**/*.rb", __FILE__) do |c|
14
+ Rails.application.config.cache_classes ? require(c) : load(c)
15
+ end
16
+ end
17
+
18
+ config.autoload_paths += %W(#{config.root}/lib)
19
+
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module SpreeRetailers
2
- VERSION = "0.70.0.0"
2
+ VERSION = "1.0.0.0"
3
3
  end
@@ -20,12 +20,12 @@ Gem::Specification.new do |s|
20
20
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
21
  s.require_paths = ["lib"]
22
22
 
23
- s.add_dependency('spree_core', '>= 0.70.0')
24
- s.add_dependency('mail', '>= 2.2.0')
25
- s.add_dependency('geokit', '>= 1.5.0')
23
+ s.add_dependency('spree_core', '~> 1.0.0')
24
+ s.add_dependency('geokit', '~> 1.6.5')
26
25
 
27
- s.add_development_dependency('dummier', '>= 0.2.4')
28
- s.add_development_dependency('shoulda', '>= 3.0.0.beta2')
29
- s.add_development_dependency('sqlite3', '>= 1.3.2')
26
+ s.add_development_dependency('dummier', '>= 0.3.0')
27
+ s.add_development_dependency('shoulda', '>= 3.0.0.beta2')
28
+ s.add_development_dependency('capybara', '>= 1.1.2')
29
+ s.add_development_dependency('sqlite3', '>= 1.3.5')
30
30
 
31
31
  end
@@ -1,13 +1,22 @@
1
- # run installer generators
2
- run "rails g spree_retailers:install"
3
- run "rails g spree:site"
1
+ # Install spree core and migrate db
2
+ rake "spree:install:migrations"
3
+
4
+ # Mount the spree core engine routes
5
+ insert_into_file File.join('config', 'routes.rb'), :after => "Application.routes.draw do\n" do
6
+ " # Mount Spree's routes\n mount Spree::Core::Engine, :at => '/'\n"
7
+ end
8
+
9
+ # Fix uninitialized constant Spree::User::DestroyWithOrdersError
10
+ template "spree_user_error_fix.rb", "config/initializers/spree_user_error_fix.rb"
4
11
 
5
- # remove all stylesheets except core
12
+ # Remove all stylesheets except core
6
13
  %w(admin store).each do |ns|
7
- js = "app/assets/javascripts/#{ns}/all.js"
8
- css = "app/assets/stylesheets/#{ns}/all.css"
9
- remove_file js
10
- remove_file css
11
- template "#{ns}/all.js", js
12
- template "#{ns}/all.css", css
14
+ template "#{ns}/all.js", "app/assets/javascripts/#{ns}/all.js", :force => true
15
+ template "#{ns}/all.css", "app/assets/stylesheets/#{ns}/all.css", :force => true
13
16
  end
17
+
18
+ # Fix sass load error by using the converted css file
19
+ template "store/screen.css", "app/assets/stylesheets/store/screen.css"
20
+
21
+ # Install spree_retailers
22
+ run "rails g spree_retailers:install"