Commit 0a406eda477beac506242b37930dce7a3df1c88f

Authored by Nick Recobra
1 parent cf313c57
Exists in master and in 1 other branch production

Ensure first user is admin.

Showing 2 changed files with 14 additions and 3 deletions   Show diff stats
db/seeds.rb
... ... @@ -10,10 +10,12 @@ puts "-- email: #{admin_email}"
10 10 puts "-- password: #{admin_pass}"
11 11 puts ""
12 12 puts "Be sure to change these credentials ASAP!"
13   -User.create!({
  13 +user = User.new({
14 14 :name => 'Errbit Admin',
15 15 :email => admin_email,
16 16 :password => admin_pass,
17 17 :password_confirmation => admin_pass,
18   - :admin => true
19   -})
20 18 \ No newline at end of file
  19 +})
  20 +
  21 +user.admin = true
  22 +user.save!
21 23 \ No newline at end of file
... ...
spec/models/user_spec.rb
... ... @@ -38,5 +38,14 @@ describe User do
38 38 end
39 39  
40 40 end
  41 +
  42 + context "First user" do
  43 + it "should be created this admin access via db:seed" do
  44 + require 'rake'
  45 + Errbit::Application.load_tasks
  46 + Rake::Task["db:seed"].execute
  47 + User.first.admin.should be_true
  48 + end
  49 + end
41 50  
42 51 end
... ...