Revert "Create the query view only when the query is created (instead of `build`). Further introduce a query factory for queries without views to enable testing the creation explicitly"

This reverts commit a03bdc92c9.
pull/9957/head
Henriette Darge 3 years ago
parent a03bdc92c9
commit 7412ce5b51
  1. 2
      modules/team_planner/spec/requests/api/v3/views/create_resource_spec.rb
  2. 18
      spec/factories/query_factory.rb
  3. 2
      spec/requests/api/v3/views/create_resource_spec.rb
  4. 10
      spec/requests/api/v3/views/index_resource_spec.rb
  5. 2
      spec/requests/api/v3/views/show_resource_spec.rb

@ -46,7 +46,7 @@ describe ::API::V3::Views::ViewsAPI,
members: { permitted_user => role })
end
shared_let(:public_query) do
FactoryBot.create(:query_without_view,
FactoryBot.create(:query,
project: project,
is_public: true)
end

@ -32,8 +32,7 @@ FactoryBot.define do
user factory: :user
transient do
create_view { true }
view_type { :view_work_packages_table }
view { :view_work_packages_table }
end
sequence(:name) { |n| "Query #{n}" }
@ -54,19 +53,10 @@ FactoryBot.define do
sequence(:name) { |n| "Global query #{n}" }
end
factory :query_without_view do
create_view { false }
sequence(:name) { |n| "Public query without view #{n}" }
end
callback(:after_build) do |query|
callback(:after_build) do |query, evaluator|
query.add_default_filter
end
callback(:after_create) do |query, evaluator|
FactoryBot.create(evaluator.view_type,
query: query) if evaluator.create_view
FactoryBot.create(evaluator.view,
query: query)
end
end
end

@ -40,7 +40,7 @@ describe ::API::V3::Views::ViewsAPI,
members: { permitted_user => role })
end
shared_let(:private_user_query) do
FactoryBot.create(:query_without_view,
FactoryBot.create(:query,
project: project,
is_public: false,
user: permitted_user)

@ -43,7 +43,7 @@ describe ::API::V3::Views::ViewsAPI,
members: { permitted_user => role })
end
shared_let(:user_private_project_query) do
FactoryBot.create(:query_without_view,
FactoryBot.create(:query,
user: permitted_user,
project: project,
is_public: false)
@ -53,7 +53,7 @@ describe ::API::V3::Views::ViewsAPI,
query: user_private_project_query)
end
shared_let(:other_user_private_project_query) do
FactoryBot.create(:query_without_view,
FactoryBot.create(:query,
project: project,
is_public: false)
end
@ -62,7 +62,7 @@ describe ::API::V3::Views::ViewsAPI,
query: other_user_private_project_query)
end
shared_let(:user_public_project_query) do
FactoryBot.create(:query_without_view,
FactoryBot.create(:query,
project: project,
is_public: true)
end
@ -75,7 +75,7 @@ describe ::API::V3::Views::ViewsAPI,
members: { permitted_user => role })
end
shared_let(:user_private_other_project_query) do
FactoryBot.create(:query_without_view,
FactoryBot.create(:query,
user: permitted_user,
project: other_project)
end
@ -143,7 +143,7 @@ describe ::API::V3::Views::ViewsAPI,
context 'with a type filter' do
let(:other_user_private_project_query) do
FactoryBot.create(:query_without_view,
FactoryBot.create(:query,
user: permitted_user,
project: project,
is_public: false)

@ -42,7 +42,7 @@ describe ::API::V3::Views::ViewsAPI,
members: { permitted_user => role })
end
shared_let(:private_user_query) do
FactoryBot.create(:query_without_view,
FactoryBot.create(:query,
project: project,
is_public: false,
user: permitted_user)

Loading…
Cancel
Save