Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Signing up with an invite now works again. Fixes #23

  • Loading branch information...
commit 5e6218a4010b63dadbe2ce68019705b26219c237 1 parent 057c699
@elektronaut authored
View
2  Gemfile.lock
@@ -127,7 +127,7 @@ GEM
net-ssh (2.5.2)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
- nokogiri (1.5.4)
+ nokogiri (1.5.9)
open4 (1.3.0)
options (2.3.0)
fattr
View
4 app/controllers/users_controller.rb
@@ -78,10 +78,6 @@ def user_params
params.require(:user).permit(*allowed_params)
end
- def new_user_params
- params.require(:user).permit(:username, *allowed_params).merge(facebook_user_params)
- end
-
public
def show
View
8 app/controllers/users_controller/create_user_controller.rb
@@ -11,10 +11,10 @@ module CreateUserController
def new
if @invite
session[:invite_token] = @invite.token
- @user = @invite.user.invitees.new(new_user_params)
+ @user = @invite.user.invitees.new(facebook_user_params)
@user.email = @invite.email
else
- @user = User.new(new_user_params)
+ @user = User.new(facebook_user_params)
end
end
@@ -36,6 +36,10 @@ def create
private
+ def new_user_params
+ params.require(:user).permit(:username, *allowed_params)
+ end
+
def find_invite
if invite_token?
@invite = Invite.find_by_token(invite_token)
View
51 spec/controllers/users_controller/create_users_controller_spec.rb
@@ -0,0 +1,51 @@
+require 'spec_helper'
+
+describe UsersController, redis: true do
+
+ let(:invite) { create(:invite) }
+
+ describe "#new" do
+ context "with a valid invite token" do
+ before do
+ configure signups_allowed: false
+ get :new, :token => invite.token
+ end
+ it { should respond_with(:success) }
+ it { should render_template(:new) }
+ it { should assign_to(:invite) }
+ it { should assign_to(:user) }
+ specify { assigns(:user).email.should == invite.email }
+ end
+
+ context "without a valid invite token" do
+ before do
+ create(:user) # Ensures the first user exists
+ configure signups_allowed: false
+ get :new
+ end
+ it { should set_the_flash.to("Signups are not allowed") }
+ it { should redirect_to(login_users_url) }
+ end
+ end
+
+ describe "#create" do
+ let(:params) {
+ attributes = attributes_for(:user)
+ {
+ username: attributes[:username],
+ email: attributes[:email],
+ password: 'randompassword',
+ confirm_password: 'randompassword',
+ realname: attributes[:realname]
+ }
+ }
+
+ context 'with a valid invite token' do
+ before { post :create, :token => invite.token, :user => params }
+
+ it { should assign_to(:invite) }
+ it { should assign_to(:user) }
+ it { should redirect_to(user_url(:id => assigns(:user).username)) }
+ end
+ end
+end
View
26 spec/controllers/users_controller_spec.rb
@@ -109,30 +109,4 @@
end
end
- describe 'POST create' do
- before do
- attributes = attributes_for(:user)
- @params = {
- :username => attributes[:username],
- :email => attributes[:email],
- :password => 'randompassword',
- :confirm_password => 'randompassword',
- :realname => attributes[:realname]
- }
- end
-
- describe 'with a valid invite token' do
- before do
- @invite = create(:invite)
- post :create, :token => @invite.token, :user => @params
- end
-
- it { should assign_to(:invite) }
- it { should assign_to(:user) }
-
- it "redirects to the user profile" do
- response.should redirect_to(user_url(:id => assigns(:user).username))
- end
- end
- end
end
View
1  spec/spec_helper.rb
@@ -89,6 +89,7 @@
config.include LoginMacros, :type => :controller
config.include Sugar::Exceptions
config.include(MailerMacros)
+ config.include(ConfigurationMacros)
config.before(:each) { reset_email }
end
View
6 spec/support/configuration_macros.rb
@@ -0,0 +1,6 @@
+module ConfigurationMacros
+ def configure(configuration={})
+ Sugar.configure(configuration)
+ Sugar.save_config!
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.