Only create records on tests using them
The test or the draft phase legislation filter was using an entirely different set of records, but was still creating the records used in the open and past filter as well. This made it hard to test the filter, since it returned records from both sets. Grouping the past and open filters together guarantees their records won't be created in the phase draft test, and so we can test the exact contents of the array.
This commit is contained in:
@@ -96,6 +96,7 @@ describe Legislation::Process do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "filter scopes" do
|
describe "filter scopes" do
|
||||||
|
describe "open and past filters" do
|
||||||
let!(:process_1) { create(:legislation_process, start_date: Date.current - 2.days,
|
let!(:process_1) { create(:legislation_process, start_date: Date.current - 2.days,
|
||||||
end_date: Date.current + 1.day) }
|
end_date: Date.current + 1.day) }
|
||||||
let!(:process_2) { create(:legislation_process, start_date: Date.current + 1.day,
|
let!(:process_2) { create(:legislation_process, start_date: Date.current + 1.day,
|
||||||
@@ -106,9 +107,17 @@ describe Legislation::Process do
|
|||||||
it "filters open" do
|
it "filters open" do
|
||||||
open_processes = ::Legislation::Process.open
|
open_processes = ::Legislation::Process.open
|
||||||
|
|
||||||
expect(open_processes).to include(process_1)
|
expect(open_processes).to eq [process_1]
|
||||||
expect(open_processes).not_to include(process_2)
|
expect(open_processes).not_to include [process_2]
|
||||||
expect(open_processes).not_to include(process_3)
|
end
|
||||||
|
|
||||||
|
it "filters past" do
|
||||||
|
past_processes = ::Legislation::Process.past
|
||||||
|
|
||||||
|
expect(past_processes).to include(process_3)
|
||||||
|
expect(past_processes).not_to include(process_2)
|
||||||
|
expect(past_processes).not_to include(process_1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "filters draft phase" do
|
it "filters draft phase" do
|
||||||
@@ -141,19 +150,11 @@ describe Legislation::Process do
|
|||||||
|
|
||||||
processes_not_in_draft = ::Legislation::Process.not_in_draft
|
processes_not_in_draft = ::Legislation::Process.not_in_draft
|
||||||
|
|
||||||
expect(processes_not_in_draft).to include(process_before_draft)
|
expect(processes_not_in_draft).to match_array [process_before_draft, process_with_draft_disabled]
|
||||||
expect(processes_not_in_draft).to include(process_with_draft_disabled)
|
|
||||||
expect(processes_not_in_draft).not_to include(process_with_draft_enabled)
|
expect(processes_not_in_draft).not_to include(process_with_draft_enabled)
|
||||||
expect(processes_not_in_draft).not_to include(process_with_draft_only_today)
|
expect(processes_not_in_draft).not_to include(process_with_draft_only_today)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "filters past" do
|
|
||||||
past_processes = ::Legislation::Process.past
|
|
||||||
|
|
||||||
expect(past_processes).to include(process_3)
|
|
||||||
expect(past_processes).not_to include(process_2)
|
|
||||||
expect(past_processes).not_to include(process_1)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#status" do
|
describe "#status" do
|
||||||
|
|||||||
Reference in New Issue
Block a user