Files
nairobi/spec/models/budget/heading_spec.rb
Bertocq 512059e021 Increase Budget, Heading and Group model specs to cover slug uniqueness
Why:

* Slug must be unique among:
 1. Budget slug: among other budgets
 2. Group slug: among other groups from its budget
 3. Heading slug: among other headings from all the groups from its budget

How:

* Adding checks for all possible scenarios on each model specs
2017-07-05 12:33:17 +02:00

29 lines
785 B
Ruby

require 'rails_helper'
describe Budget::Heading do
it_behaves_like "sluggable"
let(:budget) { create(:budget) }
let(:group) { create(:budget_group, budget: budget) }
describe "name" do
before do
create(:budget_heading, group: group, name: 'object name')
end
it "can be repeatead in other budget's groups" do
expect(build(:budget_heading, group: create(:budget_group), name: 'object name')).to be_valid
end
it "must be unique among all budget's groups" do
expect(build(:budget_heading, group: create(:budget_group, budget: budget), name: 'object name')).not_to be_valid
end
it "must be unique among all it's group" do
expect(build(:budget_heading, group: group, name: 'object name')).not_to be_valid
end
end
end