From 3e585bab9f5d0c01b0acdc7398f598819d149e35 Mon Sep 17 00:00:00 2001 From: Juan Vasquez Date: Tue, 23 Jan 2024 10:40:50 -0600 Subject: [PATCH] Update scope's name --- app/controllers/action_plans_controller.rb | 2 +- app/models/project.rb | 2 +- spec/models/project_spec.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/action_plans_controller.rb b/app/controllers/action_plans_controller.rb index 590d3ca1..9c1baf32 100644 --- a/app/controllers/action_plans_controller.rb +++ b/app/controllers/action_plans_controller.rb @@ -4,6 +4,6 @@ class ActionPlansController < ApplicationController def show @project = Project.find(params[:project_id]) @project_stories = @project.stories.approved.by_position - @children = Project.sub_projects_with_ordered_stories(@project.id) + @children = Project.sub_projects_with_approved_and_ordered_stories(@project.id) end end diff --git a/app/models/project.rb b/app/models/project.rb index 5842593c..da08e80c 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -13,7 +13,7 @@ class Project < ApplicationRecord scope :active, -> { where.not(status: "archived").or(where(status: nil)) } scope :parents, -> { where(parent: nil) } - scope :sub_projects_with_ordered_stories, ->(project_id) { + scope :sub_projects_with_approved_and_ordered_stories, ->(project_id) { where(parent_id: project_id) .includes(:stories).references(:stories) .where(stories: {status: :approved}) diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index b93f7d61..0eaa536f 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -21,7 +21,7 @@ expect(sub_project2.position).to eq 2 end - describe ".sub_projects_with_ordered_stories" do + describe ".sub_projects_with_approved_and_ordered_stories" do it "orders sub projects properly" do parent = FactoryBot.create(:project) sub_project1 = FactoryBot.create(:project, parent: parent, position: 2) @@ -33,7 +33,7 @@ story_3 = FactoryBot.create(:story, :approved, project: sub_project2, position: 3) story_1 = FactoryBot.create(:story, :approved, project: sub_project2, position: 1) story_2 = FactoryBot.create(:story, :approved, project: sub_project2, position: 2) - sub_projects = Project.sub_projects_with_ordered_stories(parent.id) + sub_projects = Project.sub_projects_with_approved_and_ordered_stories(parent.id) expect(sub_projects.count).to eq 2 expect(sub_projects[0].id).to eq sub_project2.id