chat_name_spec.rb 588 Bytes
Newer Older
1 2
require 'spec_helper'

3
describe ChatName do
4 5
  set(:chat_name) { create(:chat_name) }
  subject { chat_name }
6 7 8 9 10 11 12 13 14 15 16 17

  it { is_expected.to belong_to(:service) }
  it { is_expected.to belong_to(:user) }

  it { is_expected.to validate_presence_of(:user) }
  it { is_expected.to validate_presence_of(:service) }
  it { is_expected.to validate_presence_of(:team_id) }
  it { is_expected.to validate_presence_of(:chat_id) }

  it { is_expected.to validate_uniqueness_of(:user_id).scoped_to(:service_id) }
  it { is_expected.to validate_uniqueness_of(:chat_id).scoped_to(:service_id, :team_id) }
end