diff options
29 files changed, 144 insertions, 109 deletions
diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 4eb80fa59..66036eab5 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -25,7 +25,7 @@ class RegistrationsController < Devise::RegistrationsController private def check_registrations_open! - if APP_CONFIG[:registrations_closed] + if AppConfig[:registrations_closed] flash[:error] = t('registrations.closed') redirect_to new_user_session_path end diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb index 61c5c0c49..d3f0dd683 100644 --- a/app/mailers/notifier.rb +++ b/app/mailers/notifier.rb @@ -1,6 +1,6 @@ class Notifier < ActionMailer::Base - default :from => APP_CONFIG[:smtp_sender_address] + default :from => AppConfig[:smtp_sender_address] ATTACHMENT = File.read("#{Rails.root}/public/images/white_on_grey.png") @@ -18,7 +18,7 @@ class Notifier < ActionMailer::Base @string = string.html_safe attachments.inline['diaspora_white_on_grey.png'] = ATTACHMENT mail(:to => @recipient.email, - :subject => I18n.t('notifier.single_admin.subject'), :host => APP_CONFIG[:pod_uri].host) + :subject => I18n.t('notifier.single_admin.subject'), :host => AppConfig[:pod_uri].host) end def new_request(recipient_id, sender_id) @@ -30,7 +30,7 @@ class Notifier < ActionMailer::Base attachments.inline['diaspora_white_on_grey.png'] = ATTACHMENT mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>", - :subject => I18n.t('notifier.new_request.subject', :from => @sender.name), :host => APP_CONFIG[:pod_uri].host) + :subject => I18n.t('notifier.new_request.subject', :from => @sender.name), :host => AppConfig[:pod_uri].host) end def request_accepted(recipient_id, sender_id) @@ -42,7 +42,7 @@ class Notifier < ActionMailer::Base attachments.inline['diaspora_white_on_grey.png'] = ATTACHMENT mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>", - :subject => I18n.t('notifier.request_accepted.subject', :name => @sender.name), :host => APP_CONFIG[:pod_uri].host) + :subject => I18n.t('notifier.request_accepted.subject', :name => @sender.name), :host => AppConfig[:pod_uri].host) end private diff --git a/app/models/photo.rb b/app/models/photo.rb index d397d017e..082e04c5c 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -81,8 +81,8 @@ class Photo < Post end def absolute_url *args - pod_url = APP_CONFIG[:pod_url].dup - pod_url.chop! if APP_CONFIG[:pod_url][-1,1] == '/' + pod_url = AppConfig[:pod_url].dup + pod_url.chop! if AppConfig[:pod_url][-1,1] == '/' "#{pod_url}#{url(*args)}" end diff --git a/app/models/profile.rb b/app/models/profile.rb index 3fa9b84b8..64a177f88 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -106,8 +106,8 @@ class Profile private def absolutify_local_url url - pod_url = APP_CONFIG[:pod_url].dup - pod_url.chop! if APP_CONFIG[:pod_url][-1,1] == '/' + pod_url = AppConfig[:pod_url].dup + pod_url.chop! if AppConfig[:pod_url][-1,1] == '/' "#{pod_url}#{url}" end end diff --git a/app/models/user.rb b/app/models/user.rb index c751331f9..b9f2acb09 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -153,7 +153,7 @@ class User def post_to_hub(post) Rails.logger.debug("event=post_to_service type=pubsub sender_handle=#{self.diaspora_handle}") - EventMachine::PubSubHubbub.new(APP_CONFIG[:pubsub_server]).publish self.public_url + EventMachine::PubSubHubbub.new(AppConfig[:pubsub_server]).publish self.public_url end def update_post(post, post_hash = {}) @@ -355,8 +355,8 @@ class User opts[:person][:profile] ||= Profile.new self.person = Person.new(opts[:person]) - self.person.diaspora_handle = "#{opts[:username]}@#{APP_CONFIG[:pod_uri].host}" - self.person.url = APP_CONFIG[:pod_url] + self.person.diaspora_handle = "#{opts[:username]}@#{AppConfig[:pod_uri].host}" + self.person.url = AppConfig[:pod_url] self.serialized_private_key ||= User.generate_key diff --git a/app/views/devise/mailer/invitation.html.haml b/app/views/devise/mailer/invitation.html.haml index 19b833142..5f9edcb33 100644 --- a/app/views/devise/mailer/invitation.html.haml +++ b/app/views/devise/mailer/invitation.html.haml @@ -5,7 +5,7 @@ = render :partial => 'notifier/notifier_css' %body %header - = image_tag APP_CONFIG[:pod_url] + 'images/diaspora_white_on_grey.png' + = image_tag AppConfig[:pod_url] + 'images/diaspora_white_on_grey.png' #container - @invs = @resource.invitations_to_me %p diff --git a/app/views/devise/sessions/new.haml b/app/views/devise/sessions/new.haml index 0f7ff0e52..277330678 100644 --- a/app/views/devise/sessions/new.haml +++ b/app/views/devise/sessions/new.haml @@ -12,7 +12,7 @@ = f.label :username , t('username') = f.text_field :username %p.user_network - ="@#{APP_CONFIG[:pod_uri].host}" + ="@#{AppConfig[:pod_uri].host}" %p = f.label :password , t('password') diff --git a/app/views/devise/sessions/new.mobile.haml b/app/views/devise/sessions/new.mobile.haml index 486372005..4109bf593 100644 --- a/app/views/devise/sessions/new.mobile.haml +++ b/app/views/devise/sessions/new.mobile.haml @@ -11,7 +11,7 @@ = f.label :username , t('username') = f.text_field :username %p.user_network - ="@#{APP_CONFIG[:pod_uri].host}/" + ="@#{AppConfig[:pod_uri].host}/" %p = f.label :password , t('password') diff --git a/app/views/devise/shared/_links.haml b/app/views/devise/shared/_links.haml index f9fba245f..101d43567 100644 --- a/app/views/devise/shared/_links.haml +++ b/app/views/devise/shared/_links.haml @@ -1,7 +1,7 @@ - if controller_name != 'sessions' = link_to t('.sign_in'), new_session_path(resource_name) %br/ -- if !APP_CONFIG[:registrations_closed] && devise_mapping.registerable? && controller_name != 'registrations' +- if !AppConfig[:registrations_closed] && devise_mapping.registerable? && controller_name != 'registrations' = link_to t('.sign_up'), new_registration_path(resource_name) %br/ - else diff --git a/app/views/js/_websocket_js.haml b/app/views/js/_websocket_js.haml index cab56c5a1..4187ff631 100644 --- a/app/views/js/_websocket_js.haml +++ b/app/views/js/_websocket_js.haml @@ -5,6 +5,6 @@ :javascript WebSocket.__swfLocation = "#{javascript_path 'vendor/WebSocketMain.swf'}"; $(document).ready(function(){ - WSR.initialize("#{(APP_CONFIG[:socket_secure])?'wss':'ws'}://#{request.host}:#{APP_CONFIG[:socket_port]}/"); + WSR.initialize("#{(AppConfig[:socket_secure])?'wss':'ws'}://#{request.host}:#{AppConfig[:socket_port]}/"); }); diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 625fe3f58..a6fd8447b 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -42,10 +42,10 @@ = yield(:head) = csrf_meta_tag - -if APP_CONFIG[:google_a_site] + -if AppConfig[:google_a_site] :javascript var _gaq = _gaq || []; - _gaq.push(['_setAccount', '#{APP_CONFIG[:google_a_site]}']); + _gaq.push(['_setAccount', '#{AppConfig[:google_a_site]}']); _gaq.push(['_trackPageview']); (function() { @@ -54,12 +54,12 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); - -if APP_CONFIG[:piwik_id] + -if AppConfig[:piwik_id] :javascript - var pkBaseURL = (("https:" == document.location.protocol) ? "https://#{APP_CONFIG[:piwik_url]}/" : "http://#{APP_CONFIG[:piwik_url]}/"); + var pkBaseURL = (("https:" == document.location.protocol) ? "https://#{AppConfig[:piwik_url]}/" : "http://#{AppConfig[:piwik_url]}/"); document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E")); try { - var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", #{APP_CONFIG[:piwik_id]}); + var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", #{AppConfig[:piwik_id]}); piwikTracker.trackPageView(); piwikTracker.enableLinkTracking(); } catch( err ) {} diff --git a/app/views/publics/host_meta.erb b/app/views/publics/host_meta.erb index 337ea947b..8b0ad3aa8 100644 --- a/app/views/publics/host_meta.erb +++ b/app/views/publics/host_meta.erb @@ -1,9 +1,9 @@ <?xml version='1.0' encoding='UTF-8'?> <XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0' xmlns:hm='http://host-meta.net/xrd/1.0'> - <hm:Host><%= APP_CONFIG[:pod_uri].host %></hm:Host> + <hm:Host><%= AppConfig[:pod_uri].host %></hm:Host> <Link rel='lrdd' - template='<%= APP_CONFIG[:pod_url] %>webfinger?q={uri}'> + template='<%= AppConfig[:pod_url] %>webfinger?q={uri}'> <Title>Resource Descriptor</Title> </Link> </XRD> diff --git a/app/views/shared/_invitations.haml b/app/views/shared/_invitations.haml index 3bfd3fb5d..892c0e4a0 100644 --- a/app/views/shared/_invitations.haml +++ b/app/views/shared/_invitations.haml @@ -1,4 +1,4 @@ -- if APP_CONFIG[:invites_off] +- if AppConfig[:invites_off] = t('.invites_closed') -else -if invites > 0 diff --git a/config/initializers/_load_app_config.rb b/config/initializers/_load_app_config.rb index 8b4eda713..0e3420534 100644 --- a/config/initializers/_load_app_config.rb +++ b/config/initializers/_load_app_config.rb @@ -1,42 +1,14 @@ -# Copyright (c) 2010, Diaspora Inc. This file is -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. # -# Sets up APP_CONFIG. Unless stated below, each entry is a the string in -# the file app_config.yml, as applicable for current environment. +# Sets up AppConfig. Unless stated below, each entry is a the string in +# the file app_config.yml, as applicable for current environment. # -# Specific items -# * pod_url: As in app_config.yml, normalized with a trailing /. -# * pod_uri: An uri object derived from pod_url. +# Specific items +# * pod_url: As in app_config.yml, normalized with a trailing /. +# * pod_uri: An uri object derived from pod_url. -require 'uri' +require File.join(Rails.root, 'lib', 'app_config') -def load_config_yaml filename - YAML.load(File.read(filename)) -end - -if File.exist? "#{Rails.root}/config/app_config.yml" - all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml" - all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml.example" unless all_envs -else - puts "WARNING: No config/app_config.yml found! Look at config/app_config.yml.example for help." - all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml.example" -end - -if all_envs[Rails.env.to_s] - APP_CONFIG = all_envs['default'].merge(all_envs[Rails.env.to_s]).symbolize_keys -else - APP_CONFIG = all_envs['default'].symbolize_keys -end - -begin - APP_CONFIG[:pod_uri] = URI.parse( APP_CONFIG[:pod_url]) -rescue - puts "WARNING: pod url " + APP_CONFIG[:pod_url] + " is not a legal URI" -end - -APP_CONFIG[:pod_url] = APP_CONFIG[:pod_uri].normalize.to_s - -if APP_CONFIG[:pod_uri].host == "example.org" && Rails.env != "test" - puts "WARNING: Please modify your app_config.yml to have a proper pod_url!" -end +AppConfig.configure_for_environment(Rails.env) diff --git a/config/initializers/_mongo.rb b/config/initializers/_mongo.rb index 5276e5ae7..88bd2c44a 100644 --- a/config/initializers/_mongo.rb +++ b/config/initializers/_mongo.rb @@ -2,7 +2,7 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -ENV['MONGODB_URL'] = ENV['MONGOHQ_URL'] || URI::Generic.build(:scheme => 'mongodb', :host => APP_CONFIG[:mongo_host], :port => APP_CONFIG[:mongo_port], :path => "/diaspora-#{Rails.env}").to_s +ENV['MONGODB_URL'] = ENV['MONGOHQ_URL'] || URI::Generic.build(:scheme => 'mongodb', :host => AppConfig[:mongo_host], :port => AppConfig[:mongo_port], :path => "/diaspora-#{Rails.env}").to_s MongoMapper.config = {::Rails.env => {'uri' => ENV['MONGODB_URL']}} MongoMapper.connect ::Rails.env diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 1e3ba8fa0..bebd067b5 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -6,8 +6,8 @@ # four configuration values can also be set straight in your models. Devise.setup do |config| # Configure the e-mail address which will be shown in DeviseMailer. - if APP_CONFIG[:smtp_sender_address] - config.mailer_sender = APP_CONFIG[:smtp_sender_address] + if AppConfig[:smtp_sender_address] + config.mailer_sender = AppConfig[:smtp_sender_address] else unless Rails.env == 'test' Rails.logger.warn("No smtp sender address set, mail may fail.") diff --git a/config/initializers/mailer_config.rb b/config/initializers/mailer_config.rb index c91a99f3d..c24d21d95 100644 --- a/config/initializers/mailer_config.rb +++ b/config/initializers/mailer_config.rb @@ -3,23 +3,23 @@ # the COPYRIGHT file. Diaspora::Application.configure do - config.action_mailer.default_url_options = {:host => APP_CONFIG[:pod_uri].host} - unless Rails.env == 'test' || APP_CONFIG[:mailer_on] != true + config.action_mailer.default_url_options = {:host => AppConfig[:pod_uri].host} + unless Rails.env == 'test' || AppConfig[:mailer_on] != true config.action_mailer.delivery_method = :smtp - if APP_CONFIG[:smtp_authentication] == "none" + if AppConfig[:smtp_authentication] == "none" config.action_mailer.smtp_settings = { - :address => APP_CONFIG[:smtp_address], - :port => APP_CONFIG[:smtp_port], - :domain => APP_CONFIG[:smtp_domain] + :address => AppConfig[:smtp_address], + :port => AppConfig[:smtp_port], + :domain => AppConfig[:smtp_domain] } else config.action_mailer.smtp_settings = { - :address => APP_CONFIG[:smtp_address], - :port => APP_CONFIG[:smtp_port], - :domain => APP_CONFIG[:smtp_domain], - :authentication => APP_CONFIG[:smtp_authentication], - :user_name => APP_CONFIG[:smtp_username], - :password => APP_CONFIG[:smtp_password], + :address => AppConfig[:smtp_address], + :port => AppConfig[:smtp_port], + :domain => AppConfig[:smtp_domain], + :authentication => AppConfig[:smtp_authentication], + :user_name => AppConfig[:smtp_username], + :password => AppConfig[:smtp_password], :enable_starttls_auto => true } end diff --git a/lib/app_config.rb b/lib/app_config.rb new file mode 100644 index 000000000..f890b1845 --- /dev/null +++ b/lib/app_config.rb @@ -0,0 +1,63 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +class AppConfig + + cattr_accessor :config_vars + + def self.[](key) + config_vars[key] + end + + def self.[]=(key, value) + config_vars[key] = value + end + + def self.configure_for_environment(env) + load_config_for_environment(env) + generate_pod_uri + normalize_pod_url + check_pod_uri + end + + def self.load_config_for_environment(env) + if File.exist? "#{Rails.root}/config/app_config.yml" + all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml" + all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml.example" unless all_envs + else + puts "WARNING: No config/app_config.yml found! Look at config/app_config.yml.example for help." + all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml.example" + end + + env = env.to_s + if all_envs[env] + self.config_vars = all_envs['default'].merge(all_envs[env]).symbolize_keys + else + self.config_vars = all_envs['default'].symbolize_keys + end + end + + def self.generate_pod_uri + require 'uri' + begin + self.config_vars[:pod_uri] = URI.parse(self.config_vars[:pod_url]) + rescue + puts "WARNING: pod url " + self.config_vars[:pod_url] + " is not a legal URI" + end + end + + def self.normalize_pod_url + self.config_vars[:pod_url] = self.config_vars[:pod_uri].normalize.to_s + end + + def self.check_pod_uri + if self.config_vars[:pod_uri].host == "example.org" && Rails.env != "test" + puts "WARNING: Please modify your app_config.yml to have a proper pod_url!" + end + end + + def self.load_config_yaml filename + YAML.load(File.read(filename)) + end +end
\ No newline at end of file diff --git a/lib/diaspora/ostatus_builder.rb b/lib/diaspora/ostatus_builder.rb index 2bbb417bd..6947cf901 100644 --- a/lib/diaspora/ostatus_builder.rb +++ b/lib/diaspora/ostatus_builder.rb @@ -43,7 +43,7 @@ module Diaspora def create_endpoints <<-XML -<link href="#{APP_CONFIG[:pubsub_server]}" rel="hub"/> +<link href="#{AppConfig[:pubsub_server]}" rel="hub"/> <link href="#{@user.public_url}.atom" rel="self" type="application/atom+xml"/> XML end diff --git a/lib/rake_helpers.rb b/lib/rake_helpers.rb index 9b22e8578..80348c5d3 100644 --- a/lib/rake_helpers.rb +++ b/lib/rake_helpers.rb @@ -31,13 +31,13 @@ module RakeHelpers def fix_diaspora_handle_spaces(test = true) offenders = {} - space_people = Person.all(:diaspora_handle => / /, :url => APP_CONFIG[:pod_url]) # this is every person with a space.... + space_people = Person.all(:diaspora_handle => / /, :url => AppConfig[:pod_url]) # this is every person with a space.... #these people dont even have users.... they are totally messed up totally_messed_up_people = space_people.find_all{|x| x.owner.nil?} totally_messed_up_people.each{|x| x.delete} - space_people = Person.all(:diaspora_handle => / /, :owner_id.ne => nil, :url => APP_CONFIG[:pod_url]) # this is every person with a space.... + space_people = Person.all(:diaspora_handle => / /, :owner_id.ne => nil, :url => AppConfig[:pod_url]) # this is every person with a space.... space_people.each do |person| user = person.owner @@ -62,7 +62,7 @@ mail end def new_diaspora_handle(user) - "#{user.username}@#{APP_CONFIG[:pod_uri].host}" + "#{user.username}@#{AppConfig[:pod_uri].host}" end def update_my_posts_with_new_diaspora_handle(user, new_diaspora_handle, test) diff --git a/lib/tasks/backup.rake b/lib/tasks/backup.rake index 371c8dfe5..548452b88 100644 --- a/lib/tasks/backup.rake +++ b/lib/tasks/backup.rake @@ -6,10 +6,10 @@ namespace :backup do task :mongo do Rails.logger.info("event=backup status=start type=mongo") - if APP_CONFIG[:cloudfiles_username] && APP_CONFIG[:cloudfiles_api_key] + if AppConfig[:cloudfiles_username] && AppConfig[:cloudfiles_api_key] puts "Logging into Cloud Files" - cf = CloudFiles::Connection.new(:username => APP_CONFIG[:cloudfiles_username], :api_key => APP_CONFIG[:cloudfiles_api_key]) + cf = CloudFiles::Connection.new(:username => AppConfig[:cloudfiles_username], :api_key => AppConfig[:cloudfiles_api_key]) mongo_container = cf.container("Mongo Backup") puts "Dumping Mongo" @@ -35,10 +35,10 @@ namespace :backup do task :photos do Rails.logger.info("event=backup status=start type=photos") - if APP_CONFIG[:cloudfiles_username] && APP_CONFIG[:cloudfiles_api_key] + if AppConfig[:cloudfiles_username] && AppConfig[:cloudfiles_api_key] puts "Logging into Cloud Files" - cf = CloudFiles::Connection.new(:username => APP_CONFIG[:cloudfiles_username], :api_key => APP_CONFIG[:cloudfiles_api_key]) + cf = CloudFiles::Connection.new(:username => AppConfig[:cloudfiles_username], :api_key => AppConfig[:cloudfiles_api_key]) photo_container = cf.container("Photo Backup") tar_name = "photos_#{Time.now.to_i}.tar" diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index a273559a9..758118822 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -73,7 +73,7 @@ namespace :db do require File.dirname(__FILE__) + '/../../config/environment' Person.where(:url => 'example.org').all.each{|person| if person.owner - person.url = APP_CONFIG[:pod_url] + person.url = AppConfig[:pod_url] person.diaspora_handle = person.owner.diaspora_handle person.save end diff --git a/script/websocket_server.rb b/script/websocket_server.rb index b8da36d04..8acd73027 100644 --- a/script/websocket_server.rb +++ b/script/websocket_server.rb @@ -25,7 +25,7 @@ def write_pidfile end def debug_pp thing - pp thing if APP_CONFIG[:socket_debug] || ENV['SOCKET_DEBUG'] + pp thing if AppConfig[:socket_debug] || ENV['SOCKET_DEBUG'] end def process_message @@ -44,15 +44,15 @@ begin EM.run { Diaspora::WebSocket.initialize_channels - socket_params = { :host => APP_CONFIG[:socket_host], - :port => APP_CONFIG[:socket_port], - :debug =>APP_CONFIG[:socket_debug] } + socket_params = { :host => AppConfig[:socket_host], + :port => AppConfig[:socket_port], + :debug =>AppConfig[:socket_debug] } - if APP_CONFIG[:socket_secure] && APP_CONFIG[:socket_private_key_location] && APP_CONFIG[:socket_cert_chain_location] + if AppConfig[:socket_secure] && AppConfig[:socket_private_key_location] && AppConfig[:socket_cert_chain_location] socket_params[:secure] = true; socket_params[:tls_options] = { - :private_key_file => APP_CONFIG[:socket_private_key_location], - :cert_chain_file => APP_CONFIG[:socket_cert_chain_location] + :private_key_file => AppConfig[:socket_private_key_location], + :cert_chain_file => AppConfig[:socket_cert_chain_location] } end @@ -91,7 +91,7 @@ begin end } end - PID_FILE = (APP_CONFIG[:socket_pidfile] ? APP_CONFIG[:socket_pidfile] : 'tmp/diaspora-ws.pid') + PID_FILE = (AppConfig[:socket_pidfile] ? AppConfig[:socket_pidfile] : 'tmp/diaspora-ws.pid') write_pidfile puts "Websocket server started." process_message diff --git a/spec/config/config_spec.rb b/spec/config/config_spec.rb index b84758a07..900a604a2 100644 --- a/spec/config/config_spec.rb +++ b/spec/config/config_spec.rb @@ -6,12 +6,12 @@ describe 'making sure the config is parsed as should' do describe 'pod_url' do it 'should have a trailing slash' do - APP_CONFIG[:pod_url].should == 'http://example.org/' + AppConfig[:pod_url].should == 'http://example.org/' end end describe 'terse_pod_url' it 'should be correctly parsed' do - APP_CONFIG[:pod_uri].host.should == 'example.org' + AppConfig[:pod_uri].host.should == 'example.org' end end diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index f8b4c0ecb..b7a436050 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -22,10 +22,10 @@ describe RegistrationsController do describe '#check_registrations_open!' do before do - APP_CONFIG[:registrations_closed] = true + AppConfig[:registrations_closed] = true end after do - APP_CONFIG[:registrations_closed] = false + AppConfig[:registrations_closed] = false end it 'redirects #new to the login page' do get :new diff --git a/spec/factories.rb b/spec/factories.rb index 048c0dfc3..029155262 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -35,7 +35,7 @@ Factory.define :user do |u| user.person = Factory.build(:person, :profile => Factory.create(:profile), :owner_id => user._id, :serialized_public_key => user.encryption_key.public_key.export, - :diaspora_handle => "#{user.username}@#{APP_CONFIG[:pod_url].gsub(/(https?:|www\.)\/\//, '').chop!}") + :diaspora_handle => "#{user.username}@#{AppConfig[:pod_url].gsub(/(https?:|www\.)\/\//, '').chop!}") end end diff --git a/spec/lib/rake_helper_spec.rb b/spec/lib/rake_helper_spec.rb index b908bcd64..b9538e009 100644 --- a/spec/lib/rake_helper_spec.rb +++ b/spec/lib/rake_helper_spec.rb @@ -43,13 +43,13 @@ describe RakeHelpers do Factory(:person) 5.times do |number| f = Factory.create(:user) - f.person.diaspora_handle = "#{f.username} #{APP_CONFIG[:pod_uri].host}" - f.person.url = APP_CONFIG[:pod_url] + f.person.diaspora_handle = "#{f.username} #{AppConfig[:pod_uri].host}" + f.person.url = AppConfig[:pod_url] f.person.save(:validate => false) end p = Factory(:person) - p.diaspora_handle = "bubblegoose @#{APP_CONFIG[:pod_uri].host}" - p.url = APP_CONFIG[:pod_url] + p.diaspora_handle = "bubblegoose @#{AppConfig[:pod_uri].host}" + p.url = AppConfig[:pod_url] p.save(:validate => false) end @@ -73,7 +73,7 @@ describe RakeHelpers do it 'should update a users username, his persons diaspora hande, and posts' do billy = Factory.create(:user) billy.username = "ma.x" - billy.person.diaspora_handle = "ma.x@#{APP_CONFIG[:pod_uri].host}" + billy.person.diaspora_handle = "ma.x@#{AppConfig[:pod_uri].host}" billy.person.save(:validate => false) billy.save(:validate => false) @@ -82,7 +82,7 @@ describe RakeHelpers do RakeHelpers::fix_periods_in_username(false) - new_d_handle = "max@#{APP_CONFIG[:pod_uri].host}" + new_d_handle = "max@#{AppConfig[:pod_uri].host}" User.first.username.should == 'max' User.first.person.diaspora_handle.should == new_d_handle diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index dc71dfca3..a83e6b9a0 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -33,13 +33,13 @@ describe Person do context 'local people' do it 'uses the pod config url to set the diaspora_handle' do new_user = Factory.create(:user) - new_user.person.diaspora_handle.should == new_user.username + "@" + APP_CONFIG[:pod_uri].host + new_user.person.diaspora_handle.should == new_user.username + "@" + AppConfig[:pod_uri].host end end context 'remote people' do it 'stores the diaspora_handle in the database' do - @person.diaspora_handle.include?(APP_CONFIG[:pod_uri].host).should be false + @person.diaspora_handle.include?(AppConfig[:pod_uri].host).should be false end end diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb index 2a54945de..b8a125710 100644 --- a/spec/models/profile_spec.rb +++ b/spec/models/profile_spec.rb @@ -49,7 +49,7 @@ describe Profile do fixture_name = File.dirname(__FILE__) + '/../fixtures/button.png' @photo = @user.post(:photo, :user_file => File.open(fixture_name), :to => 'all') @profile.image_url = "http://tom.joindiaspora.com/images/user/tom.jpg" - @pod_url = (APP_CONFIG[:pod_url][-1,1] == '/' ? APP_CONFIG[:pod_url].chop : APP_CONFIG[:pod_url]) + @pod_url = (AppConfig[:pod_url][-1,1] == '/' ? AppConfig[:pod_url].chop : AppConfig[:pod_url]) end it 'ignores an empty string' do lambda {@profile.image_url = ""}.should_not change(@profile, :image_url) |