spree 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of spree might be problematic. Click here for more details.

data/db/seeds.rb ADDED
@@ -0,0 +1,10 @@
1
+ def yaml_to_database(fixture, path)
2
+ require 'active_record/fixtures'
3
+ ActiveRecord::Base.establish_connection(RAILS_ENV)
4
+ tables = Dir.new(path).entries.select{|e| e =~ /(.+)?\.yml/}.collect{|c| c.split('.').first}
5
+ Fixtures.create_fixtures(path, tables)
6
+ end
7
+
8
+ # load setup data from seeds
9
+ fixture = "default"
10
+ yaml_to_database(fixture, "#{SPREE_ROOT}/db/#{fixture}")
data/lib/spree.rb CHANGED
@@ -9,7 +9,7 @@ unless defined? Spree::Version
9
9
  module Version
10
10
  Major = '0'
11
11
  Minor = '8'
12
- Tiny = '4'
12
+ Tiny = '5'
13
13
 
14
14
  class << self
15
15
  def to_s
data/lib/spree/setup.rb CHANGED
@@ -15,8 +15,10 @@ module Spree
15
15
  setup
16
16
  end
17
17
  def create_admin_user
18
- raise "Cannot create a second admin user." unless User.count == 0
19
18
  new.create_admin_user
19
+ end
20
+ def load_sample_data
21
+ new.load_sample_data
20
22
  end
21
23
  end
22
24
 
@@ -26,10 +28,16 @@ module Spree
26
28
  # make sure the product images directory exists
27
29
  FileUtils.mkdir_p "#{RAILS_ROOT}/public/images/products/"
28
30
 
29
- @config = config
30
- @admin = create_admin_user(config[:admin_password], config[:admin_email])
31
- load_sample_data if sample_data?
32
- announce "Finished.\n\n"
31
+ @config = config
32
+ load_default_data unless Country.count > 0
33
+ create_admin_user(config[:admin_password], config[:admin_email]) unless User.first(:include => :roles, :conditions => ["roles.name = 'admin'"])
34
+
35
+ if RAILS_ENV == 'production' and Product.count > 0
36
+ announce "WARNING: Running bootstrap in production mode and there is already existing product data. Sample data will not be loaded."
37
+ else
38
+ load_sample_data if sample_data?
39
+ end
40
+ announce "Bootstrap Complete.\n\n"
33
41
  end
34
42
 
35
43
  def create_admin_user(password=nil, email=nil)
@@ -45,13 +53,22 @@ module Spree
45
53
  :email => email,
46
54
  :login => email
47
55
  }
48
- admin = User.create(attributes)
49
56
 
50
- # create an admin role and and assign the admin user to that role
51
- role = Role.create(:name => 'admin')
52
- admin.roles << role
53
- admin.save
54
- admin
57
+ if User.find_by_login(email)
58
+ say "\nWARNING: There is already a user with the email: #{email}, so no account changes were made. If you wish to create an additional admin user, please run rake db:admin:create again with a different email.\n\n"
59
+ else
60
+ admin = User.create(attributes)
61
+
62
+ # create an admin role and and assign the admin user to that role
63
+ role = Role.find_or_create_by_name "admin"
64
+ admin.roles << role
65
+ admin.save
66
+ end
67
+ end
68
+
69
+ # Loads default data necessary for basic spree functionality
70
+ def load_default_data
71
+ Rake::Task["db:seed"].invoke
55
72
  end
56
73
 
57
74
  # Uses a special set of fixtures to load sample data
@@ -83,7 +100,7 @@ module Spree
83
100
  end
84
101
  end
85
102
 
86
- announce "Sample products have been loaded into to the store"
103
+ announce "Sample data has been loaded"
87
104
  end
88
105
 
89
106
  private
@@ -112,7 +129,7 @@ module Spree
112
129
  def sample_data?
113
130
  return true if ENV['AUTO_ACCEPT']
114
131
  sample = ask('Load Sample Data? [y]: ', String) do |q|
115
- q.echo = false
132
+ q.echo = true
116
133
  q.whitespace = :strip
117
134
  end
118
135
  sample == "" or sample == "y" or sample == "yes" or sample == "true"
@@ -27,35 +27,52 @@ namespace :db do
27
27
  require 'authlogic'
28
28
  Spree::Setup.create_admin_user
29
29
  end
30
- end
30
+ end
31
31
 
