diff --git a/app/models/user.rb b/app/models/user.rb index ac46491db..327f8b0db 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -28,6 +28,7 @@ class User < ActiveRecord::Base validates_presence_of :person, :unless => proc {|user| user.invitation_token.present?} validates_associated :person + validate :no_person_with_same_username 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 @@ -471,4 +472,11 @@ class User < ActiveRecord::Base self.email = self.invitation_identifier if self.invitation_service == 'email' self 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 diff --git a/app/views/shared/_donate.html.haml b/app/views/shared/_donate.html.haml index 38a04b6a6..a87d6c2ec 100644 --- a/app/views/shared/_donate.html.haml +++ b/app/views/shared/_donate.html.haml @@ -1,11 +1,12 @@ -%form{:action => "https://www.paypal.com/cgi-bin/webscr", :method => "post"} - %input{:name => "cmd", :type => "hidden", :value => "_s-xclick"} - %input{:name => "hosted_button_id", :type => "hidden", :value => AppConfig[:paypal_hosted_button_id]} - %input{:name => "on0", :type => "hidden", :value => "Type"} - %input{:name => "modify", :type => "hidden", :value => "2"} - %select{:name => "os0"} - %option{:value => "Mocha"} Mocha : $3.00USD - %option{:value => "Americano"} Americano : $5.00USD - %option{:value => "Box o' Joe"} Box o' Joe : $20.00USD - %input{:name => "currency_code", :type => "hidden", :value => "USD"} +-# %form{:action => "https://www.paypal.com/cgi-bin/webscr", :method => "post"} +%form{:action => "https://www.diasporafoundation.org/donate", :method => "get"} + -# %input{:name => "cmd", :type => "hidden", :value => "_s-xclick"} + -# %input{:name => "hosted_button_id", :type => "hidden", :value => AppConfig[:paypal_hosted_button_id]} + -# %input{:name => "on0", :type => "hidden", :value => "Type"} + -# %input{:name => "modify", :type => "hidden", :value => "2"} + %select{:name => "monthly_amount"} + %option{:value => "1"} Supporter : $5.00USD + %option{:value => "2"} Member : $10.00USD + %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')} diff --git a/app/views/shared/_right_sections.html.haml b/app/views/shared/_right_sections.html.haml index 8fc62600a..fb674d98c 100644 --- a/app/views/shared/_right_sections.html.haml +++ b/app/views/shared/_right_sections.html.haml @@ -77,15 +77,13 @@ .content#community_spotlight = link_to t('aspects.index.see_more_from_us'), spotlight_path, :id => 'view_all_contacts_link' -- unless AppConfig[:paypal_hosted_button_id].blank? - .section - .title - = image_tag('/images/icons/coffee.png') - %h5 - = t('aspects.index.donate') - .content - = t('aspects.index.keep_us_running', :pod => URI.parse(AppConfig[:pod_url]).host) - %br - = render 'shared/donate' - +.section + .title + = image_tag('/images/icons/coffee.png') + %h5 + = t('aspects.index.donate') + .content + = t('aspects.index.keep_us_running', :pod => URI.parse(AppConfig[:pod_url]).host) + %br + = render 'shared/donate' diff --git a/features/accepts_invitation.feature b/features/accepts_invitation.feature index 95bfaa07c..c9055a0c5 100644 --- a/features/accepts_invitation.feature +++ b/features/accepts_invitation.feature @@ -4,10 +4,10 @@ Feature: invitation acceptance Given I have been invited by an admin And I am on my acceptance form page And I fill in the following: - | Username | ohai | - | Email | woot@sweet.com | + | user_username | ohai | + | user_email | woot@sweet.com | | user_password | secret | - | Password confirmation | secret | + | user_password_confirmation | secret | And I press "Create my account" Then I should be on the getting started page And I should see "Welcome" @@ -28,10 +28,10 @@ Feature: invitation acceptance Given I have been invited by a user And I am on my acceptance form page And I fill in the following: - | Username | ohai | - | Email | woot@sweet.com | + | user_username | ohai | + | user_email | woot@sweet.com | | user_password | secret | - | Password confirmation | secret | + | user_password_confirmation | secret | And I press "Create my account" Then I should be on the getting started page And I should see "Welcome" diff --git a/features/signs_up.feature b/features/signs_up.feature index d4fd95052..3149f729e 100644 --- a/features/signs_up.feature +++ b/features/signs_up.feature @@ -3,10 +3,10 @@ Feature: new user registration Background: When I go to the new user registration page - And I fill in "Username" with "ohai" - And I fill in "Email" with "ohai@example.com" + And I fill in "user_username" with "ohai" + And I fill in "user_email" with "ohai@example.com" 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" Then I should be on the getting started page And I should see "Welcome" diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 2138a7e73..6902db86b 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -110,6 +110,13 @@ describe User do alice.should_not be_valid 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 user = Factory.build(:user, :username => "WeIrDcAsE") user.should be_valid