Skip to content

Commit 852206c

Browse files
committed
[#73389] Align shared sprint behavior
Align shared sprint behavior with the new controller scoping. This applies the review-driven follow-ups around shared sprint visibility, sprint planning routing, and controller behavior while keeping the legacy and Agile paths consistent. https://community.openproject.org/wp/73389
1 parent 6abf905 commit 852206c

File tree

17 files changed

+88
-97
lines changed

17 files changed

+88
-97
lines changed

modules/backlogs/app/components/backlogs/backlog_component.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def draggable_item_config(story)
8282
{
8383
draggable_id: story.id,
8484
draggable_type: "story",
85-
drop_url: move_legacy_backlogs_project_sprint_story_path(project, sprint, story)
85+
drop_url: move_backlogs_project_sprint_story_path(project, sprint, story)
8686
}
8787
end
8888
end

modules/backlogs/app/controllers/agile/sprint_planning_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class SprintPlanningController < BaseController
3939

4040
def show
4141
if turbo_frame_request?
42-
render partial: "sprint_planning_list", layout: false
42+
render partial: "list", layout: false
4343
else
4444
render :show
4545
end

modules/backlogs/app/controllers/agile/sprints_controller.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,15 @@ def finish
126126

127127
private
128128

129-
# Member actions receive :id, not :sprint_id
129+
# Member actions receive :id, not :sprint_id.
130+
# Scoped to sprint_source (not for_project) to prevent mutation of
131+
# sprints that are merely visible via work-package references.
130132
def load_sprint
131133
sprint_id = params[:sprint_id] || params[:id]
132134
return unless sprint_id
133135

134136
@sprint = ::Agile::Sprint
135-
.for_project(@project)
137+
.where(project: @project.sprint_source)
136138
.visible
137139
.find(sprint_id)
138140
end

modules/backlogs/app/controllers/agile/stories_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def load_project_sprint_and_story
6060
.for_project(@project)
6161
.visible
6262
.find(params[:sprint_id])
63-
@story = ::Story.visible.find(params[:id])
63+
@story = WorkPackage.visible.find(params[:id])
6464
end
6565

6666
def move_story(move_attributes)

modules/backlogs/app/controllers/rb_sprints_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def update_header_component_via_turbo_stream(state: :show)
8181
# Overrides load_sprint_and_project to load the sprint from :id instead of :sprint_id
8282
def load_sprint_and_project
8383
load_project
84-
@sprint = Sprint.visible.find(params[:id])
84+
@sprint = Sprint.visible.apply_to(@project).find(params[:id])
8585
end
8686

8787
def sprint_params

modules/backlogs/app/views/agile/sprint_planning/_sprint_planning_list.html.erb renamed to modules/backlogs/app/views/agile/sprint_planning/_list.html.erb

File renamed without changes.

modules/backlogs/config/routes.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@
8787
as: :details,
8888
work_package_split_view: true,
8989
defaults: { tab: :overview }
90-
91-
get :sprint_planning
9290
end
9391
end
9492

@@ -107,7 +105,7 @@
107105

108106
resources :stories, controller: :rb_stories, only: [] do
109107
member do
110-
put :move_legacy
108+
put :move
111109
post :reorder
112110
end
113111
end

modules/backlogs/lib/open_project/backlogs/engine.rb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def self.settings
6868

6969
project_module :backlogs, dependencies: :work_package_tracking do
7070
permission :view_sprints,
71-
{ rb_master_backlogs: %i[index sprint_planning details],
71+
{ rb_master_backlogs: %i[index details],
7272
rb_sprints: %i[index show show_name],
7373
rb_wikis: :show,
7474
rb_stories: %i[index show],
@@ -90,23 +90,22 @@ def self.settings
9090
require: :member
9191

9292
permission :create_sprints,
93-
{ rb_sprints: %i[new_dialog refresh_form create edit_name update edit_dialog update_agile_sprint],
93+
{ rb_sprints: %i[edit_name update],
9494
rb_wikis: %i[edit update],
9595
"agile/sprints": %i[new_dialog refresh_form create edit_dialog update] },
9696
permissible_on: :project,
9797
require: :member,
9898
dependencies: :view_sprints
9999

100100
permission :start_complete_sprint,
101-
{ rb_sprints: %i[start finish],
102-
"agile/sprints": %i[start finish] },
101+
{ "agile/sprints": %i[start finish] },
103102
permissible_on: :project,
104103
require: :member,
105104
dependencies: %i[view_sprints manage_board_views],
106105
visible: -> { OpenProject::FeatureDecisions.scrum_projects_active? }
107106

108107
permission :manage_sprint_items,
109-
{ rb_stories: %i[move move_legacy reorder],
108+
{ rb_stories: %i[move reorder],
110109
"agile/stories": :move },
111110
permissible_on: :project,
112111
require: :member,
@@ -123,15 +122,15 @@ def self.settings
123122
# Menu items that are there when feature flag is active
124123
menu :project_menu,
125124
:backlogs,
126-
{ controller: "/rb_master_backlogs", action: :sprint_planning },
125+
{ controller: "/agile/sprint_planning", action: :show },
127126
if: Proc.new { |project| project.module_enabled?(:backlogs) && OpenProject::FeatureDecisions.scrum_projects_active? },
128127
caption: :project_module_backlogs,
129128
after: :work_packages,
130129
icon: "op-backlogs"
131130

132131
menu :project_menu,
133132
:sprint_planning,
134-
{ controller: "/rb_master_backlogs", action: :sprint_planning },
133+
{ controller: "/agile/sprint_planning", action: :show },
135134
if: Proc.new { |project| project.module_enabled?(:backlogs) && OpenProject::FeatureDecisions.scrum_projects_active? },
136135
caption: :label_sprint_planning,
137136
parent: :backlogs

modules/backlogs/spec/components/backlogs/backlog_component_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def render_component
129129
story_row = page.find(".Box-row[id='story_#{story1.id}']")
130130
expect(story_row["data-draggable-id"]).to eq(story1.id.to_s)
131131
expect(story_row["data-draggable-type"]).to eq("story")
132-
expect(story_row["data-drop-url"]).to end_with(move_legacy_backlogs_project_sprint_story_path(project, sprint, story1))
132+
expect(story_row["data-drop-url"]).to end_with(move_backlogs_project_sprint_story_path(project, sprint, story1))
133133
end
134134

135135
it "renders story rows with proper classes" do

modules/backlogs/spec/controllers/rb_sprints_controller_spec.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
current_user { user }
3939

4040
let(:visible_projects_scope) { instance_double(ActiveRecord::Relation) }
41-
let(:visible_sprints_scope) { instance_double(ActiveRecord::Relation) }
41+
let(:visible_sprints_scope) { double("Sprint::ActiveRecord_Relation") } # rubocop:disable RSpec/VerifiedDoubles
4242

4343
before do
4444
allow(Setting)
@@ -58,6 +58,11 @@
5858
.to receive(:visible)
5959
.and_return(visible_sprints_scope)
6060

61+
allow(visible_sprints_scope)
62+
.to receive(:apply_to)
63+
.with(project)
64+
.and_return(visible_sprints_scope)
65+
6166
allow(visible_sprints_scope)
6267
.to receive(:find)
6368
.with(sprint.id.to_s)

0 commit comments

Comments
 (0)