32
+ desc 'Create the database, load the schema, and initialize with the seed data'
33
+ task :setup => [ 'db:create', 'db:schema:load', 'db:seed' ]
34
+
35
+ desc 'Load the seed data from db/seeds.rb'
36
+ task :seed => :environment do
37
+ seed_file = File.join(SPREE_ROOT, 'db', 'seeds.rb')
38
+ load(seed_file) if File.exist?(seed_file)
39
+ end
40
+
41
+ desc 'Load the sample fixture data from db/sample'
42
+ task :sample => :environment do
43
+ require 'spree/setup'
44
+ Spree::Setup.load_sample_data
45
+ end
46
+
32
47
  desc "Bootstrap your database for Spree."
33
48
  task :bootstrap => :environment do
34
49
  require 'highline/import'
35
50
  require 'authlogic'
36
51
 
37
- raise "Cannot bootstrap in production mode (for saftey reasons.)" unless %w[demo development test].include? RAILS_ENV
38
- if ENV['AUTO_ACCEPT'] or agree("This task will destroy any data in the database. Are you sure you want to \ncontinue? [yn] ")
39
-
40
- ENV['SKIP_NAG'] = 'yes'
41
-
42
- # Remigrate
43
- Rake::Task["db:remigrate"].invoke
44
-
45
- require 'spree/setup'
46
-
47
- attributes = {}
48
- if ENV['AUTO_ACCEPT']
49
- attributes = {
50
- :admin_password => "spree",
51
- :admin_email => "spree@example.com"
52
- }
52
+ # remigrate unless production mode (as saftey check)
53
+ if %w[demo development test].include? RAILS_ENV
54
+ if ENV['AUTO_ACCEPT'] or agree("This task will destroy any data in the database. Are you sure you want to \ncontinue? [yn] ")
55
+ ENV['SKIP_NAG'] = 'yes'
56
+ Rake::Task["db:remigrate"].invoke
57
+ else
58
+ say "Task cancelled."
59
+ exit
53
60
  end
54
-
55
- Spree::Setup.bootstrap attributes
56
- else
57
- say "Task cancelled."
58
- exit
61
+ else
62
+ say "NOTE: Bootstrap in production mode will not drop database before migration"
63
+ Rake::Task["db:migrate"].invoke
59
64
  end
65
+
66
+ require 'spree/setup'
67
+
68
+ attributes = {}
69
+ if ENV['AUTO_ACCEPT']
70
+ attributes = {
71
+ :admin_password => "spree",
72
+ :admin_email => "spree@example.com"
73
+ }
74
+ end
75
+
76
+ Spree::Setup.bootstrap attributes
60
77
  end
61
78
  end
@@ -56,10 +56,9 @@ namespace 'spree' do
56
56
  files.exclude 'config/locomotive.yml'
57
57
  files.exclude 'config/lighttpd.conf'
58
58
  files.exclude 'config/mongrel_mimes.yml'
59
- files.exclude 'db/*.db'
59
+ files.exclude 'db/schema.db'
60
60
  files.exclude 'db/*.sqlite3'
61
61
  files.exclude 'db/*.sql'
62
- files.exclude 'db/*.rb'
63
62
  files.exclude /^doc/
64
63
  files.exclude 'log/*.log'
65
64
  files.exclude 'log/*.pid'
@@ -0,0 +1,16 @@
1
+ ActiveRecord::Schema.define(:version => 2) do
2
+
3
+ create_table :comments, :force => true do |t|
4
+ t.integer :photo_id
5
+ t.string :author
6
+ t.text :body
7
+ t.timestamps
8
+ end
9
+
10
+ create_table :photos, :force => true do |t|
11
+ t.string :title
12
+ t.text :description
13
+ t.timestamps
14
+ end
15
+
16
+ end
@@ -0,0 +1,78 @@
1
+ # This file is auto-generated from the current state of the database. Instead of editing this file,
2
+ # please use the migrations feature of Active Record to incrementally modify your database, and
3
+ # then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your database schema. If you need
6
+ # to create the application database on another system, you should be using db:schema:load, not running
7
+ # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
8
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
9
+ #
10
+ # It's strongly recommended to check this file into your version control system.
11
+
12
+ ActiveRecord::Schema.define(:version => 14) do
13
+
14
+ create_table "accounts", :force => true do |t|
15
+ t.string "name"
16
+ end
17
+
18
+ create_table "comments", :force => true do |t|
19
+ t.integer "post_id"
20
+ t.string "author"
21
+ t.text "body"
22
+ end
23
+
24
+ create_table "images", :force => true do |t|
25
+ t.integer "user_id"
26
+ t.datetime "created_at"
27
+ t.datetime "updated_at"
28
+ end
29
+
30
+ create_table "options", :force => true do |t|
31
+ t.integer "product_id"
32
+ t.integer "account_id"
33
+ t.string "title"
34
+ end
35
+
36
+ create_table "personnel", :force => true do |t|
37
+ t.datetime "created_at"
38
+ t.datetime "updated_at"
39
+ end
40
+
41
+ create_table "photos", :force => true do |t|
42
+ t.string "title"
43
+ t.integer "account_id"
44
+ t.integer "personnel_id"
45
+ end
46
+
47
+ create_table "photos_tags", :force => true do |t|
48
+ t.integer "photo_id"
49
+ t.integer "tag_id"
50
+ end
51
+
52
+ create_table "posts", :force => true do |t|
53
+ t.string "title", :default => ""
54
+ t.text "body", :default => ""
55
+ end
56
+
57
+ create_table "products", :force => true do |t|
58
+ t.string "name"
59
+ end
60
+
61
+ create_table "projects", :force => true do |t|
62
+ t.string "title"
63
+ end
64
+
65
+ create_table "somethings", :force => true do |t|
66
+ t.string "title"
67
+ end
68
+
69
+ create_table "tags", :force => true do |t|
70
+ t.string "name"
71
+ end
72
+
73
+ create_table "users", :force => true do |t|
74
+ t.datetime "created_at"
75
+ t.datetime "updated_at"
76
+ end
77
+
78
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-02 00:00:00 -04:00
12
+ date: 2009-07-08 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -490,6 +490,12 @@ files:
490
490
  - config/spree_permissions.yml
