Make db seed set app_config[:pod_url]
This commit is contained in:
parent
d26e7850ac
commit
d3b0b9c07e
3 changed files with 37 additions and 25 deletions
|
|
@ -15,25 +15,38 @@
|
||||||
require 'config/environment'
|
require 'config/environment'
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|
||||||
|
|
||||||
config = YAML.load_file(File.dirname(__FILE__) + '/../../config/deploy_config.yml')
|
config = YAML.load_file(File.dirname(__FILE__) + '/../../config/deploy_config.yml')
|
||||||
backer_info = config['servers']['backer']
|
backer_info = config['servers']['backer']
|
||||||
|
|
||||||
backer_number = YAML.load_file(Rails.root.join('config','backer_number.yml'))[:seed_number].to_i
|
backer_number = YAML.load_file(Rails.root.join('config','backer_number.yml'))[:seed_number].to_i
|
||||||
# Create seed user
|
|
||||||
|
#set pod url
|
||||||
username = backer_info[backer_number]['username'].gsub(/ /,'').downcase
|
username = backer_info[backer_number]['username'].gsub(/ /,'').downcase
|
||||||
|
set_app_config username
|
||||||
|
require 'config/initializers/_load_app_config.rb'
|
||||||
|
|
||||||
|
# Create seed user
|
||||||
user = User.instantiate!(:email => "#{username}@#{username}.joindiaspora.com",
|
user = User.instantiate!(:email => "#{username}@#{username}.joindiaspora.com",
|
||||||
:username => username,
|
:username => username,
|
||||||
:password => "#{username+backer_info[backer_number]['pin'].to_s}",
|
:password => "#{username+backer_info[backer_number]['pin'].to_s}",
|
||||||
:password_confirmation => "#{username+backer_info[backer_number]['pin'].to_s}",
|
:password_confirmation => "#{username+backer_info[backer_number]['pin'].to_s}",
|
||||||
:url=> "http://#{username}.joindiaspora.com/",
|
|
||||||
:person => Person.new(
|
:person => Person.new(
|
||||||
:diaspora_handle => "#{username}@#{username}.joindiaspora.com",
|
|
||||||
:profile => Profile.new( :first_name => backer_info[backer_number]['given_name'], :last_name => backer_info[backer_number]['family_name'],
|
:profile => Profile.new( :first_name => backer_info[backer_number]['given_name'], :last_name => backer_info[backer_number]['family_name'],
|
||||||
:image_url => "http://#{username}.joindiaspora.com/images/user/#{username}.jpg"),
|
:image_url => "http://#{username}.joindiaspora.com/images/user/#{username}.jpg")
|
||||||
:url=> "http://#{username}.joindiaspora.com/")
|
|
||||||
)
|
)
|
||||||
user.person.save!
|
user.person.save!
|
||||||
|
|
||||||
user.aspect(:name => "Presidents")
|
user.aspect(:name => "Presidents")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_app_config username
|
||||||
|
current_config = YAML.load(Rails.root.join('config', 'app_config.yml'))
|
||||||
|
current_config[Rails.env] ||= {}
|
||||||
|
current_config[Rails.env][:pod_url] = "#{username}.joindiaspora.com"
|
||||||
|
current_config[:default][:pod_url] = "#{username}.joindiaspora.com"
|
||||||
|
file = File.new(Rails.root.join('config','app_config.yml'),'w')
|
||||||
|
file.write(current_config.to_yaml)
|
||||||
|
file.close
|
||||||
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,31 +6,23 @@
|
||||||
|
|
||||||
require 'config/environment'
|
require 'config/environment'
|
||||||
|
|
||||||
host = "localhost:3000"
|
|
||||||
url = "http://#{host}/"
|
|
||||||
username = "tom"
|
username = "tom"
|
||||||
# Create seed user
|
# Create seed user
|
||||||
user = User.instantiate!( :email => "tom@tom.joindiaspora.com",
|
user = User.instantiate!( :email => "tom@tom.joindiaspora.com",
|
||||||
:username => "tom",
|
:username => "tom",
|
||||||
:password => "evankorth",
|
:password => "evankorth",
|
||||||
:password_confirmation => "evankorth",
|
:password_confirmation => "evankorth",
|
||||||
:url=> "http://#{username}.joindiaspora.com/"
|
|
||||||
:person => Person.new(
|
:person => Person.new(
|
||||||
:diaspora_handle => "tom@tom.joindiaspora.com",
|
|
||||||
:url => url,
|
|
||||||
:profile => Profile.new( :first_name => "Alexander", :last_name => "Hamiltom" ))
|
:profile => Profile.new( :first_name => "Alexander", :last_name => "Hamiltom" ))
|
||||||
)
|
)
|
||||||
user.person.save!
|
user.person.save!
|
||||||
|
|
||||||
user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com",
|
user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com",
|
||||||
:username => "korth",
|
:username => "korth",
|
||||||
:url=> "http://#{username}.joindiaspora.com/"
|
|
||||||
:password => "evankorth",
|
:password => "evankorth",
|
||||||
:password_confirmation => "evankorth",
|
:password_confirmation => "evankorth",
|
||||||
:person => Person.new( :diaspora_handle => "korth@tom.joindiaspora.com",
|
:person => Person.new(
|
||||||
:url => url,
|
:profile => Profile.new( :first_name => "Evan", :last_name => "Korth")))
|
||||||
:profile => Profile.new( :first_name => "Evan",
|
|
||||||
:last_name => "Korth")))
|
|
||||||
|
|
||||||
user2.person.save!
|
user2.person.save!
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,17 +6,26 @@
|
||||||
|
|
||||||
require 'config/environment'
|
require 'config/environment'
|
||||||
|
|
||||||
remote_url = "http://tom.joindiaspora.com/"
|
def set_app_config username
|
||||||
#remote_url = "http://localhost:3000/"
|
current_config = YAML.load(Rails.root.join('config', 'app_config.yml'))
|
||||||
|
current_config[Rails.env] ||= {}
|
||||||
|
current_config[Rails.env][:pod_url] = "#{username}.joindiaspora.com"
|
||||||
|
current_config[:default][:pod_url] = "#{username}.joindiaspora.com"
|
||||||
|
file = File.new(Rails.root.join('config','app_config.yml'),'w')
|
||||||
|
file.write(current_config.to_yaml)
|
||||||
|
file.close
|
||||||
|
end
|
||||||
|
|
||||||
|
set_app_config "tom"
|
||||||
|
require 'config/initializers/_load_app_config.rb'
|
||||||
|
|
||||||
|
|
||||||
# Create seed user
|
# Create seed user
|
||||||
user = User.instantiate!( :email => "tom@tom.joindiaspora.com",
|
user = User.instantiate!( :email => "tom@tom.joindiaspora.com",
|
||||||
:username => "tom",
|
:username => "tom",
|
||||||
:password => "evankorth",
|
:password => "evankorth",
|
||||||
:password_confirmation => "evankorth",
|
:password_confirmation => "evankorth",
|
||||||
:url => remote_url,
|
|
||||||
:person => {
|
:person => {
|
||||||
:diaspora_handle => "tom@tom.joindiaspora.com",
|
|
||||||
:url => remote_url,
|
|
||||||
:profile => { :first_name => "Alexander", :last_name => "Hamiltom",
|
:profile => { :first_name => "Alexander", :last_name => "Hamiltom",
|
||||||
:image_url => "http://tom.joindiaspora.com/images/user/tom.jpg"}}
|
:image_url => "http://tom.joindiaspora.com/images/user/tom.jpg"}}
|
||||||
)
|
)
|
||||||
|
|
@ -26,11 +35,7 @@ user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com",
|
||||||
:password => "evankorth",
|
:password => "evankorth",
|
||||||
:password_confirmation => "evankorth",
|
:password_confirmation => "evankorth",
|
||||||
:username => "korth",
|
:username => "korth",
|
||||||
:url => remote_url,
|
:person => {:profile => { :first_name => "Evan", :last_name => "Korth",
|
||||||
:person => { :diaspora_handle => "korth@tom.joindiaspora.com",
|
|
||||||
:url => remote_url,
|
|
||||||
:profile => { :first_name => "Evan",
|
|
||||||
:last_name => "Korth",
|
|
||||||
:image_url => "http://tom.joindiaspora.com/images/user/korth.jpg"}})
|
:image_url => "http://tom.joindiaspora.com/images/user/korth.jpg"}})
|
||||||
|
|
||||||
user2.person.save!
|
user2.person.save!
|
||||||
|
|
@ -41,3 +46,5 @@ request = user.send_friend_request_to(user2, aspect)
|
||||||
reversed_request = user2.accept_friend_request( request.id, user2.aspect(:name => "presidents").id )
|
reversed_request = user2.accept_friend_request( request.id, user2.aspect(:name => "presidents").id )
|
||||||
user.receive reversed_request.to_diaspora_xml
|
user.receive reversed_request.to_diaspora_xml
|
||||||
user.aspect(:name => "Presidents")
|
user.aspect(:name => "Presidents")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue