Skip to content

Commit

Permalink
Merge pull request #16908 from opf/fix/use-saveable-query-my-page
Browse files Browse the repository at this point in the history
Use the static query strategy for the implicitly created widgets
  • Loading branch information
oliverguenther authored Oct 9, 2024
2 parents a834a6f + f6dbfaf commit 4b2c3f8
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 5 deletions.
4 changes: 2 additions & 2 deletions modules/my_page/lib/my_page/grid_registration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class GridRegistration < ::Grids::Configuration::Registration
column_count: 2,
widgets: [
{
identifier: "work_packages_table",
identifier: "work_packages_assigned",
start_row: 1,
end_row: 2,
start_column: 1,
Expand All @@ -70,7 +70,7 @@ class GridRegistration < ::Grids::Configuration::Registration
}
},
{
identifier: "work_packages_table",
identifier: "work_packages_created",
start_row: 1,
end_row: 2,
start_column: 2,
Expand Down
6 changes: 6 additions & 0 deletions modules/my_page/spec/factories/grid_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,11 @@
)
]
end

trait :empty do
widgets { [] }
row_count { 1 }
column_count { 1 }
end
end
end
5 changes: 5 additions & 0 deletions modules/my_page/spec/features/my/custom_text_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
let(:other_user) do
create(:user, member_with_permissions: { project => permissions })
end

let!(:my_page_grid) do
create(:my_page, :empty, user:)
end

let(:my_page) do
Pages::My::Page.new
end
Expand Down
4 changes: 4 additions & 0 deletions modules/my_page/spec/features/my/documents_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
Pages::My::Page.new
end

let!(:my_page_grid) do
create(:my_page, :empty, user:)
end

before do
login_as user

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
let!(:week_days) { week_with_saturday_and_sunday_as_weekend }
let!(:non_working_day) { create(:non_working_day, date: tuesday) }

let!(:my_page_grid) do
create(:my_page, :empty, user:)
end

before do
login_as user
my_page.visit!
Expand Down
4 changes: 4 additions & 0 deletions modules/my_page/spec/features/my/news_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
Pages::My::Page.new
end

let!(:my_page_grid) do
create(:my_page, :empty, user:)
end

before do
login_as user

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@
create(:user,
member_with_permissions: { project => %i[view_time_entries edit_time_entries view_work_packages log_own_time] })
end

let!(:my_page_grid) do
create(:my_page, :empty, user:)
end

let(:my_page) do
Pages::My::Page.new
end
Expand Down
4 changes: 4 additions & 0 deletions modules/my_page/spec/features/my/work_package_table_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@
context "without the permission to save queries" do
let(:permissions) { %i[view_work_packages add_work_packages] }

let!(:my_page_grid) do
create(:my_page, :empty, user:)
end

it "cannot add the widget" do
my_page.expect_unable_to_add_widget(1, 1, :within, "Work packages table")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
Pages::My::Page.new
end

let!(:my_page_grid) do
create(:my_page, :empty, user:)
end

before do
login_as user
work_package.add_watcher(user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@
}
end

it "contains default data in the payload" do
it "contains default data in the payload" do # rubocop:disable RSpec/ExampleLength
expected = {
rowCount: 1,
columnCount: 2,
options: {},
widgets: [
{
_type: "GridWidget",
identifier: "work_packages_table",
identifier: "work_packages_assigned",
options: {
name: "Work packages assigned to me",
queryProps: {
Expand All @@ -99,7 +99,7 @@
},
{
_type: "GridWidget",
identifier: "work_packages_table",
identifier: "work_packages_created",
options: {
name: "Work packages created by me",
queryProps: {
Expand Down
5 changes: 5 additions & 0 deletions spec/features/projects/favorite_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
end
let(:projects_page) { Pages::Projects::Index.new }
let(:top_menu) { Components::Projects::TopMenu.new }

let!(:my_page_grid) do
create(:my_page, :empty, user:)
end

let(:my_page) do
Pages::My::Page.new
end
Expand Down

0 comments on commit 4b2c3f8

Please sign in to comment.