We're using `eq` and `match_array` in most places, but there were a few places where we were still checking each element is included in the array. This is a bit dangerous, because the array could have duplicate elements, and we wouldn't detect them with `include`.
59 lines
1.7 KiB
Ruby
59 lines
1.7 KiB
Ruby
require "rails_helper"
|
|
|
|
describe Milestone do
|
|
it_behaves_like "globalizable", :milestone_with_description
|
|
|
|
describe "Validations" do
|
|
let(:milestone) { build(:milestone) }
|
|
|
|
it "is valid" do
|
|
expect(milestone).to be_valid
|
|
end
|
|
|
|
it "is valid without a title" do
|
|
milestone.title = nil
|
|
expect(milestone).to be_valid
|
|
end
|
|
|
|
it "is not valid without a description if status is empty" do
|
|
milestone.status = nil
|
|
milestone.description = nil
|
|
expect(milestone).not_to be_valid
|
|
end
|
|
|
|
it "is valid without a description if status is present" do
|
|
milestone.description = nil
|
|
expect(milestone).to be_valid
|
|
end
|
|
|
|
it "is not valid without a milestoneable" do
|
|
milestone.milestoneable_id = nil
|
|
expect(milestone).not_to be_valid
|
|
end
|
|
|
|
it "is not valid if description and status are not present" do
|
|
milestone.description = nil
|
|
milestone.status_id = nil
|
|
expect(milestone).not_to be_valid
|
|
end
|
|
|
|
it "is valid without status if description is present" do
|
|
milestone.status_id = nil
|
|
expect(milestone).to be_valid
|
|
end
|
|
end
|
|
|
|
describe ".published" do
|
|
it "uses the application's time zone date", :with_different_time_zone do
|
|
published_in_local_time_zone = create(:milestone,
|
|
publication_date: Date.today)
|
|
|
|
published_in_application_time_zone = create(:milestone,
|
|
publication_date: Date.current)
|
|
|
|
expect(Milestone.published).to eq [published_in_application_time_zone]
|
|
expect(Milestone.published).not_to include(published_in_local_time_zone)
|
|
end
|
|
end
|
|
end
|