diff --git a/app/controllers/invitations_controller.rb b/app/controllers/invitations_controller.rb
index 3f4e95435..1b4561972 100644
--- a/app/controllers/invitations_controller.rb
+++ b/app/controllers/invitations_controller.rb
@@ -4,7 +4,7 @@
class InvitationsController < Devise::InvitationsController
- before_filter :check_token, :only => [:edit]
+ before_filter :check_token, :only => [:edit, :email]
before_filter :check_if_invites_open, :only =>[:create]
def new
@@ -73,8 +73,7 @@ class InvitationsController < Devise::InvitationsController
protected
def check_token
if User.find_by_invitation_token(params[:invitation_token]).nil?
- flash[:error] = I18n.t 'invitations.check_token.not_found'
- redirect_to root_url
+ render 'invitations/token_not_found'
end
end
diff --git a/app/views/devise/mailer/invitation_instructions.erb b/app/views/devise/mailer/invitation_instructions.erb
index f3fe8a240..78b55067e 100644
--- a/app/views/devise/mailer/invitation_instructions.erb
+++ b/app/views/devise/mailer/invitation_instructions.erb
@@ -1,5 +1,5 @@
<%- self.extend NotifierHelper -%>
-<% @invites = @resource.invitations_to_me.includes(:sender =>{:person => :profile}).where(:admin => false).all%>
+<% @invites = @resource.invitations_to_me.includes(:sender =>{:person => :profile}).where(:admin => false).all %>
<%=invite_email_title %>
diff --git a/app/views/invitations/token_not_found.html.haml b/app/views/invitations/token_not_found.html.haml
new file mode 100644
index 000000000..81712492c
--- /dev/null
+++ b/app/views/invitations/token_not_found.html.haml
@@ -0,0 +1,3 @@
+.span-15.last
+ %h2
+ = t('devise.invitations.invitation_token_invalid')
diff --git a/config/locales/devise/devise.en.yml b/config/locales/devise/devise.en.yml
index 77abe5e1a..cb69e049c 100644
--- a/config/locales/devise/devise.en.yml
+++ b/config/locales/devise/devise.en.yml
@@ -52,7 +52,7 @@ en:
resend_unlock: "Resend unlock instructions"
invitations:
send_instructions: 'Your invitation has been sent.'
- invitation_token_invalid: 'The invitation token provided is not valid!'
+ invitation_token_invalid: 'Our apologies! That invitation token is not valid.'
updated: 'Your password was set successfully. You are now signed in.'
mailer:
welcome: "Welcome %{email}!"
@@ -73,8 +73,8 @@ en:
click_to_unlock: "Click the link below to unlock your account:"
unlock: "Unlock my account"
invitation_instructions:
- displaying_correctly: "Email not displaying correctly? %{link} in your browser"
- view_in: "View in"
+ displaying_correctly: "Email not displaying correctly? %{link}"
+ view_in: "View it in your browser."
finally: "Finally - it's here"
arrived: "The social network you have been waiting for has arrived. Revamped, more secure, and more fun, %{strong_diaspora} is ready to help you share and explore the web in a whole new way."
sign_up_now: "Sign up now →"
diff --git a/spec/controllers/invitations_controller_spec.rb b/spec/controllers/invitations_controller_spec.rb
index bf723ed3d..2b56db0da 100644
--- a/spec/controllers/invitations_controller_spec.rb
+++ b/spec/controllers/invitations_controller_spec.rb
@@ -24,20 +24,20 @@ describe InvitationsController do
request.env["HTTP_REFERER"]= 'http://test.host/cats/foo'
end
- it 'saves and invitation' do
+ it 'saves an invitation' do
expect {
post :create, :user => @invite
}.should change(Invitation, :count).by(1)
end
- it 'handles a comma seperated list of emails' do
+ it 'handles a comma-separated list of emails' do
expect{
post :create, :user => @invite.merge(
:email => "foofoofoofoo@example.com, mbs@gmail.com")
}.should change(Invitation, :count).by(2)
end
- it 'handles a comma seperated list of emails with whitespace' do
+ it 'handles a comma-separated list of emails with whitespace' do
expect {
post :create, :user => @invite.merge(
:email => "foofoofoofoo@example.com , mbs@gmail.com")
@@ -70,6 +70,24 @@ describe InvitationsController do
end
end
+ describe "#email" do
+ before do
+ invites = Invitation.batch_invite(["foo@example.com"], :message => "hi", :sender => @user, :aspect => @user.aspects.first, :service => 'email', :language => "en-US")
+ invites.first.send!
+ @invited_user = User.find_by_email("foo@example.com")
+ end
+
+ it "succeeds" do
+ get :email, :invitation_token => @invited_user.invitation_token
+ response.should be_success
+ end
+
+ it "shows an error if there's no such invitation token" do
+ get :email, :invitation_token => 12345
+ response.should render_template(:token_not_found)
+ end
+ end
+
describe "#update" do
before do
invite = Factory(:invitation, :sender => @user, :service => 'email', :identifier => "a@a.com")