mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-15 19:31:26 +00:00
User can now change password without having to provide an invitation code
This commit is contained in:
parent
430a6a8432
commit
2a9c5e172a
4 changed files with 21 additions and 9 deletions
1
Gemfile
1
Gemfile
|
@ -48,6 +48,7 @@ end
|
|||
group :development, :test do
|
||||
gem 'rspec-rails'
|
||||
gem 'rspec'
|
||||
gem 'shoulda-matchers'
|
||||
gem 'rr'
|
||||
gem 'webmock', :require => false
|
||||
gem 'rake'
|
||||
|
|
|
@ -43,6 +43,8 @@ GEM
|
|||
rails (>= 3.1)
|
||||
bootstrap-sass (2.3.0.1)
|
||||
sass (~> 3.2)
|
||||
bourne (1.4.0)
|
||||
mocha (~> 0.13.2)
|
||||
builder (3.0.4)
|
||||
coderay (1.0.9)
|
||||
coffee-rails (3.2.2)
|
||||
|
@ -119,8 +121,11 @@ GEM
|
|||
i18n (>= 0.4.0)
|
||||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
metaclass (0.0.1)
|
||||
method_source (0.8.1)
|
||||
mime-types (1.21)
|
||||
mocha (0.13.3)
|
||||
metaclass (~> 0.0.1)
|
||||
multi_json (1.6.1)
|
||||
multi_xml (0.5.3)
|
||||
multipart-post (1.2.0)
|
||||
|
@ -204,6 +209,9 @@ GEM
|
|||
select2-rails (3.3.1)
|
||||
sass-rails (>= 3.2)
|
||||
thor (~> 0.14)
|
||||
shoulda-matchers (1.5.6)
|
||||
activesupport (>= 3.0.0)
|
||||
bourne (~> 1.3)
|
||||
simple_oauth (0.1.9)
|
||||
slop (3.4.3)
|
||||
sprockets (2.2.2)
|
||||
|
@ -273,6 +281,7 @@ DEPENDENCIES
|
|||
safe_yaml (= 0.8.6)
|
||||
sass-rails (~> 3.2.3)
|
||||
select2-rails
|
||||
shoulda-matchers
|
||||
system_timer
|
||||
twitter
|
||||
twitter-stream (>= 0.1.16)
|
||||
|
|
|
@ -19,7 +19,7 @@ class User < ActiveRecord::Base
|
|||
validates_presence_of :username
|
||||
validates_uniqueness_of :username
|
||||
validates_format_of :username, :with => /\A[a-zA-Z0-9_-]{3,15}\Z/, :message => "can only contain letters, numbers, underscores, and dashes, and must be between 3 and 15 characters in length."
|
||||
validates_inclusion_of :invitation_code, :in => INVITATION_CODES, :message => "is not valid"
|
||||
validates_inclusion_of :invitation_code, :on => :create, :in => INVITATION_CODES, :message => "is not valid"
|
||||
|
||||
has_many :events, :order => "events.created_at desc", :dependent => :delete_all, :inverse_of => :user
|
||||
has_many :agents, :order => "agents.created_at desc", :dependent => :destroy, :inverse_of => :user
|
||||
|
|
|
@ -3,14 +3,16 @@ require 'spec_helper'
|
|||
describe User do
|
||||
describe "validations" do
|
||||
describe "invitation_code" do
|
||||
it "should be required and only be valid when set to one of the allowed values" do
|
||||
users(:bob).should be_valid
|
||||
users(:bob).invitation_code = ""
|
||||
users(:bob).should_not be_valid
|
||||
users(:bob).invitation_code = "something_fake"
|
||||
users(:bob).should_not be_valid
|
||||
users(:bob).invitation_code = User::INVITATION_CODES.first
|
||||
users(:bob).should be_valid
|
||||
it "only accepts valid invitation codes" do
|
||||
User::INVITATION_CODES.each do |v|
|
||||
should allow_value(v).for(:invitation_code)
|
||||
end
|
||||
end
|
||||
|
||||
it "can reject invalid invitation codes" do
|
||||
%w['foo', 'bar'].each do |v|
|
||||
should_not allow_value(v).for(:invitation_code)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue