add validation which prevent user for signing up with dead username. fix cucumber features
This commit is contained in:
parent
34816f3a7f
commit
484f46d70f
6 changed files with 44 additions and 30 deletions
|
|
@ -28,6 +28,7 @@ class User < ActiveRecord::Base
|
||||||
|
|
||||||
validates_presence_of :person, :unless => proc {|user| user.invitation_token.present?}
|
validates_presence_of :person, :unless => proc {|user| user.invitation_token.present?}
|
||||||
validates_associated :person
|
validates_associated :person
|
||||||
|
validate :no_person_with_same_username
|
||||||
|
|
||||||
has_one :person, :foreign_key => :owner_id
|
has_one :person, :foreign_key => :owner_id
|
||||||
delegate :public_key, :posts, :photos, :owns?, :diaspora_handle, :name, :public_url, :profile, :first_name, :last_name, :to => :person
|
delegate :public_key, :posts, :photos, :owns?, :diaspora_handle, :name, :public_url, :profile, :first_name, :last_name, :to => :person
|
||||||
|
|
@ -471,4 +472,11 @@ class User < ActiveRecord::Base
|
||||||
self.email = self.invitation_identifier if self.invitation_service == 'email'
|
self.email = self.invitation_identifier if self.invitation_service == 'email'
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def no_person_with_same_username
|
||||||
|
diaspora_id = "#{self.username}@#{AppConfig[:pod_uri].host}"
|
||||||
|
if self.username_changed? && Person.exists?(:diaspora_handle => diaspora_id)
|
||||||
|
errors[:base] << 'That username has already been taken'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
%form{:action => "https://www.paypal.com/cgi-bin/webscr", :method => "post"}
|
-# %form{:action => "https://www.paypal.com/cgi-bin/webscr", :method => "post"}
|
||||||
%input{:name => "cmd", :type => "hidden", :value => "_s-xclick"}
|
%form{:action => "https://www.diasporafoundation.org/donate", :method => "get"}
|
||||||
%input{:name => "hosted_button_id", :type => "hidden", :value => AppConfig[:paypal_hosted_button_id]}
|
-# %input{:name => "cmd", :type => "hidden", :value => "_s-xclick"}
|
||||||
%input{:name => "on0", :type => "hidden", :value => "Type"}
|
-# %input{:name => "hosted_button_id", :type => "hidden", :value => AppConfig[:paypal_hosted_button_id]}
|
||||||
%input{:name => "modify", :type => "hidden", :value => "2"}
|
-# %input{:name => "on0", :type => "hidden", :value => "Type"}
|
||||||
%select{:name => "os0"}
|
-# %input{:name => "modify", :type => "hidden", :value => "2"}
|
||||||
%option{:value => "Mocha"} Mocha : $3.00USD
|
%select{:name => "monthly_amount"}
|
||||||
%option{:value => "Americano"} Americano : $5.00USD
|
%option{:value => "1"} Supporter : $5.00USD
|
||||||
%option{:value => "Box o' Joe"} Box o' Joe : $20.00USD
|
%option{:value => "2"} Member : $10.00USD
|
||||||
%input{:name => "currency_code", :type => "hidden", :value => "USD"}
|
%option{:value => "3"} Freedom Fighter : $20.00USD
|
||||||
|
-# %input{:name => "currency_code", :type => "hidden", :value => "USD"}
|
||||||
%input{:name => "submit", :type => "submit", :value => t('aspects.index.donate')}
|
%input{:name => "submit", :type => "submit", :value => t('aspects.index.donate')}
|
||||||
|
|
|
||||||
|
|
@ -77,15 +77,13 @@
|
||||||
.content#community_spotlight
|
.content#community_spotlight
|
||||||
= link_to t('aspects.index.see_more_from_us'), spotlight_path, :id => 'view_all_contacts_link'
|
= link_to t('aspects.index.see_more_from_us'), spotlight_path, :id => 'view_all_contacts_link'
|
||||||
|
|
||||||
- unless AppConfig[:paypal_hosted_button_id].blank?
|
.section
|
||||||
.section
|
.title
|
||||||
.title
|
= image_tag('/images/icons/coffee.png')
|
||||||
= image_tag('/images/icons/coffee.png')
|
%h5
|
||||||
%h5
|
= t('aspects.index.donate')
|
||||||
= t('aspects.index.donate')
|
.content
|
||||||
.content
|
= t('aspects.index.keep_us_running', :pod => URI.parse(AppConfig[:pod_url]).host)
|
||||||
= t('aspects.index.keep_us_running', :pod => URI.parse(AppConfig[:pod_url]).host)
|
%br
|
||||||
%br
|
= render 'shared/donate'
|
||||||
= render 'shared/donate'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@ Feature: invitation acceptance
|
||||||
Given I have been invited by an admin
|
Given I have been invited by an admin
|
||||||
And I am on my acceptance form page
|
And I am on my acceptance form page
|
||||||
And I fill in the following:
|
And I fill in the following:
|
||||||
| Username | ohai |
|
| user_username | ohai |
|
||||||
| Email | woot@sweet.com |
|
| user_email | woot@sweet.com |
|
||||||
| user_password | secret |
|
| user_password | secret |
|
||||||
| Password confirmation | secret |
|
| user_password_confirmation | secret |
|
||||||
And I press "Create my account"
|
And I press "Create my account"
|
||||||
Then I should be on the getting started page
|
Then I should be on the getting started page
|
||||||
And I should see "Welcome"
|
And I should see "Welcome"
|
||||||
|
|
@ -28,10 +28,10 @@ Feature: invitation acceptance
|
||||||
Given I have been invited by a user
|
Given I have been invited by a user
|
||||||
And I am on my acceptance form page
|
And I am on my acceptance form page
|
||||||
And I fill in the following:
|
And I fill in the following:
|
||||||
| Username | ohai |
|
| user_username | ohai |
|
||||||
| Email | woot@sweet.com |
|
| user_email | woot@sweet.com |
|
||||||
| user_password | secret |
|
| user_password | secret |
|
||||||
| Password confirmation | secret |
|
| user_password_confirmation | secret |
|
||||||
And I press "Create my account"
|
And I press "Create my account"
|
||||||
Then I should be on the getting started page
|
Then I should be on the getting started page
|
||||||
And I should see "Welcome"
|
And I should see "Welcome"
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@ Feature: new user registration
|
||||||
|
|
||||||
Background:
|
Background:
|
||||||
When I go to the new user registration page
|
When I go to the new user registration page
|
||||||
And I fill in "Username" with "ohai"
|
And I fill in "user_username" with "ohai"
|
||||||
And I fill in "Email" with "ohai@example.com"
|
And I fill in "user_email" with "ohai@example.com"
|
||||||
And I fill in "user_password" with "secret"
|
And I fill in "user_password" with "secret"
|
||||||
And I fill in "Password confirmation" with "secret"
|
And I fill in "user_password_confirmation" with "secret"
|
||||||
And I press "Create my account"
|
And I press "Create my account"
|
||||||
Then I should be on the getting started page
|
Then I should be on the getting started page
|
||||||
And I should see "Welcome"
|
And I should see "Welcome"
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,13 @@ describe User do
|
||||||
alice.should_not be_valid
|
alice.should_not be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'requires uniqueness also amount Person objects with diaspora handle' do
|
||||||
|
p = Factory(:person, :diaspora_handle => "jimmy@#{AppConfig[:pod_uri].host}")
|
||||||
|
alice.username = 'jimmy'
|
||||||
|
alice.should_not be_valid
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
it "downcases username" do
|
it "downcases username" do
|
||||||
user = Factory.build(:user, :username => "WeIrDcAsE")
|
user = Factory.build(:user, :username => "WeIrDcAsE")
|
||||||
user.should be_valid
|
user.should be_valid
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue