Commit 83adb7e8 authored by Eulyeon Ko's avatar Eulyeon Ko Committed by Eulyeon Ko

Apply reviewer suggestions

- Test the scenario in which confidential argument
is set to false.

- Expand the description for confidential argument
parent 73386287
...@@ -63,7 +63,7 @@ module IssueResolverArguments ...@@ -63,7 +63,7 @@ module IssueResolverArguments
argument :confidential, argument :confidential,
GraphQL::Types::Boolean, GraphQL::Types::Boolean,
required: false, required: false,
description: 'Filter for confidential issues.' description: 'Filter for confidential issues. "false" excludes confidential issues. "true" returns only the confidential issues.'
argument :not, Types::Issues::NegatedIssueFilterInputType, argument :not, Types::Issues::NegatedIssueFilterInputType,
description: 'Negated arguments.', description: 'Negated arguments.',
prepare: ->(negated_args, ctx) { negated_args.to_h }, prepare: ->(negated_args, ctx) { negated_args.to_h },
......
...@@ -10300,7 +10300,7 @@ four standard [pagination arguments](#connection-pagination-arguments): ...@@ -10300,7 +10300,7 @@ four standard [pagination arguments](#connection-pagination-arguments):
| <a id="groupissuesauthorusername"></a>`authorUsername` | [`String`](#string) | Username of the author of the issue. | | <a id="groupissuesauthorusername"></a>`authorUsername` | [`String`](#string) | Username of the author of the issue. |
| <a id="groupissuesclosedafter"></a>`closedAfter` | [`Time`](#time) | Issues closed after this date. | | <a id="groupissuesclosedafter"></a>`closedAfter` | [`Time`](#time) | Issues closed after this date. |
| <a id="groupissuesclosedbefore"></a>`closedBefore` | [`Time`](#time) | Issues closed before this date. | | <a id="groupissuesclosedbefore"></a>`closedBefore` | [`Time`](#time) | Issues closed before this date. |
| <a id="groupissuesconfidential"></a>`confidential` | [`Boolean`](#boolean) | Filter for confidential issues. | | <a id="groupissuesconfidential"></a>`confidential` | [`Boolean`](#boolean) | Filter for confidential issues. "false" excludes confidential issues. "true" returns only the confidential issues. |
| <a id="groupissuescreatedafter"></a>`createdAfter` | [`Time`](#time) | Issues created after this date. | | <a id="groupissuescreatedafter"></a>`createdAfter` | [`Time`](#time) | Issues created after this date. |
| <a id="groupissuescreatedbefore"></a>`createdBefore` | [`Time`](#time) | Issues created before this date. | | <a id="groupissuescreatedbefore"></a>`createdBefore` | [`Time`](#time) | Issues created before this date. |
| <a id="groupissuesepicid"></a>`epicId` | [`String`](#string) | ID of an epic associated with the issues, "none" and "any" values are supported. | | <a id="groupissuesepicid"></a>`epicId` | [`String`](#string) | ID of an epic associated with the issues, "none" and "any" values are supported. |
...@@ -12736,7 +12736,7 @@ Returns [`Issue`](#issue). ...@@ -12736,7 +12736,7 @@ Returns [`Issue`](#issue).
| <a id="projectissueauthorusername"></a>`authorUsername` | [`String`](#string) | Username of the author of the issue. | | <a id="projectissueauthorusername"></a>`authorUsername` | [`String`](#string) | Username of the author of the issue. |
| <a id="projectissueclosedafter"></a>`closedAfter` | [`Time`](#time) | Issues closed after this date. | | <a id="projectissueclosedafter"></a>`closedAfter` | [`Time`](#time) | Issues closed after this date. |
| <a id="projectissueclosedbefore"></a>`closedBefore` | [`Time`](#time) | Issues closed before this date. | | <a id="projectissueclosedbefore"></a>`closedBefore` | [`Time`](#time) | Issues closed before this date. |
| <a id="projectissueconfidential"></a>`confidential` | [`Boolean`](#boolean) | Filter for confidential issues. | | <a id="projectissueconfidential"></a>`confidential` | [`Boolean`](#boolean) | Filter for confidential issues. "false" excludes confidential issues. "true" returns only the confidential issues. |
| <a id="projectissuecreatedafter"></a>`createdAfter` | [`Time`](#time) | Issues created after this date. | | <a id="projectissuecreatedafter"></a>`createdAfter` | [`Time`](#time) | Issues created after this date. |
| <a id="projectissuecreatedbefore"></a>`createdBefore` | [`Time`](#time) | Issues created before this date. | | <a id="projectissuecreatedbefore"></a>`createdBefore` | [`Time`](#time) | Issues created before this date. |
| <a id="projectissueepicid"></a>`epicId` | [`String`](#string) | ID of an epic associated with the issues, "none" and "any" values are supported. | | <a id="projectissueepicid"></a>`epicId` | [`String`](#string) | ID of an epic associated with the issues, "none" and "any" values are supported. |
...@@ -12773,7 +12773,7 @@ Returns [`IssueStatusCountsType`](#issuestatuscountstype). ...@@ -12773,7 +12773,7 @@ Returns [`IssueStatusCountsType`](#issuestatuscountstype).
| <a id="projectissuestatuscountsauthorusername"></a>`authorUsername` | [`String`](#string) | Username of the author of the issue. | | <a id="projectissuestatuscountsauthorusername"></a>`authorUsername` | [`String`](#string) | Username of the author of the issue. |
| <a id="projectissuestatuscountsclosedafter"></a>`closedAfter` | [`Time`](#time) | Issues closed after this date. | | <a id="projectissuestatuscountsclosedafter"></a>`closedAfter` | [`Time`](#time) | Issues closed after this date. |
| <a id="projectissuestatuscountsclosedbefore"></a>`closedBefore` | [`Time`](#time) | Issues closed before this date. | | <a id="projectissuestatuscountsclosedbefore"></a>`closedBefore` | [`Time`](#time) | Issues closed before this date. |
| <a id="projectissuestatuscountsconfidential"></a>`confidential` | [`Boolean`](#boolean) | Filter for confidential issues. | | <a id="projectissuestatuscountsconfidential"></a>`confidential` | [`Boolean`](#boolean) | Filter for confidential issues. "false" excludes confidential issues. "true" returns only the confidential issues. |
| <a id="projectissuestatuscountscreatedafter"></a>`createdAfter` | [`Time`](#time) | Issues created after this date. | | <a id="projectissuestatuscountscreatedafter"></a>`createdAfter` | [`Time`](#time) | Issues created after this date. |
| <a id="projectissuestatuscountscreatedbefore"></a>`createdBefore` | [`Time`](#time) | Issues created before this date. | | <a id="projectissuestatuscountscreatedbefore"></a>`createdBefore` | [`Time`](#time) | Issues created before this date. |
| <a id="projectissuestatuscountsiid"></a>`iid` | [`String`](#string) | IID of the issue. For example, "1". | | <a id="projectissuestatuscountsiid"></a>`iid` | [`String`](#string) | IID of the issue. For example, "1". |
...@@ -12808,7 +12808,7 @@ four standard [pagination arguments](#connection-pagination-arguments): ...@@ -12808,7 +12808,7 @@ four standard [pagination arguments](#connection-pagination-arguments):
| <a id="projectissuesauthorusername"></a>`authorUsername` | [`String`](#string) | Username of the author of the issue. | | <a id="projectissuesauthorusername"></a>`authorUsername` | [`String`](#string) | Username of the author of the issue. |
| <a id="projectissuesclosedafter"></a>`closedAfter` | [`Time`](#time) | Issues closed after this date. | | <a id="projectissuesclosedafter"></a>`closedAfter` | [`Time`](#time) | Issues closed after this date. |
| <a id="projectissuesclosedbefore"></a>`closedBefore` | [`Time`](#time) | Issues closed before this date. | | <a id="projectissuesclosedbefore"></a>`closedBefore` | [`Time`](#time) | Issues closed before this date. |
| <a id="projectissuesconfidential"></a>`confidential` | [`Boolean`](#boolean) | Filter for confidential issues. | | <a id="projectissuesconfidential"></a>`confidential` | [`Boolean`](#boolean) | Filter for confidential issues. "false" excludes confidential issues. "true" returns only the confidential issues. |
| <a id="projectissuescreatedafter"></a>`createdAfter` | [`Time`](#time) | Issues created after this date. | | <a id="projectissuescreatedafter"></a>`createdAfter` | [`Time`](#time) | Issues created after this date. |
| <a id="projectissuescreatedbefore"></a>`createdBefore` | [`Time`](#time) | Issues created before this date. | | <a id="projectissuescreatedbefore"></a>`createdBefore` | [`Time`](#time) | Issues created before this date. |
| <a id="projectissuesepicid"></a>`epicId` | [`String`](#string) | ID of an epic associated with the issues, "none" and "any" values are supported. | | <a id="projectissuesepicid"></a>`epicId` | [`String`](#string) | ID of an epic associated with the issues, "none" and "any" values are supported. |
......
...@@ -32,7 +32,7 @@ RSpec.describe Resolvers::IssuesResolver do ...@@ -32,7 +32,7 @@ RSpec.describe Resolvers::IssuesResolver do
end end
context "with a project" do context "with a project" do
let!(:obj) { project } let(:obj) { project }
before_all do before_all do
project.add_developer(current_user) project.add_developer(current_user)
...@@ -229,25 +229,37 @@ RSpec.describe Resolvers::IssuesResolver do ...@@ -229,25 +229,37 @@ RSpec.describe Resolvers::IssuesResolver do
end end
end end
context 'filtering for confidential issues' do context 'confidential issues' do
include_context 'filtering for confidential issues' include_context 'filtering for confidential issues'
context 'when filter is explicitly set to false' do context "when user is allowed to view confidential issues" do
it 'returns all viewable issues' do it 'returns all viewable issues by default' do
expect(resolve_issues).to contain_exactly(issue1, issue2, confidential_issue1) expect(resolve_issues).to contain_exactly(issue1, issue2, confidential_issue1)
end end
end
context "when user is allowed to view confidential issues" do it 'returns only the non-confidential issues for the project when filter is set to false' do
it "returns only the confidential issues of the project" do expect(resolve_issues({ confidential: false })).to contain_exactly(issue1, issue2)
end
it "returns only the confidential issues for the project when filter is set to true" do
expect(resolve_issues({ confidential: true })).to contain_exactly(confidential_issue1) expect(resolve_issues({ confidential: true })).to contain_exactly(confidential_issue1)
end end
end end
context "when user is not allowed to see confidential issues" do context "when user is not allowed to see confidential issues" do
it 'does not return the confidential issues' do before do
project.add_guest(current_user) project.add_guest(current_user)
end
it 'returns all viewable issues by default' do
expect(resolve_issues).to contain_exactly(issue1, issue2)
end
it 'does not return the confidential issues when filter is set to false' do
expect(resolve_issues({ confidential: false })).to contain_exactly(issue1, issue2)
end
it 'does not return the confidential issues when filter is set to true' do
expect(resolve_issues({ confidential: true })).to be_empty expect(resolve_issues({ confidential: true })).to be_empty
end end
end end
...@@ -550,7 +562,7 @@ RSpec.describe Resolvers::IssuesResolver do ...@@ -550,7 +562,7 @@ RSpec.describe Resolvers::IssuesResolver do
end end
context "with a group" do context "with a group" do
let!(:obj) { group } let(:obj) { group }
before do before do
group.add_developer(current_user) group.add_developer(current_user)
...@@ -565,26 +577,42 @@ RSpec.describe Resolvers::IssuesResolver do ...@@ -565,26 +577,42 @@ RSpec.describe Resolvers::IssuesResolver do
expect(resolve_issues({ not: { types: ['issue'] } })).to contain_exactly(issue1) expect(resolve_issues({ not: { types: ['issue'] } })).to contain_exactly(issue1)
end end
context 'filtering for confidential issues' do context "confidential issues" do
include_context 'filtering for confidential issues' include_context 'filtering for confidential issues'
context 'when filter is explicitly set to false' do context "when user is allowed to view confidential issues" do
it 'returns all viewable issues' do it 'returns all viewable issues by default' do
expect(resolve_issues).to contain_exactly(issue1, issue2, issue3, confidential_issue1, confidential_issue2) expect(resolve_issues).to contain_exactly(issue1, issue2, issue3, confidential_issue1, confidential_issue2)
end end
end
context "when user is allowed to view confidential issues" do context 'filtering for confidential issues' do
it "returns only the confidential issues for the group" do it 'returns only the non-confidential issues for the group when filter is set to false' do
expect(resolve_issues({ confidential: true })).to contain_exactly(confidential_issue1, confidential_issue2) expect(resolve_issues({ confidential: false })).to contain_exactly(issue1, issue2, issue3)
end
it "returns only the confidential issues for the group when filter is set to true" do
expect(resolve_issues({ confidential: true })).to contain_exactly(confidential_issue1, confidential_issue2)
end
end end
end end
context "when user is not allowed to see confidential issues" do context "when user is not allowed to see confidential issues" do
it 'does not return the confidential issues' do before do
group.add_guest(current_user) group.add_guest(current_user)
end
expect(resolve_issues({ confidential: true })).to be_empty it 'returns all viewable issues by default' do
expect(resolve_issues).to contain_exactly(issue1, issue2, issue3)
end
context 'filtering for confidential issues' do
it 'does not return the confidential issues when filter is set to false' do
expect(resolve_issues({ confidential: false })).to contain_exactly(issue1, issue2, issue3)
end
it 'does not return the confidential issues when filter is set to true' do
expect(resolve_issues({ confidential: true })).to be_empty
end
end end
end end
end end
...@@ -598,7 +626,7 @@ RSpec.describe Resolvers::IssuesResolver do ...@@ -598,7 +626,7 @@ RSpec.describe Resolvers::IssuesResolver do
end end
end end
let!(:obj) { project } let(:obj) { project }
it "returns nil without breaking" do it "returns nil without breaking" do
expect(resolve_issues(iids: ["don't", "break"])).to be_empty expect(resolve_issues(iids: ["don't", "break"])).to be_empty
......
...@@ -72,6 +72,16 @@ RSpec.describe 'getting an issue list for a group' do ...@@ -72,6 +72,16 @@ RSpec.describe 'getting an issue list for a group' do
expect(issues_ids).to be_empty expect(issues_ids).to be_empty
end end
end end
context 'filtering for non-confidential issues' do
let(:issue_filter_params) { { confidential: false } }
it 'returns correctly filtered issues' do
post_graphql(query, current_user: current_user)
expect(issues_ids).to contain_exactly(issue1_gid, issue2_gid)
end
end
end end
context 'when the user can see confidential issues' do context 'when the user can see confidential issues' do
...@@ -94,6 +104,16 @@ RSpec.describe 'getting an issue list for a group' do ...@@ -94,6 +104,16 @@ RSpec.describe 'getting an issue list for a group' do
expect(issues_ids).to contain_exactly(confidential_issue1_gid, confidential_issue2_gid) expect(issues_ids).to contain_exactly(confidential_issue1_gid, confidential_issue2_gid)
end end
end end
context 'filtering for non-confidential issues' do
let(:issue_filter_params) { { confidential: false } }
it 'returns correctly filtered issues' do
post_graphql(query, current_user: current_user)
expect(issues_ids).to contain_exactly(issue1_gid, issue2_gid)
end
end
end end
end end
......
...@@ -170,6 +170,16 @@ RSpec.describe 'getting an issue list for a project' do ...@@ -170,6 +170,16 @@ RSpec.describe 'getting an issue list for a project' do
expect(issues_data.size).to eq(0) expect(issues_data.size).to eq(0)
end end
end end
context 'filtering for non-confidential issues' do
let(:issue_filter_params) { { confidential: false } }
it 'returns correctly filtered issues' do
post_graphql(query, current_user: current_user)
expect(issues_ids).to contain_exactly(issue_a_gid, issue_b_gid)
end
end
end end
context 'when the user can see confidential issues' do context 'when the user can see confidential issues' do
...@@ -198,6 +208,16 @@ RSpec.describe 'getting an issue list for a project' do ...@@ -198,6 +208,16 @@ RSpec.describe 'getting an issue list for a project' do
expect(issues_ids).to contain_exactly(confidential_issue_gid) expect(issues_ids).to contain_exactly(confidential_issue_gid)
end end
end end
context 'filtering for non-confidential issues' do
let(:issue_filter_params) { { confidential: false } }
it 'returns correctly filtered issues' do
post_graphql(query, current_user: current_user)
expect(issues_ids).to contain_exactly(issue_a_gid, issue_b_gid)
end
end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment