Created
September 12, 2012 10:18
-
-
Save lucassus/3705764 to your computer and use it in GitHub Desktop.
Testing indexes for mongoid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe 'indexes' do | |
it { should have_index_for({ company: 1, advisor_company: 1 }).with_options(unique: true) } | |
describe 'unique index for :company and :advisor_company' do | |
let!(:first_advisor_company) { create(:company, :advisor) } | |
let!(:second_advisor_company) { create(:company, :advisor) } | |
let!(:company) { create(:company) } | |
before { Rails::Mongoid.create_indexes("app/models/company/**/*.rb") } | |
it 'should ensure uniques' do | |
company.invite_advisor(first_advisor_company) | |
expect do | |
company.invite_advisor(first_advisor_company) | |
end.not_to change(Company::Relation::AdvisorCompany, :count) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment