diff options
-rw-r--r-- | common_dependencies.rb | 5 | ||||
-rw-r--r-- | test/factories.rb | 3 | ||||
-rw-r--r-- | users/app/models/user.rb | 6 | ||||
-rw-r--r-- | users/test/factories.rb | 18 |
4 files changed, 29 insertions, 3 deletions
diff --git a/common_dependencies.rb b/common_dependencies.rb index a6691cf..1650fee 100644 --- a/common_dependencies.rb +++ b/common_dependencies.rb @@ -4,3 +4,8 @@ group :test do gem 'mocha', '~> 0.13.0', :require => false end +group :test, :development do + gem 'faker' + gem 'factory_girl_rails' +end + diff --git a/test/factories.rb b/test/factories.rb new file mode 100644 index 0000000..6c671f8 --- /dev/null +++ b/test/factories.rb @@ -0,0 +1,3 @@ +Dir.glob(Rails.root.join('**','test','factories.rb')) do |factory_file| + require factory_file +end diff --git a/users/app/models/user.rb b/users/app/models/user.rb index 1798ea4..8474d16 100644 --- a/users/app/models/user.rb +++ b/users/app/models/user.rb @@ -18,8 +18,8 @@ class User < CouchRest::Model::Base :if => :serverside? validates :login, - :format => { :with => /\A[A-Za-z\d_]+\z/, - :message => "Only letters, digits and _ allowed" } + :format => { :with => /\A[A-Za-z\d_\.]+\z/, + :message => "Only letters, digits, . and _ allowed" } validates :password_salt, :password_verifier, :format => { :with => /\A[\dA-Fa-f]+\z/, :message => "Only hex numbers allowed" } @@ -57,7 +57,7 @@ class User < CouchRest::Model::Base # valid set of attributes for testing def valid_attributes_hash - { :login => "me", + { :login => Faker::Name.first_name.downcase, :password_verifier => "1234ABCD", :password_salt => "4321AB" } end diff --git a/users/test/factories.rb b/users/test/factories.rb new file mode 100644 index 0000000..2802c7e --- /dev/null +++ b/users/test/factories.rb @@ -0,0 +1,18 @@ +FactoryGirl.define do + + factory :user do + login { Faker::Internet.user_name } + password_verifier "1234ABCD" + password_salt "4321AB" + end + + factory :user_with_settings, :class => User do + login { Faker::Internet.user_name } + password_verifier "1234ABCD" + password_salt "4321AB" + email_forward { Faker::Internet.email } + email_aliases_attributes do + {:a => Faker::Internet.user_name + '@' + APP_CONFIG[:domain]} + end + end +end |