diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-01 12:09:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-01 12:09:54 +0300 |
commit | 635d82b15d83a88a2d073fbf3bb56f6ff626020f (patch) | |
tree | 777ccf8764f948a44aba3bf792bde8717e950824 /spec | |
parent | a7e81add72ecfbbf888ec4f73debdc2647b059de (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
3 files changed, 42 insertions, 9 deletions
diff --git a/spec/frontend/lib/utils/datetime_utility_spec.js b/spec/frontend/lib/utils/datetime_utility_spec.js index 5b1fdea058b..a7973d66b50 100644 --- a/spec/frontend/lib/utils/datetime_utility_spec.js +++ b/spec/frontend/lib/utils/datetime_utility_spec.js @@ -667,3 +667,26 @@ describe('differenceInMilliseconds', () => { expect(datetimeUtility.differenceInMilliseconds(startDate, endDate)).toBe(expected); }); }); + +describe('dateAtFirstDayOfMonth', () => { + const date = new Date('2019-07-16T12:00:00.000Z'); + + it('returns the date at the first day of the month', () => { + const startDate = datetimeUtility.dateAtFirstDayOfMonth(date); + const expectedStartDate = new Date('2019-07-01T12:00:00.000Z'); + + expect(startDate).toStrictEqual(expectedStartDate); + }); +}); + +describe('datesMatch', () => { + const date = new Date('2019-07-17T00:00:00.000Z'); + + it.each` + date1 | date2 | expected + ${date} | ${new Date('2019-07-17T00:00:00.000Z')} | ${true} + ${date} | ${new Date('2019-07-17T12:00:00.000Z')} | ${false} + `('returns $expected for $date1 matches $date2', ({ date1, date2, expected }) => { + expect(datetimeUtility.datesMatch(date1, date2)).toBe(expected); + }); +}); diff --git a/spec/graphql/types/global_id_type_spec.rb b/spec/graphql/types/global_id_type_spec.rb index 2a7b26f66b0..7589b0e285e 100644 --- a/spec/graphql/types/global_id_type_spec.rb +++ b/spec/graphql/types/global_id_type_spec.rb @@ -99,8 +99,6 @@ RSpec.describe Types::GlobalIDType do end describe 'compatibility' do - # Simplified schema to test compatibility - def query(doc, vars) GraphQL::Query.new(schema, document: doc, context: {}, variables: vars) end @@ -112,6 +110,7 @@ RSpec.describe Types::GlobalIDType do all_types = [::GraphQL::ID_TYPE, ::Types::GlobalIDType, ::Types::GlobalIDType[::Project]] shared_examples 'a working query' do + # Simplified schema to test compatibility let!(:schema) do # capture values so they can be closed over arg_type = argument_type @@ -135,10 +134,21 @@ RSpec.describe Types::GlobalIDType do argument :id, arg_type, required: true end + # This is needed so that all types are always registered as input types + field :echo, String, null: true do + argument :id, ::GraphQL::ID_TYPE, required: false + argument :gid, ::Types::GlobalIDType, required: false + argument :pid, ::Types::GlobalIDType[::Project], required: false + end + def project_by_id(id:) gid = ::Types::GlobalIDType[::Project].coerce_isolated_input(id) gid.model_class.find(gid.model_id) end + + def echo(id: nil, gid: nil, pid: nil) + "id: #{id}, gid: #{gid}, pid: #{pid}" + end end) end end @@ -152,7 +162,7 @@ RSpec.describe Types::GlobalIDType do end end - context 'when the argument is declared as ID' do + context 'when the client declares the argument as ID the actual argument can be any type' do let(:document) do <<-GRAPHQL query($projectId: ID!){ @@ -163,16 +173,16 @@ RSpec.describe Types::GlobalIDType do GRAPHQL end - let(:argument_type) { ::GraphQL::ID_TYPE } - - where(:result_type) { all_types } + where(:result_type, :argument_type) do + all_types.flat_map { |arg_type| all_types.zip([arg_type].cycle) } + end with_them do it_behaves_like 'a working query' end end - context 'when the argument is declared as GlobalID' do + context 'when the client passes the argument as GlobalID' do let(:document) do <<-GRAPHQL query($projectId: GlobalID!) { @@ -192,7 +202,7 @@ RSpec.describe Types::GlobalIDType do end end - context 'when the argument is declared as ProjectID' do + context 'when the client passes the argument as ProjectID' do let(:document) do <<-GRAPHQL query($projectId: ProjectID!) { diff --git a/spec/support/shared_contexts/cache_allowed_users_in_namespace_shared_context.rb b/spec/support/shared_contexts/cache_allowed_users_in_namespace_shared_context.rb index e3c1d0afa53..bfb719fd840 100644 --- a/spec/support/shared_contexts/cache_allowed_users_in_namespace_shared_context.rb +++ b/spec/support/shared_contexts/cache_allowed_users_in_namespace_shared_context.rb @@ -25,7 +25,7 @@ RSpec.shared_examples 'allowed user IDs are cached' do expect(described_class.l1_cache_backend).to receive(:fetch).and_call_original expect(described_class.l2_cache_backend).to receive(:fetch).and_call_original expect(subject).to be_truthy - end.not_to exceed_query_limit(2) + end.not_to exceed_query_limit(3) end end end |