Namespace can have only one chat team
This commit is contained in:
parent
df55d35ffd
commit
7fb2d94e56
3 changed files with 15 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
class ChatTeam < ActiveRecord::Base
|
class ChatTeam < ActiveRecord::Base
|
||||||
validates :team_id, presence: true
|
validates :team_id, presence: true
|
||||||
|
validates :namespace, uniqueness: true
|
||||||
|
|
||||||
belongs_to :namespace
|
belongs_to :namespace
|
||||||
end
|
end
|
||||||
|
|
9
spec/factories/chat_teams.rb
Normal file
9
spec/factories/chat_teams.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :chat_team, class: ChatTeam do
|
||||||
|
sequence :team_id do |n|
|
||||||
|
"abcdefghijklm#{n}"
|
||||||
|
end
|
||||||
|
|
||||||
|
namespace factory: :group
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,9 +1,14 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe ChatTeam, type: :model do
|
describe ChatTeam, type: :model do
|
||||||
|
subject { create(:chat_team) }
|
||||||
|
|
||||||
# Associations
|
# Associations
|
||||||
it { is_expected.to belong_to(:namespace) }
|
it { is_expected.to belong_to(:namespace) }
|
||||||
|
|
||||||
|
# Validations
|
||||||
|
it { is_expected.to validate_uniqueness_of(:namespace) }
|
||||||
|
|
||||||
# Fields
|
# Fields
|
||||||
it { is_expected.to respond_to(:name) }
|
it { is_expected.to respond_to(:name) }
|
||||||
it { is_expected.to respond_to(:team_id) }
|
it { is_expected.to respond_to(:team_id) }
|
||||||
|
|
Loading…
Reference in a new issue