From 597d0c92ee94ad374a2ba944206c5a4aa3e5e1dd Mon Sep 17 00:00:00 2001 From: Francois Buys Date: Tue, 23 Jan 2024 19:27:20 +0200 Subject: [PATCH] VLT-1: Improve specs related to approved stories. --- spec/features/action_plan_generate_spec.rb | 6 +++--- spec/models/story_spec.rb | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/spec/features/action_plan_generate_spec.rb b/spec/features/action_plan_generate_spec.rb index 62f93c0f..186e201d 100644 --- a/spec/features/action_plan_generate_spec.rb +++ b/spec/features/action_plan_generate_spec.rb @@ -8,9 +8,10 @@ let!(:project) do FactoryBot.create(:project, parent: parent).tap do |project| - FactoryBot.create(:story, :approved, title: "Second Story", description: "Second", position: 2, project: project, extra_info: "Extra Information") + FactoryBot.create(:story, :approved, title: "Second Story", description: "Second", position: 3, project: project, extra_info: "Extra Information") FactoryBot.create(:story, :approved, title: "First Story", description: "First", position: 1, project: project) - FactoryBot.create(:story, :pending, title: "Pending task", description: "Pending description", position: 3, project: project) + FactoryBot.create(:story, :pending, title: "Pending task", description: "Pending description", position: 2, project: project) + FactoryBot.create(:story, :rejected, title: "Rejected task", description: "Rejected description", position: 4, project: project) end end @@ -18,7 +19,6 @@ FactoryBot.create(:project, parent: parent).tap do |project| FactoryBot.create(:story, :approved, title: "Third Story", description: "Third", position: 2, project: project) FactoryBot.create(:story, :approved, title: "Forth Story", description: "Forth", position: 1, project: project) - FactoryBot.create(:story, :rejected, title: "Rejected task", description: "Rejected description", position: 3, project: project) end end diff --git a/spec/models/story_spec.rb b/spec/models/story_spec.rb index b9b69db6..737f4d5d 100644 --- a/spec/models/story_spec.rb +++ b/spec/models/story_spec.rb @@ -119,9 +119,10 @@ describe ".approved" do it "returns only approved stories" do approved_stories = FactoryBot.create_list(:story, 2, :approved) - FactoryBot.create_list(:story, 2, :rejected) + FactoryBot.create(:story, :rejected) + FactoryBot.create(:story, :pending) - expect(Story.approved).to eq(approved_stories) + expect(Story.approved.map(&:id).sort).to eq(approved_stories.map(&:id).sort) end end end