when a user is invited from a beta user, they are also beta
This commit is contained in:
parent
bae47a10eb
commit
e79d78302e
6 changed files with 25 additions and 1 deletions
|
|
@ -14,6 +14,7 @@ class RegistrationsController < Devise::RegistrationsController
|
||||||
if @user.save
|
if @user.save
|
||||||
flash[:notice] = I18n.t 'registrations.create.success'
|
flash[:notice] = I18n.t 'registrations.create.success'
|
||||||
@user.seed_aspects
|
@user.seed_aspects
|
||||||
|
Role.add_beta(@user.person) if invite.present? && invite.beta?
|
||||||
sign_in_and_redirect(:user, @user)
|
sign_in_and_redirect(:user, @user)
|
||||||
Rails.logger.info("event=registration status=successful user=#{@user.diaspora_handle}")
|
Rails.logger.info("event=registration status=successful user=#{@user.diaspora_handle}")
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ class InvitationCode < ActiveRecord::Base
|
||||||
|
|
||||||
before_create :generate_token, :set_default_invite_count
|
before_create :generate_token, :set_default_invite_count
|
||||||
|
|
||||||
|
delegate :beta?, :to => :user
|
||||||
def to_param
|
def to_param
|
||||||
token
|
token
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ class Role < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.is_beta?(person)
|
def self.is_beta?(person)
|
||||||
find_by_person_id_and_name(person.id, 'beta')
|
find_by_person_id_and_name(person.id, 'beta').present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.add_beta(person)
|
def self.add_beta(person)
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,10 @@ class User < ActiveRecord::Base
|
||||||
ConversationVisibility.sum(:unread, :conditions => "person_id = #{self.person.id}")
|
ConversationVisibility.sum(:unread, :conditions => "person_id = #{self.person.id}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def beta?
|
||||||
|
Role.is_beta?(self.person)
|
||||||
|
end
|
||||||
|
|
||||||
#@deprecated
|
#@deprecated
|
||||||
def ugly_accept_invitation_code
|
def ugly_accept_invitation_code
|
||||||
begin
|
begin
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,8 @@ describe RegistrationsController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
describe "#create" do
|
describe "#create" do
|
||||||
context "with valid parameters" do
|
context "with valid parameters" do
|
||||||
before do
|
before do
|
||||||
|
|
@ -84,6 +86,12 @@ describe RegistrationsController do
|
||||||
response.should be_redirect
|
response.should be_redirect
|
||||||
response.location.should match /^#{root_url}\??$/
|
response.location.should match /^#{root_url}\??$/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'with an invite code from a beta users, make the user beta' do
|
||||||
|
Role.add_beta(bob.person)
|
||||||
|
get :create, @valid_params.merge(:invite => {:token => bob.invitation_code.token})
|
||||||
|
User.last.should be_beta
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with invalid parameters" do
|
context "with invalid parameters" do
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,16 @@ describe InvitationCode do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '.beta?' do
|
||||||
|
it 'returns true if the invite code user is beta' do
|
||||||
|
code = Factory(:invitation_code)
|
||||||
|
Role.add_beta(code.user.person)
|
||||||
|
code.user.should be_beta
|
||||||
|
code.should be_beta
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
describe '.default_inviter_or' do
|
describe '.default_inviter_or' do
|
||||||
before do
|
before do
|
||||||
@old_account = AppConfig[:admin_account]
|
@old_account = AppConfig[:admin_account]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue