OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#41299] fixed unit test expectations
Eric Schubertd3edd1531e87
diff --git a/docs/api/apiv3/openapi-spec.yml b/docs/api/apiv3/openapi-spec.ymlindex b2d8b5b555c..30ae39bbb87 100644--- a/docs/api/apiv3/openapi-spec.yml+++ b/docs/api/apiv3/openapi-spec.yml@@ -256,6 +256,10 @@ paths:"$ref": "./paths/oauth_application.yml""/api/v3/oauth_client_credentials/{id}":"$ref": "./paths/oauth_client_credentials.yml"+ "/api/v3/placeholder_users":+ "$ref": "./paths/placeholder_users.yml"+ "/api/v3/placeholder_users/{id}":+ "$ref": "./paths/placeholder_user.yml""/api/v3/posts/{id}":"$ref": "./paths/post.yml""/api/v3/posts/{id}/attachments":@@ -677,6 +681,8 @@ components:"$ref": "./components/schemas/paginated_collection_model.yml"PlaceholderUserCollectionModel:"$ref": "./components/schemas/placeholder_user_collection_model.yml"+ PlaceholderUserCreateModel:+ "$ref": "./components/schemas/placeholder_user_create_model.yml"PlaceholderUserModel:"$ref": "./components/schemas/placeholder_user_model.yml"Plain_TextModel:diff --git a/spec/lib/api/v3/placeholder_users/placeholder_user_representer_rendering_spec.rb b/spec/lib/api/v3/placeholder_users/placeholder_user_representer_rendering_spec.rbindex 122056d9eb1..3648a4f8441 100644--- a/spec/lib/api/v3/placeholder_users/placeholder_user_representer_rendering_spec.rb+++ b/spec/lib/api/v3/placeholder_users/placeholder_user_representer_rendering_spec.rb@@ -59,7 +59,7 @@ RSpec.describe API::V3::PlaceholderUsers::PlaceholderUserRepresenter, 'renderingenddescribe '_links' do- context 'self' do+ describe 'self' doit_behaves_like 'has a titled link' dolet(:link) { 'self' }let(:href) { api_v3_paths.placeholder_user placeholder_user.id }@@ -67,19 +67,19 @@ RSpec.describe API::V3::PlaceholderUsers::PlaceholderUserRepresenter, 'renderingendend- context 'showUser' do+ describe 'showUser' doit_behaves_like 'has an untitled link' dolet(:link) { 'showUser' }let(:href) { "/placeholder_users/#{placeholder_user.id}" }endend- context 'delete' do+ describe 'delete' doit_behaves_like 'has no link' dolet(:link) { 'delete' }end- context 'when user allowed to manage' do+ context 'if user is allowed to manage' dolet(:global_permissions) { [:manage_placeholder_user] }it_behaves_like 'has a titled link' do@@ -91,7 +91,7 @@ RSpec.describe API::V3::PlaceholderUsers::PlaceholderUserRepresenter, 'renderingendend- context 'updateImmediately' do+ describe 'updateImmediately' doit_behaves_like 'has no link' dolet(:link) { 'updateImmediately' }end@@ -108,28 +108,28 @@ RSpec.describe API::V3::PlaceholderUsers::PlaceholderUserRepresenter, 'renderingendend- context 'memberships' do+ describe 'memberships' doit_behaves_like 'has no link' dolet(:link) { 'memberships' }end- context 'user allowed to see members' do+ context 'if user is allowed to see members' dolet(:project_permissions) { [:view_members] }it_behaves_like 'has a titled link' dolet(:link) { 'memberships' }let(:href) { memberships_path }- let(:title) { I18n.t(:label_member_plural) }+ let(:title) { I18n.t(:label_membership_plural) }endend- context 'user allowed to manage members' do+ context 'if user is allowed to manage members' dolet(:project_permissions) { [:manage_members] }it_behaves_like 'has a titled link' dolet(:link) { 'memberships' }let(:href) { memberships_path }- let(:title) { I18n.t(:label_member_plural) }+ let(:title) { I18n.t(:label_membership_plural) }endendend@@ -181,12 +181,15 @@ RSpec.describe API::V3::PlaceholderUsers::PlaceholderUserRepresenter, 'renderingdescribe 'caching' doit 'is based on the representer\'s cache_key' do- expect(OpenProject::Cache)+ allow(OpenProject::Cache).to receive(:fetch)- .with(representer.json_cache_key).and_call_originalrepresenter.to_json++ expect(OpenProject::Cache)+ .to have_received(:fetch)+ .with(representer.json_cache_key)enddescribe '#json_cache_key' do@@ -205,7 +208,7 @@ RSpec.describe API::V3::PlaceholderUsers::PlaceholderUserRepresenter, 'renderingendit 'changes when the placeholder is updated' do- placeholder_user.updated_at = Time.now + 20.seconds+ placeholder_user.updated_at = 20.seconds.from_nowexpect(representer.json_cache_key).not_to eql former_cache_keydiff --git a/spec/lib/api/v3/users/user_representer_spec.rb b/spec/lib/api/v3/users/user_representer_spec.rbindex 877052a520a..fe12cac792a 100644--- a/spec/lib/api/v3/users/user_representer_spec.rb+++ b/spec/lib/api/v3/users/user_representer_spec.rb@@ -36,7 +36,7 @@ RSpec.describe API::V3::Users::UserRepresenter doinclude API::V3::Utilities::PathHelper- context 'generation' do+ describe 'generation' dosubject(:generated) { representer.to_json }it do@@ -114,13 +114,13 @@ RSpec.describe API::V3::Users::UserRepresenter doendend- context 'user shows his E-Mail address' do+ context 'if user shows his E-Mail address' dolet(:preference) { build(:user_preference, hide_mail: false) }it_behaves_like 'shows the users E-Mail address'end- context 'user hides his E-Mail address' do+ context 'if user hides his E-Mail address' dolet(:preference) { build(:user_preference, hide_mail: true) }it 'does not render the users E-Mail address' do@@ -156,7 +156,7 @@ RSpec.describe API::V3::Users::UserRepresenter doexpect(subject).to have_json_path('_links/self/href')end- context 'showUser' do+ describe 'showUser' doit_behaves_like 'has an untitled link' dolet(:link) { 'showUser' }let(:href) { "/users/#{user.id}" }@@ -197,8 +197,8 @@ RSpec.describe API::V3::Users::UserRepresenter docontext 'when deletion is allowed' dobefore doallow(Users::DeleteContract).to receive(:deletion_allowed?)- .with(user, current_user)- .and_return(true)+ .with(user, current_user)+ .and_return(true)endit 'links to delete' do@@ -210,8 +210,8 @@ RSpec.describe API::V3::Users::UserRepresenter docontext 'when deletion is allowed' dobefore doallow(Users::DeleteContract).to receive(:deletion_allowed?)- .with(user, current_user)- .and_return(true)+ .with(user, current_user)+ .and_return(true)endit 'links to delete' do@@ -222,8 +222,8 @@ RSpec.describe API::V3::Users::UserRepresenter docontext 'when deletion is not allowed' dobefore doallow(Users::DeleteContract).to receive(:deletion_allowed?)- .with(user, current_user)- .and_return(false)+ .with(user, current_user)+ .and_return(false)endit 'does not link to delete' do@@ -252,7 +252,7 @@ RSpec.describe API::V3::Users::UserRepresenter doit_behaves_like 'has a titled link' dolet(:link) { 'memberships' }- let(:title) { I18n.t(:label_member_plural) }+ let(:title) { I18n.t(:label_membership_plural) }endend@@ -261,7 +261,7 @@ RSpec.describe API::V3::Users::UserRepresenter doit_behaves_like 'has a titled link' dolet(:link) { 'memberships' }- let(:title) { I18n.t(:label_member_plural) }+ let(:title) { I18n.t(:label_membership_plural) }endend@@ -277,12 +277,15 @@ RSpec.describe API::V3::Users::UserRepresenter dodescribe 'caching' doit 'is based on the representer\'s cache_key' do- expect(OpenProject::Cache)+ allow(OpenProject::Cache).to receive(:fetch)- .with(representer.json_cache_key)- .and_call_original+ .and_call_originalrepresenter.to_json++ expect(OpenProject::Cache)+ .to have_received(:fetch)+ .with(representer.json_cache_key)enddescribe '#json_cache_key' do@@ -308,7 +311,7 @@ RSpec.describe API::V3::Users::UserRepresenter doendit 'changes when the user is updated' do- user.updated_at = Time.now + 20.seconds+ user.updated_at = 20.seconds.from_nowexpect(representer.json_cache_key).not_to eql former_cache_keydiff --git a/spec/requests/api/v3/placeholder_users/delete_resource_examples.rb b/spec/requests/api/v3/placeholder_users/delete_resource_examples.rbindex 37e5f64fa4b..562f0dbf73b 100644--- a/spec/requests/api/v3/placeholder_users/delete_resource_examples.rb+++ b/spec/requests/api/v3/placeholder_users/delete_resource_examples.rb@@ -26,8 +26,8 @@# See COPYRIGHT and LICENSE files for more details.RSpec.shared_examples 'deletion allowed' do- it 'responds with 202' do- expect(last_response.status).to eq 202+ it 'responds with 204' do+ expect(last_response.status).to eq 204endit 'locks the account and mark for deletion' do@@ -51,6 +51,6 @@ RSpec.shared_examples 'deletion is not allowed' doendit 'does not delete the user' do- expect(PlaceholderUser.exists?(placeholder.id)).to be_truthy+ expect(PlaceholderUser).to exist(placeholder.id)endend