diff --git a/config/application.yml.example b/config/application.yml.example index 7c01c0747..94653a39d 100644 --- a/config/application.yml.example +++ b/config/application.yml.example @@ -167,7 +167,7 @@ test: pod_url: "http://localhost:9887" socket_port: 8081 enable_splunk_logging: false - open_invitations: false + open_invitations: true integration_1: diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 718bfd33f..be5942981 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -20,6 +20,17 @@ Devise.setup do |config| # (bson_ext recommended) and :data_mapper (experimental). require 'devise/orm/active_record' + #mail setup + 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.") + puts "WARNING: No smtp sender address set, mail may fail." + end + config.mailer_sender = "please-change-me@config-initializers-devise.com" + end + # Configure the class responsible to send e-mails. config.mailer = "DiasporaDeviseMailer" diff --git a/features/accepts_invitation.feature b/features/accepts_invitation.feature index 9840f3b4e..6b1033a29 100644 --- a/features/accepts_invitation.feature +++ b/features/accepts_invitation.feature @@ -48,3 +48,10 @@ Feature: invitation acceptance When I follow "Finished" Then I should be on the aspects page + Scenario: sends an invitation + Given a user with email "bob@bob.bob" + When I sign in as "bob@bob.bob" + And I follow "By email" + And I fill in "user_email" with "alex@example.com" + And I press "Send an invitation" + Then I should have 1 Devise email delivery diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index 25f0aa54f..278a064a8 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -150,6 +150,11 @@ And /^I follow the "([^\"]*)" link from the last sent email$/ do |link_text| visit URI::parse(path).request_uri end +Then /^I should have (\d+) Devise email delivery$/ do |n| + Devise.mailer.deliveries.length.should == n.to_i +end + + When /^"([^\"]+)" has posted a status message with a photo$/ do |email| user = User.find_for_database_authentication(:username => email) post = Factory(:status_message_with_photo, :text => "Look at this dog", :author => user.person) diff --git a/spec/models/invitation_spec.rb b/spec/models/invitation_spec.rb index 4e5b531df..cfb5e82a2 100644 --- a/spec/models/invitation_spec.rb +++ b/spec/models/invitation_spec.rb @@ -73,7 +73,7 @@ describe Invitation do end it 'generate the invitation token and pass it to the user' do - + pending end end @@ -100,15 +100,33 @@ describe Invitation do end end - describe '#resend' do + describe 'send' do before do @invitation = Factory(:invitation, :sender => alice, :aspect => alice.aspects.first, :service => 'email', :identifier => 'a@a.com') end - it 'sends another email' do - lambda { - @invitation.resend - }.should change(Devise.mailer.deliveries, :count).by(1) + it 'sends an email' do + lambda { + @invitation.send! + }.should change(Devise.mailer.deliveries, :count).by(1) + end + + it 'sends an email with from header' do + @invitation.send! + Devise.mailer.deliveries.first.from.should_not be_blank + end + + it 'sends an email with from header' do + @invitation.send! + Devise.mailer.deliveries.first.to.should == ["a@a.com"] + end + + context "re-send" do + it 'sends another email' do + lambda { + @invitation.resend + }.should change(Devise.mailer.deliveries, :count).by(1) + end end end