-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix the erroring password change. move admin user to seed-fu
- Loading branch information
1 parent
07984a1
commit b2fc03a
Showing
11 changed files
with
80 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
User.seed(:login) do |s| | ||
s.login = 'admin' | ||
s.email = '[email protected]' | ||
s.password = 'changeme' | ||
s.admin = true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,15 +22,6 @@ def self.up | |
add_index :users, :last_request_at | ||
add_index :users, :perishable_token | ||
add_index :users, :email | ||
|
||
say "adding defalt admin user" | ||
user = User.new(:login => 'admin', | ||
:email => '[email protected]', | ||
:password => 'changeme', | ||
:password_confirmation => 'changeme' | ||
) | ||
user.admin = true | ||
user.save! | ||
end | ||
|
||
def self.down | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
namespace :db do | ||
desc <<-EOS | ||
Loads seed data for the current environment. It will look for | ||
ruby seed files in <RAILS_ROOT>/db/fixtures/ and | ||
<RAILS_ROOT>/db/fixtures/<RAILS_ENV>/. | ||
By default it will load any ruby files found. You can filter the files | ||
loaded by passing in the SEED environment variable with a comma-delimited | ||
list of patterns to include. Any files not matching the pattern will | ||
not be loaded. | ||
You can also change the directory where seed files are looked for | ||
with the FIXTURE_PATH environment variable. | ||
Examples: | ||
# default, to load all seed files for the current environment | ||
rake db:seed | ||
# to load seed files matching orders or customers | ||
rake db:seed SEED=orders,customers | ||
# to load files from RAILS_ROOT/features/fixtures | ||
rake db:seed FIXTURE_PATH=features/fixtures | ||
EOS | ||
task :seed => :environment do | ||
fixture_path = ENV["FIXTURE_PATH"] ? ENV["FIXTURE_PATH"] : "db/fixtures" | ||
|
||
global_seed_files = Dir[File.join(RAILS_ROOT, fixture_path, '*.rb')].sort | ||
env_specific_seed_files = Dir[File.join(RAILS_ROOT, fixture_path, RAILS_ENV, '*.rb')] | ||
potential_seed_files = (global_seed_files + env_specific_seed_files).uniq | ||
|
||
if ENV["SEED"] | ||
filter = ENV["SEED"].gsub(/,/, "|") | ||
potential_seed_files.reject!{ |file| true unless file =~ /#{filter}/ } | ||
puts "\n == Filtering seed files against regexp: #{filter}" | ||
end | ||
|
||
potential_seed_files.each do |file| | ||
pretty_name = file.sub("#{RAILS_ROOT}/", "") | ||
puts "\n== Seed from #{pretty_name} " + ("=" * (60 - (17 + File.split(file).last.length))) | ||
load file | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ | |
|
||
it "should redirect to account on successful :create" do | ||
post :create, :user => { :login => 'bob', :email => '[email protected]', | ||
:password => 'bobs_pass', :password_confirmation => 'bobs_pass' } | ||
:password => 'bobs_pass' } | ||
response.should redirect_to(account_path) | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | ||
|
||
describe User do | ||
fixtures :users | ||
|
||
describe "changing password" do | ||
it "should succeed without a confirmation field" do | ||
user = users(:mmoen) | ||
user.password = 'some new password' | ||
user.save! | ||
end | ||
end | ||
end |