Skip to content
Extraits de code Groupes Projets
Valider c6d61c68 rédigé par Sarah Mei's avatar Sarah Mei
Parcourir les fichiers

Backfill some tests for app config, refactor base file name so people copy it instead of moving it

parent f29a605a
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
# Copyright (c) 2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
default:
# Hostname of this host, as seen from the internet.
pod_url: "http://localhost:3000"
# Set this to true in order to close signups. Users will still be
# able to invite other people to join.
registrations_closed: false
# Enable extensive logging to log/{development,test,production}.log
debug: false
# Websocket server setup, see script/websocket_server.rb
# Enable extensive logging to websocket server.
socket_debug : false
# Websocket host, leave as 0.0.0.0 unless you know what you are doing
socket_host: 0.0.0.0
# File containing pid of running script/websocket_server.rb
socket_pidfile: "log/diaspora-wsd.pid"
# Websocket port, should normally be 8080 or 8081.
socket_port: 8080
socket_collection_name: 'websocket'
# Secure websocket confguration (wss://)
# requires SSL cert and key
socket_secure: false
socket_cert_chain_location: '/full/path/to/cert_chain.crt'
socket_private_key_location: '/full/path/to/file.key'
# Diaspora is only tested against this default pubsub server.
pubsub_server: 'https://pubsubhubbub.appspot.com/'
# Setting this to true enables diaspora's "send email" functionality
# requiring meaningful smtp_* settings. These are options for RoR's
# ActionMailer class.
mailer_on: false
# This chooses which mailer should be used. 'smtp' for a smtp
# connection or 'sendmail' to use the sendmail binary.
mailer_method: 'smtp'
# Address/port to smtp server handing outgoing mail.
smtp_address: 'smtp.example.com'
smtp_port: '587'
# Domain administered of smtp server.
smtp_domain: 'example.com'
# Sender address in diaspora's outgoing mail.
smtp_sender_address: 'no-reply@joindiaspora.com'
# Authentication required to send mail. Use one of 'one','plain',
# 'login' or 'cram-md5'. Use 'none' if server do not support
# authentication
smtp_authentication: 'plain'
# Credentails possibly required to log in to SMTP server if
# smtp_authentication != 'none'
smtp_username: 'smtp_username'
smtp_password: 'secret'
# The path to the sendmail binary.
sendmail_location: '/usr/sbin/sendmail'
#google analytics key, if false, it won't include the javascript
google_a_site: false
#piwik integration if not set, no javascript included
piwik_id:
# the site url in raw format (e.g. pikwik.examplehost.com)
piwik_url:
#cloudfiles username and api-key, used for backups
cloudfiles_username: 'example'
cloudfiles_api_key: 'abc123'
invites_off: false
#list of users who have admin privilages
admins:
- 'example_user1dsioaioedfhgoiesajdigtoearogjaidofgjo'
#s3 config, if set, carrierwave will store your photos on s3
#s3_key: 'key'
#s3_secret: 'secret'
#s3_bucket: 'my_photos'
s3_region: 'us-east-1'
# If you want normal Rails logs, set this to false in the appropriate environment.
# It is false by default in development and test.
enable_splunk_logging: true
# Process jobs in process?
single_process_mode: true
# Use this sections to overide settings from default in the specific environments
development:
enable_splunk_logging: false
production:
single_process_mode: false
# Do not touch unless you know what you're doing
test:
pod_url: "http://example.org/"
socket_port: 8081
enable_splunk_logging: false
# This section is special, you cannot overide settings from here in the above sections
script_server:
# Port on which thin should listen
thin_port: 3000
# customize thins startup
default_thin_args: "-p $THIN_PORT -e $RAILS_ENV"
# Possibilties are development, production
rails_env: "development"
...@@ -5,7 +5,12 @@ ...@@ -5,7 +5,12 @@
class AppConfig class AppConfig
cattr_accessor :config_vars cattr_accessor :config_vars
cattr_accessor :base_file_path
def self.base_file_path
@@base_file_path || File.join(Rails.root, "config", "app_base.yml")
end
def self.[](key) def self.[](key)
config_vars[key] config_vars[key]
end end
...@@ -27,10 +32,10 @@ class AppConfig ...@@ -27,10 +32,10 @@ class AppConfig
end end
def self.load_config_for_environment(env) def self.load_config_for_environment(env)
if File.exist? "#{Rails.root}/config/app.yml.example" if File.exist?(base_file_path)
all_envs = load_config_yaml "#{Rails.root}/config/app.yml.example" all_envs = load_config_yaml(base_file_path)
else else
$stderr.puts "ERROR: Why have you deleted config/app.yml.example?" $stderr.puts "OH NO! Required file #{base_file_path} doesn't exist! Did you move it?"
all_envs = {} all_envs = {}
end end
if File.exist? "#{Rails.root}/config/app.yml" if File.exist? "#{Rails.root}/config/app.yml"
......
...@@ -5,14 +5,40 @@ ...@@ -5,14 +5,40 @@
require 'spec_helper' require 'spec_helper'
describe AppConfig do describe AppConfig do
describe ".generate_pod_uri" do before do
@environment_vars = AppConfig.config_vars
AppConfig.config_vars = {}
end
after do
AppConfig.config_vars = @environment_vars
end
describe ".base_file_path" do
it "allows you to set the base file path" do
AppConfig.base_file_path = "foo"
AppConfig.base_file_path.should == "foo"
end
it "defaults to config/app_base.yml" do
AppConfig.base_file_path = nil
AppConfig.base_file_path.should == "#{Rails.root}/config/app_base.yml"
end
end
describe ".load_config_for_environment" do
before do before do
@environment_vars = AppConfig.config_vars @original_stderr = $stderr
AppConfig.config_vars = {} $stderr = StringIO.new
end end
after do after do
AppConfig.config_vars = @environment_vars $stderr = @original_stderr
end
it "prints error if base file is missing" do
AppConfig.base_file_path = "/no/such/file"
AppConfig.load_config_for_environment(:test)
$stderr.rewind
$stderr.string.chomp.should_not be_blank
end end
end
describe ".generate_pod_uri" do
describe "when pod_url is prefixed with protocol" do describe "when pod_url is prefixed with protocol" do
it "generates a URI with a host for http" do it "generates a URI with a host for http" do
AppConfig[:pod_url] = "http://oscar.joindiaspora.com" AppConfig[:pod_url] = "http://oscar.joindiaspora.com"
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter