Skip to content

Commit

Permalink
Update scope's name
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanVqz committed Jan 23, 2024
1 parent d0eb2ee commit 3e585ba
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/action_plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
4 changes: 2 additions & 2 deletions spec/models/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 3e585ba

Please sign in to comment.