diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-06-17 14:41:35 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-06-18 18:47:52 +0400 |
commit | fa877b63126c84cb304228cf37b61d186d5e4477 (patch) | |
tree | 548789263fd3fee1f64521a646d1848af96a1872 /spec | |
parent | 95965d3f5417b62ec61fcdd3d7f21fe1f6260993 (diff) |
UsersGroup specs. Fixed db/schema
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories/users_groups.rb | 8 | ||||
-rw-r--r-- | spec/models/users_group_spec.rb | 24 |
2 files changed, 26 insertions, 6 deletions
diff --git a/spec/factories/users_groups.rb b/spec/factories/users_groups.rb index f19f5d1eb95..cb272e35c92 100644 --- a/spec/factories/users_groups.rb +++ b/spec/factories/users_groups.rb @@ -1,9 +1,7 @@ -# Read about factories at https://github.com/thoughtbot/factory_girl - FactoryGirl.define do factory :users_group do - access_level 1 - group_id 1 - user_id 1 + group_access { UsersGroup::OWNER } + group + user end end diff --git a/spec/models/users_group_spec.rb b/spec/models/users_group_spec.rb index e0c1d23711d..fd847dad48c 100644 --- a/spec/models/users_group_spec.rb +++ b/spec/models/users_group_spec.rb @@ -1,5 +1,27 @@ require 'spec_helper' describe UsersGroup do - pending "add some examples to (or delete) #{__FILE__}" + describe "Associations" do + it { should belong_to(:group) } + it { should belong_to(:user) } + end + + describe "Mass assignment" do + it { should_not allow_mass_assignment_of(:group_id) } + end + + describe "Validation" do + let!(:users_group) { create(:users_group) } + + it { should validate_presence_of(:user) } + it { should validate_uniqueness_of(:user_id).scoped_to(:group_id).with_message(/already exists/) } + + it { should validate_presence_of(:group) } + it { should ensure_inclusion_of(:group_access).in_array(UsersGroup.group_access_roles.values) } + end + + describe "Delegate methods" do + it { should respond_to(:user_name) } + it { should respond_to(:user_email) } + end end |