diff --git a/config/app_config.yml.example b/config/app_config.yml.example index 069823a05c8c1075ce7a546f9f2ff0be1142a1b4..deb69220eb3216982d79bfd5af52f9d31c6773d9 100644 --- a/config/app_config.yml.example +++ b/config/app_config.yml.example @@ -12,6 +12,13 @@ default: pubsub_server: 'https://pubsubhubbub.appspot.com/' mongo_host: 'localhost' mongo_port: 27017 + smtp_address: 'smtp.example.com' + smtp_port: '587' + smtp_domain: 'mail.example.com' + smtp_authentication: 'plain' + smtp_username: 'no-reply@example.com' + smtp_password: 'secret' + development: diff --git a/config/environments/development.rb b/config/environments/development.rb index 15d1fc2bba372ae28e8260a22b0563d0dd401af7..063adbd1b94a32773977443ed9feaf18aac3d8db 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -24,15 +24,4 @@ Diaspora::Application.configure do config.active_support.deprecation = :log config.middleware.use MongoMapper::ClearDevMemory #config.threadsafe! - config.action_mailer.delivery_method = :smtp - config.action_mailer.default_url_options = {:host => 'localhost:3000'} - config.action_mailer.smtp_settings = { - :address => 'smtp.gmail.com', - :port => 587, - :domain => 'mail.joindiaspora.com', - :authentication => 'plain', - :user_name => 'diaspora-pivots@joindiaspora.com', - :password => "xy289|]G+R*-kA", - :enable_starttls_auto => true - } end diff --git a/config/environments/production.rb b/config/environments/production.rb index cb13c1d1c1222783cc0c979a14e8164930d85fb8..bdeeea2495af893693ecf476f558f580d6585af2 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -48,15 +48,4 @@ Diaspora::Application.configure do config.i18n.fallbacks = true config.threadsafe! - config.action_mailer.delivery_method = :smtp - config.action_mailer.default_url_options = {:host => 'pivots.joindiaspora.com'} - config.action_mailer.smtp_settings = { - :address => 'smtp.gmail.com', - :port => 587, - :domain => 'mail.joindiaspora.com', - :authentication => 'plain', - :user_name => 'diaspora-pivots@joindiaspora.com', - :password => "xy289|]G+R*-kA", - :enable_starttls_auto => true - } end diff --git a/config/initializers/mailer_config.rb b/config/initializers/mailer_config.rb new file mode 100644 index 0000000000000000000000000000000000000000..823a369fe21f79cf488cb7e81dc5eb0907c9ec83 --- /dev/null +++ b/config/initializers/mailer_config.rb @@ -0,0 +1,17 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3. See +# the COPYRIGHT file. + +Diaspora::Application.configure do + config.action_mailer.delivery_method = :smtp + config.action_mailer.default_url_options = {:host => APP_CONFIG[:terse_pod_url]} + 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], + :enable_starttls_auto => true + } +end diff --git a/spec/controllers/dev_utilities_controller_spec.rb b/spec/controllers/dev_utilities_controller_spec.rb index 66c07350f41da88a3b474b9295b90b54c8d5b4ac..c4439c790c87f8a10aad228ebf1ba89416fde9b6 100644 --- a/spec/controllers/dev_utilities_controller_spec.rb +++ b/spec/controllers/dev_utilities_controller_spec.rb @@ -19,7 +19,7 @@ describe DevUtilitiesController do end end - describe "#set_profile_photo" do + describe "operations that affect config/backer_number.yml" do # In case anyone wants their config/backer_number.yml to still exist after running specs before do @backer_number_file = File.join(File.dirname(__FILE__), "..", "..", "config", "backer_number.yml") @@ -33,10 +33,32 @@ describe DevUtilitiesController do FileUtils.rm_rf(@backer_number_file) end end - it "succeeds" do - get :set_backer_number, 'number' => '3' - get :set_profile_photo - response.should be_success + + describe "#set_backer_number" do + it "creates a file containing the seed number" do + File.should_not exist(@backer_number_file) + get :set_backer_number, 'number' => '3' + File.should exist(@backer_number_file) + YAML.load_file(@backer_number_file)[:seed_number].to_i.should == 3 + end + end + + describe "#set_profile_photo" do + before do + config = YAML.load_file(File.join(File.dirname(__FILE__), "..", "..", "config", "deploy_config.yml")) + seed_numbers = config["servers"]["backer"].map {|b| b["number"] } + @good_number = seed_numbers.max + @bad_number = @good_number + 1 + end + it "succeeds when a backer with the seed number exists" do + get :set_backer_number, 'number' => @good_number.to_s + get :set_profile_photo + response.should be_success + end + it "fails when a backer with the seed number does not exist" do + get :set_backer_number, 'number' => @bad_number.to_s + lambda { get :set_profile_photo }.should raise_error + end end end end