Merge branch 'next-minor' into develop

This commit is contained in:
Dennis Schubert 2016-09-06 05:08:09 +02:00
commit 09aef2f145
No known key found for this signature in database
GPG key ID: 5A0304BEA7966D7E
4 changed files with 37 additions and 3 deletions

View file

@ -25,6 +25,7 @@
* Deleted comments will be removed when loading more comments [#7045](https://github.com/diaspora/diaspora/pull/7045)
* The "subscribe" indicator on a post now gets toggled when you like or rehsare a post [#7040](https://github.com/diaspora/diaspora/pull/7040)
* Add OpenGraph video support [#7043](https://github.com/diaspora/diaspora/pull/7043)
* You'll now get redirected to the invites page if you follow an invitation but you're already logged in [#7061](https://github.com/diaspora/diaspora/pull/7061)
# 0.6.0.0

View file

@ -6,8 +6,13 @@ class InvitationCodesController < ApplicationController
end
def show
sign_out(current_user) if user_signed_in?
redirect_to new_user_registration_path(:invite => {:token => params[:id]})
if user_signed_in?
invite = InvitationCode.find_by_token!(params[:id])
flash[:notice] = I18n.t("invitation_codes.already_logged_in", inviter: invite.user.name)
redirect_to person_path(invite.user.person)
else
redirect_to new_user_registration_path(invite: {token: params[:id]})
end
end
private

View file

@ -553,6 +553,7 @@ en:
invitation_codes:
not_valid: "That invite code is no longer valid"
already_logged_in: "You have been invited by %{inviter} to join this pod but you are already logged in."
invitations:
create:

View file

@ -0,0 +1,27 @@
require "spec_helper"
describe InvitationCodesController, type: :controller do
describe "#show" do
it "redirects to the root page if the invitation code is invalid" do
get :show, id: "InvalidInvitationCode"
expect(response).to redirect_to root_path
expect(flash[:notice]).to eq(I18n.t("invitation_codes.not_valid"))
end
context "valid invitation code" do
let(:invitation_token) { alice.invitation_code.token }
it "redirects logged out users to the sign in page" do
post :show, id: invitation_token
expect(response).to redirect_to new_user_registration_path(invite: {token: invitation_token})
end
it "redirects logged in users the the inviters page" do
sign_in bob
post :show, id: invitation_token
expect(response).to redirect_to person_path(alice.person)
expect(flash[:notice]).to eq(I18n.t("invitation_codes.already_logged_in", inviter: alice.name))
end
end
end
end