2012-10-09 10:14:17 +02:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: users_projects
|
|
|
|
#
|
|
|
|
# id :integer not null, primary key
|
|
|
|
# user_id :integer not null
|
|
|
|
# project_id :integer not null
|
|
|
|
# created_at :datetime not null
|
|
|
|
# updated_at :datetime not null
|
|
|
|
# project_access :integer default(0), not null
|
|
|
|
#
|
|
|
|
|
2011-10-08 23:36:38 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe UsersProject do
|
|
|
|
describe "Associations" do
|
|
|
|
it { should belong_to(:project) }
|
|
|
|
it { should belong_to(:user) }
|
|
|
|
end
|
|
|
|
|
2012-09-26 20:17:17 +02:00
|
|
|
describe "Mass assignment" do
|
|
|
|
it { should_not allow_mass_assignment_of(:project_id) }
|
|
|
|
end
|
|
|
|
|
2011-10-08 23:36:38 +02:00
|
|
|
describe "Validation" do
|
2012-08-29 17:36:02 +02:00
|
|
|
let!(:users_project) { create(:users_project) }
|
|
|
|
|
2012-10-09 02:10:16 +02:00
|
|
|
it { should validate_presence_of(:user) }
|
2012-09-06 23:05:23 +02:00
|
|
|
it { should validate_uniqueness_of(:user_id).scoped_to(:project_id).with_message(/already exists/) }
|
2012-08-29 17:36:02 +02:00
|
|
|
|
2012-10-09 02:10:16 +02:00
|
|
|
it { should validate_presence_of(:project) }
|
2011-10-08 23:36:38 +02:00
|
|
|
end
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
describe "Delegate methods" do
|
2011-10-08 23:36:38 +02:00
|
|
|
it { should respond_to(:user_name) }
|
|
|
|
it { should respond_to(:user_email) }
|
|
|
|
end
|
|
|
|
end
|