491
491
  - CONTRIBUTORS
492
492
  - db
493
+ - db/default
494
+ - db/default/countries.yml
495
+ - db/default/roles.yml
496
+ - db/default/states.yml
497
+ - db/default/zone_members.yml
498
+ - db/default/zones.yml
493
499
  - db/migrate
494
500
  - db/migrate/001_create_addresses.rb
495
501
  - db/migrate/002_create_cart_items.rb
@@ -607,11 +613,9 @@ files:
607
613
  - db/sample/products.yml
608
614
  - db/sample/properties.yml
609
615
  - db/sample/prototypes.yml
610
- - db/sample/roles.yml
611
616
  - db/sample/shipments.yml
612
617
  - db/sample/shipping_categories.yml
613
618
  - db/sample/shipping_methods.yml
614
- - db/sample/states.yml
615
619
  - db/sample/tax_categories.yml
616
620
  - db/sample/taxonomies.yml
617
621
  - db/sample/taxons.yml
@@ -619,6 +623,8 @@ files:
619
623
  - db/sample/variants.yml
620
624
  - db/sample/zone_members.yml
621
625
  - db/sample/zones.yml
626
+ - db/schema.rb
627
+ - db/seeds.rb
622
628
  - INSTALL
623
629
  - lib
624
630
  - lib/annotatable.rb
@@ -2114,6 +2120,7 @@ files:
2114
2120
  - vendor/plugins/attribute_fu/test/comment_test.rb
2115
2121
  - vendor/plugins/attribute_fu/test/db
2116
2122
  - vendor/plugins/attribute_fu/test/db/database.yml
2123
+ - vendor/plugins/attribute_fu/test/db/schema.rb
2117
2124
  - vendor/plugins/attribute_fu/test/models
2118
2125
  - vendor/plugins/attribute_fu/test/models/comment.rb
2119
2126
  - vendor/plugins/attribute_fu/test/models/photo.rb
@@ -2429,6 +2436,7 @@ files:
2429
2436
  - vendor/plugins/resource_controller/test/db/migrate/012_create_users.rb
2430
2437
  - vendor/plugins/resource_controller/test/db/migrate/013_create_personnel.rb
2431
2438
  - vendor/plugins/resource_controller/test/db/migrate/014_add_personnel_id_to_photos.rb
2439
+ - vendor/plugins/resource_controller/test/db/schema.rb
2432
2440
  - vendor/plugins/resource_controller/test/log
2433
2441
  - vendor/plugins/resource_controller/test/Rakefile
2434
2442
  - vendor/plugins/resource_controller/test/script
