Skip to content

Commit

Permalink
Refactor tests to use new interface for user factory #3
Browse files Browse the repository at this point in the history
  • Loading branch information
klaustopher committed Sep 20, 2023
1 parent fe4326c commit bf630bb
Show file tree
Hide file tree
Showing 34 changed files with 38 additions and 76 deletions.
3 changes: 1 addition & 2 deletions spec/features/members/invitation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
current_user do
create(:user,
global_permissions: [:create_user],
member_in_project: project,
member_with_permissions: %i[view_members manage_members])
member_with_permissions: { project => %i[view_members manage_members] })
end

context 'with a new user' do
Expand Down
3 changes: 1 addition & 2 deletions spec/features/menu_items/menu_permissions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
with_cuprite: true do
let(:user) do
create(:user,
member_in_project: project,
member_with_permissions: %i[manage_versions view_work_packages])
member_with_permissions: { project => %i[manage_versions view_work_packages] })
end
let(:admin) { create(:admin) }

Expand Down
3 changes: 1 addition & 2 deletions spec/features/notifications/navigation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
shared_let(:second_work_package) { create(:work_package, project:) }
shared_let(:recipient) do
create(:user,
member_in_project: project,
member_with_permissions: %i[view_work_packages])
member_with_permissions: { project => %i[view_work_packages] })
end
shared_let(:notification) do
create(:notification,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

shared_let(:recipient) do
create(:user,
member_in_project: project,
member_with_permissions: %i[view_work_packages])
member_with_permissions: { project => %i[view_work_packages] })
end
shared_let(:notification) do
create(:notification,
Expand Down
3 changes: 1 addition & 2 deletions spec/features/versions/edit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
RSpec.describe 'version edit' do
let(:user) do
create(:user,
member_in_project: version.project,
member_with_permissions: %i[manage_versions view_work_packages])
member_with_permissions: { version.project => %i[manage_versions view_work_packages] })
end
let(:version) { create(:version) }
let(:new_version_name) { 'A new version name' }
Expand Down
3 changes: 1 addition & 2 deletions spec/features/versions/project_settings_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
RSpec.describe 'project settings index' do
let(:user) do
create(:user,
member_in_project: project,
member_with_permissions: %i[manage_versions])
member_with_permissions: { project => %i[manage_versions] })
end
let(:project) { create(:project) }
let!(:version1) { create(:version, name: "aaaaa 1.", project:) }
Expand Down
3 changes: 1 addition & 2 deletions spec/features/wiki/attachment_upload_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
RSpec.describe 'Upload attachment to wiki page', js: true do
let(:user) do
create(:user,
member_in_project: project,
member_with_permissions: %i[view_wiki_pages edit_wiki_pages])
member_with_permissions: { project => %i[view_wiki_pages edit_wiki_pages] })
end
let(:project) { create(:project) }
let(:attachments) { Components::Attachments.new }
Expand Down
3 changes: 1 addition & 2 deletions spec/features/work_packages/bulk/copy_work_package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
create(:user,
firstname: 'Dev',
lastname: 'Guy',
member_in_project: project,
member_with_permissions: %i[view_work_packages work_package_assigned])
member_with_permissions: { project => %i[view_work_packages work_package_assigned] })
end
shared_let(:mover) do
create(:user,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@
let(:work_package) { create(:work_package, project:) }
let(:user) do
create(:user,
member_in_project: project,
member_with_permissions: %i[view_work_packages edit_work_packages manage_versions assign_versions])
member_with_permissions: { project => %i[view_work_packages edit_work_packages manage_versions assign_versions] })
end
let(:second_user) do
create(:user,
member_in_project: project,
member_with_permissions: %i[view_work_packages edit_work_packages assign_versions])
member_with_permissions: { project => %i[view_work_packages edit_work_packages assign_versions] })
end
let(:permissions) { %i[view_work_packages edit_work_packages assign_versions] }
let(:work_package_page) { Pages::FullWorkPackage.new(work_package) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
create(:user,
firstname: 'Itsa',
lastname: 'Me',
member_in_project: visible_project,
member_with_permissions: %i[view_work_packages edit_work_packages work_package_assigned assign_versions])
member_with_permissions: { visible_project => %i[view_work_packages edit_work_packages work_package_assigned assign_versions] })
end

shared_let(:wp_bug) do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,13 @@
shared_let(:berlin_user) do
create(:user,
preferences: { time_zone: 'Europe/Berlin' },
member_in_project: project,
member_with_permissions: %i[view_work_packages save_queries manage_public_queries])
member_with_permissions: { project => %i[view_work_packages save_queries manage_public_queries] })
end

