attr_accessible :group_access, :user_id
belongs_to :user
- belongs_to :project
+ belongs_to :group
scope :guests, -> { where(group_access: GUEST) }
scope :reporters, -> { where(group_access: REPORTER) }
describe "Validation" do
let!(:users_group) { create(:users_group) }
- it { should validate_presence_of(:user) }
+ it { should validate_presence_of(:user_id) }
it { should validate_uniqueness_of(:user_id).scoped_to(:group_id).with_message(/already exists/) }
- it { should validate_presence_of(:group) }
+ it { should validate_presence_of(:group_id) }
it { should ensure_inclusion_of(:group_access).in_array(UsersGroup.group_access_roles.values) }
end