data/db/sample/roles.yml DELETED
@@ -1,3 +0,0 @@
1
- user_role:
2
- id: 2
3
- name: user
data/db/sample/states.yml DELETED
@@ -1,204 +0,0 @@
1
- alabama:
2
- name: Alabama
3
- abbr: AL
4
- country_id: 214
5
- alaska:
6
- name: Alaska
7
- abbr: AK
8
- country_id: 214
9
- arizona:
10
- name: Arizona
11
- abbr: AZ
12
- country_id: 214
13
- arkansas:
14
- name: Arkansas
15
- abbr: AR
16
- country_id: 214
17
- california:
18
- name: California
19
- abbr: CA
20
- country_id: 214
21
- colorado:
22
- name: Colorado
23
- abbr: CO
24
- country_id: 214
25
- connecticut:
26
- name: Connecticut
27
- abbr: CT
28
- country_id: 214
29
- deleware:
30
- name: Delaware
31
- abbr: DE
32
- country_id: 214
33
- dc:
34
- name: District of Columbia
35
- abbr: DC
36
- country_id: 214
37
- florida:
38
- name: Florida
39
- abbr: FL
40
- country_id: 214
41
- georgia:
42
- name: Georgia
43
- abbr: GA
44
- country_id: 214
45
- hawaii:
46
- name: Hawaii
47
- abbr: HI
48
- country_id: 214
49
- idaho:
50
- name: Idaho
51
- abbr: ID
52
- country_id: 214
53
- illinois:
54
- name: Illinois
55
- abbr: IL
56
- country_id: 214
57
- indiana:
58
- name: Indiana
59
- abbr: IN
60
- country_id: 214
61
- iowa:
62
- name: Iowa
63
- abbr: IA
64
- country_id: 214
65
- kansas:
66
- name: Kansas
67
- abbr: KS
68
- country_id: 214
69
- kentucky:
70
- name: Kentucky
71
- abbr: KY
72
- country_id: 214
73
- louisiana:
74
- name: Louisiana
75
- abbr: LA
76
- country_id: 214
77
- maine:
78
- name: Maine
79
- abbr: ME
80
- country_id: 214
81
- maryland:
82
- name: Maryland
83
- abbr: MD
84
- country_id: 214
85
- massachusetts:
86
- name: Massachusetts
87
- abbr: MA
88
- country_id: 214
89
- michigan:
90
- name: Michigan
91
- abbr: MI
92
- country_id: 214
93
- minnesota:
94
- name: Minnesota
95
- abbr: MN
96
- country_id: 214
97
- mississippi:
98
- name: Mississippi
99
- abbr: MS
100
- country_id: 214
101
- missouri:
102
- name: Missouri
103
- abbr: MO
104
- country_id: 214
105
- montana:
106
- name: Montana
107
- abbr: MT
108
- country_id: 214
109
- nebraska:
110
- name: Nebraska
111
- abbr: NE
112
- country_id: 214
113
- nevada:
114
- name: Nevada
115
- abbr: NV
116
- country_id: 214
117
- new_hampshire:
118
- name: New Hampshire
119
- abbr: NH
120
- country_id: 214
121
- new_jersey:
122
- name: New Jersey
123
- abbr: NJ
124
- country_id: 214
125
- new_mexico:
126
- name: New Mexico
127
- abbr: NM
128
- country_id: 214
129
- new_york:
130
- name: New York
131
- abbr: NY
132
- country_id: 214
133
- north_carolina:
134
- name: North Carolina
135
- abbr: NC
136
- country_id: 214
137
- north_dakota:
138
- name: North Dakota
139
- abbr: ND
140
- country_id: 214
141
- ohio:
142
- name: Ohio
143
- abbr: OH
144
- country_id: 214
145
- oklahoma:
146
- name: Oklahoma
147
- abbr: OK
148
- country_id: 214
149
- oregon:
150
- name: Oregon
151
- abbr: OR
152
- country_id: 214
153
- pennsylvania:
154
- name: Pennsylvania
155
- abbr: PA
156
- country_id: 214
157
- rhode_island:
158
- name: Rhode Island
159
- abbr: RI
160
- country_id: 214
161
- south_carolina:
162
- name: South Carolina
163
- abbr: SC
164
- country_id: 214
165
- south_dakota:
166
- name: South Dakota
167
- abbr: SD
168
- country_id: 214
169
- tennesse:
170
- name: Tennessee
171
- abbr: TN
172
- country_id: 214
173
- texas:
174
- name: Texas
175
- abbr: TX
176
- country_id: 214
177
- utah:
178
- name: Utah
179
- abbr: UT
180
- country_id: 214
181
- vermont:
182
- name: Vermont
183
- abbr: VT
184
- country_id: 214
185
- virginia:
186
- name: Virginia
187
- abbr: VA
188
- country_id: 214
189
- washington:
190
- name: Washington
191
- abbr: WA
192
- country_id: 214
193
- west_virginia:
194
- name: West Virginia
195
- abbr: WV
196
- country_id: 214
197
- wisconsin:
198
- name: Wisconsin
199
- abbr: WI
200
- country_id: 214
201
- wyoming:
202
- name: Wyoming
203
- abbr: WY
204
- country_id: 214