shared_let(:tokyo_user) do
create(:user,
preferences: { time_zone: 'Asia/Tokyo' },
member_in_project: project,
member_with_permissions: %i[view_work_packages save_queries manage_public_queries])
member_with_permissions: { project => %i[view_work_packages save_queries manage_public_queries] })
end

it 'shows a warning when an incompatible filter is used' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,14 @@
create(:admin,
firstname: 'Itsa',
lastname: 'Me',
member_in_project: project,
member_with_permissions: %i[view_work_packages edit_work_packages work_package_assigned assign_versions])
member_with_permissions: { project => %i[view_work_packages edit_work_packages work_package_assigned assign_versions] })
end

shared_let(:assignee) do
create(:user,
firstname: 'Assigned',
lastname: 'User',
member_in_project: project,
member_with_permissions: %i[view_work_packages edit_work_packages work_package_assigned])
member_with_permissions: { project => %i[view_work_packages edit_work_packages work_package_assigned] })
end

shared_let(:default_priority) do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@

current_user do
create(:user,
member_in_project: project,
member_with_permissions: %i[view_work_packages save_queries])
member_with_permissions: { project => %i[view_work_packages save_queries] })
end

it 'shows the work package matching the bool cf filter' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
RSpec.describe 'Filter updates pagination', js: true do
let(:user) do
create(:user,
member_in_project: project,
member_with_permissions: %i[view_work_packages])
member_with_permissions: { project => %i[view_work_packages] })
end

let(:work_packages_page) { WorkPackagesPage.new(project) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
end
let(:principal) do
create(:user,
member_in_project: project,
member_with_permissions: %i[view_members])
member_with_permissions: { project => %i[view_members] })
end
let(:project) do
create(:project)
Expand All @@ -52,8 +51,7 @@

current_user do
create(:user,
member_in_project: project,
member_with_permissions: [])
member_with_permissions: { project => [] })
end

subject(:json) do
Expand Down
3 changes: 1 addition & 2 deletions spec/models/journable/with_historic_attributes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@
create(:user,
firstname: 'user',
lastname: '1',
member_in_project: project,
member_with_permissions: %i[view_work_packages view_file_links])
member_with_permissions: { project => %i[view_work_packages view_file_links] })
end
let(:build_query) do
build(:query, user: nil, project: nil).tap do |query|
Expand Down
3 changes: 1 addition & 2 deletions spec/models/query/results_cf_sorting_integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
create(:user,
firstname: 'user',
lastname: '1',
member_in_project: project,
member_with_permissions: [:view_work_packages])
member_with_permissions: { project => [:view_work_packages] })
end

let(:type) { create(:type_standard, custom_fields: [custom_field]) }
Expand Down
3 changes: 1 addition & 2 deletions spec/models/query/results_filter_on_historic_data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
create(:user,
firstname: 'user',
lastname: '1',
member_in_project: project_with_member,
member_with_permissions: %i[view_work_packages view_file_links])
member_with_permissions: { project_with_member => %i[view_work_packages view_file_links] })
end

def move_work_package_to_project(work_package, project, time)
Expand Down
3 changes: 1 addition & 2 deletions spec/models/query/results_sort_intergration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
create(:user,
firstname: 'user',
lastname: '1',
member_in_project: project1,
member_with_permissions: [:view_work_packages])
member_with_permissions: { project1 => [:view_work_packages] })
end
let(:user_a) { create(:user, firstname: 'AAA', lastname: 'AAA') }
let(:user_m) { create(:user, firstname: 'mmm', lastname: 'mmm') }
Expand Down
3 changes: 1 addition & 2 deletions spec/models/query/results_subject_filter_integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
create(:user,
firstname: 'user',
lastname: '1',
member_in_project: project,
member_with_permissions: [:view_work_packages])
member_with_permissions: { project => [:view_work_packages] })
end

let!(:contains_wp) do
Expand Down
3 changes: 1 addition & 2 deletions spec/models/query/results_version_integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
create(:user,
firstname: 'user',
lastname: '1',
member_in_project: project,
member_with_permissions: [:view_work_packages])
member_with_permissions: { project => [:view_work_packages] })
end

let(:old_version) do
Expand Down
3 changes: 1 addition & 2 deletions spec/models/watcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@
let(:notification_settings) { [] }
let(:saved_user) do
create(:user,
member_in_project: saved_watchable.project,
member_with_permissions: [],
member_with_permissions: { saved_watchable.project => [] },
notification_settings:)
end
let(:saved_watchable) { create(:news) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@
end
let(:user) do
create(:user,
member_in_project: project,
member_with_permissions: %w[view_work_packages export_work_packages])
member_with_permissions: { project => %w[view_work_packages export_work_packages] })
end
let(:export_time) { DateTime.new(2023, 6, 30, 23, 59) }
let(:export_time_formatted) { format_time(export_time, true) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
let(:project) { create(:project, name: 'Foo Bla. Report No. 4/2021 with/for Case 42', types: [type]) }
let(:user) do
create(:user,
member_in_project: project,
member_with_permissions: %w[view_work_packages export_work_packages])
member_with_permissions: { project => %w[view_work_packages export_work_packages] })
end
let(:export_time) { DateTime.new(2023, 6, 30, 23, 59) }
let(:export_time_formatted) { format_time(export_time, true) }
Expand Down
3 changes: 1 addition & 2 deletions spec/requests/api/v3/capability_resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
shared_let(:project) { create(:project) }
shared_current_user do
create(:user,
member_in_project: project,
member_with_permissions: %i[manage_members])
member_with_permissions: { project => %i[manage_members] })
end

let(:role) do
Expand Down
3 changes: 1 addition & 2 deletions spec/requests/api/v3/notifications/details_resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
end
shared_let(:recipient) do
create(:user,
member_in_project: project,
member_with_permissions: %i[view_work_packages])
member_with_permissions: { project => %i[view_work_packages] })
end

let(:notification) { create(:notification, recipient:, resource:, project:, reason:) }
Expand Down
3 changes: 1 addition & 2 deletions spec/requests/api/v3/notifications/index_resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
shared_let(:work_package) { create(:work_package) }
shared_let(:recipient) do
create(:user,
member_in_project: work_package.project,
member_with_permissions: %i[view_work_packages])
member_with_permissions: { work_package.project => %i[view_work_packages] })
end
shared_let(:mentioned_notification) do
create(:notification,
Expand Down
3 changes: 1 addition & 2 deletions spec/requests/api/v3/notifications/read_ian_resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
shared_let(:work_package) { create(:work_package, project:) }
shared_let(:recipient) do
create(:user,
member_in_project: project,
member_with_permissions: %i[view_work_packages])
member_with_permissions: { project => %i[view_work_packages] })
end
shared_let(:notification) do
create(:notification,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@

shared_let(:current_user) do
create(:user,
member_in_project: source_project,
member_with_permissions: %i[copy_projects view_project view_work_packages])
member_with_permissions: { source_project => %i[copy_projects view_project view_work_packages] })
end

let(:path) { api_v3_paths.project_copy_form(source_project.id) }
Expand Down
3 changes: 1 addition & 2 deletions spec/requests/api/v3/projects/copy/copy_resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@

shared_let(:current_user) do
create(:user,
member_in_project: source_project,
member_with_permissions: %i[copy_projects view_project view_work_packages])
member_with_permissions: { source_project => %i[copy_projects view_project view_work_packages] })
end

let(:path) { api_v3_paths.project_copy(source_project.id) }
Expand Down
3 changes: 1 addition & 2 deletions spec/requests/auth/token_based_access_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
let(:work_package) { create(:work_package) }
let(:user) do
create(:user,
member_in_project: work_package.project,
member_with_permissions: %i[view_work_packages])
member_with_permissions: { work_package.project => %i[view_work_packages] })
end
let(:rss_key) { user.rss_key }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
shared_let(:container) { create(:work_package) }
shared_let(:user) do
create(:user,
member_in_project: container.project,
member_with_permissions: %i[view_work_packages edit_work_packages])
member_with_permissions: { container.project => %i[view_work_packages edit_work_packages] })
end
let(:instance) { described_class.new(user:) }

Expand Down
3 changes: 1 addition & 2 deletions spec/support/shared/acts_as_attachable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
end
let(:no_permission_user) do
create(:user,
member_in_project: instance_project,
member_with_permissions: [])
member_with_permissions: { instance_project => [] })
end
let(:other_user) do
create(:user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
let(:project) { create(:project) }
let(:user) do
create(:user,
member_in_project: project,
member_with_permissions: %w[view_work_packages export_work_packages])
member_with_permissions: { project => %w[view_work_packages export_work_packages] })
end
let(:export) do
create(:work_packages_export)
Expand Down

0 comments on commit bf630bb

Please sign in to comment.