diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-08 00:11:52 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-08 00:11:52 +0000 |
commit | 61f4111a853b8bb50f10fbd7854a8796be7eca24 (patch) | |
tree | d8a8a644de7d67bbaf1cfb899ec39973ac8a0ce3 | |
parent | 4fcfdad283a25ee4d1e955954aeceb08d7ffd5f7 (diff) | |
download | gitlab-ce-61f4111a853b8bb50f10fbd7854a8796be7eca24.tar.gz |
Add latest changes from gitlab-org/gitlab@master
-rw-r--r-- | data/deprecations/templates/example.yml | 4 | ||||
-rw-r--r-- | doc/development/documentation/index.md | 27 | ||||
-rw-r--r-- | qa/lib/gitlab.rb | 6 | ||||
-rw-r--r-- | qa/lib/gitlab/page/admin/dashboard.rb | 15 | ||||
-rw-r--r-- | qa/lib/gitlab/page/admin/dashboard.stub.rb | 81 | ||||
-rw-r--r-- | qa/lib/gitlab/page/admin/subscription.rb | 13 | ||||
-rw-r--r-- | qa/lib/gitlab/page/admin/subscription.stub.rb | 33 | ||||
-rw-r--r-- | qa/lib/gitlab/page/main/sign_up.rb | 36 | ||||
-rw-r--r-- | qa/lib/gitlab/page/main/sign_up.stub.rb | 203 | ||||
-rw-r--r-- | qa/qa/resource/user.rb | 11 |
10 files changed, 425 insertions, 4 deletions
diff --git a/data/deprecations/templates/example.yml b/data/deprecations/templates/example.yml index f665dd21530..a11a6800a74 100644 --- a/data/deprecations/templates/example.yml +++ b/data/deprecations/templates/example.yml @@ -12,7 +12,7 @@ - name: "Feature name" # The name of the feature to be deprecated announcement_milestone: "XX.YY" # The milestone when this feature was first announced as deprecated. - announcement_date: "YYYY-MM-DD" # The date of the milestone release when this feature was first announced as deprecated + announcement_date: "YYYY-MM-DD" # The date of the milestone release when this feature was first announced as deprecated. This should almost always be the 22nd of a month (YYYY-MM-22), unless you did an out of band blog post. removal_milestone: "XX.YY" # The milestone when this feature is planned to be removed body: | # Do not modify this line, instead modify the lines below. <!-- START OF BODY COMMENT @@ -30,4 +30,4 @@ documentation_url: # (optional) This is a link to the current documentation page image_url: # (optional) This is a link to a thumbnail image depicting the feature video_url: # (optional) Use the youtube thumbnail URL with the structure of https://img.youtube.com/vi/UNIQUEID/hqdefault.jpg - removal_date: # (optional - may be required in the future) YYYY-MM-DD format - the date of the milestone release when this feature is planned to be removed + removal_date: # (optional - may be required in the future) YYYY-MM-DD format. This should almost always be the 22nd of a month (YYYY-MM-22), the date of the milestone release when this feature is planned to be removed diff --git a/doc/development/documentation/index.md b/doc/development/documentation/index.md index 73670a3f676..75538fe1fe7 100644 --- a/doc/development/documentation/index.md +++ b/doc/development/documentation/index.md @@ -202,8 +202,10 @@ with the following conventions: The help text follows the [Pajamas guidelines](https://design.gitlab.com/usability/helping-users/#formatting-help-content). -Use the following special cases depending on the context, ensuring all links -are inside `_()` so they can be translated: +#### Linking to `/help` in HAML + +Use the following special cases depending on the context, ensuring all link text +is inside `_()` so it can be translated: - Linking to a doc page. In its most basic form, the HAML code to generate a link to the `/help` page is: @@ -248,6 +250,27 @@ helpPagePath('user/permissions', { anchor: 'anchor-link' }) This is preferred over static paths, as the helper also works on instances installed under a [relative URL](../../install/relative_url.md). +#### Linking to `/help` in Ruby + +To link to the documentation from within Ruby code, use the following code block as a guide, ensuring all link text is inside `_()` so it can +be translated: + +```ruby +docs_link = link_to _('Learn more.'), help_page_url('user/permissions', anchor: 'anchor-link'), target: '_blank', rel: 'noopener noreferrer' +_('This is a text describing the option/feature in a sentence. %{docs_link}').html_safe % { docs_link: docs_link.html_safe } +``` + +In cases where you need to generate a link from outside of views/helpers, where the `link_to` and `help_page_url` methods are not available, use the following code block +as a guide where the methods are fully qualified: + +```ruby +docs_link = ActionController::Base.helpers.link_to _('Learn more.'), Rails.application.routes.url_helpers.help_page_url('user/permissions', anchor: 'anchor-link'), target: '_blank', rel: 'noopener noreferrer' +_('This is a text describing the option/feature in a sentence. %{docs_link}').html_safe % { docs_link: docs_link.html_safe } +``` + +Do not use `include ActionView::Helpers::UrlHelper` just to make the `link_to` method available as you might see in some existing code. Read more in +[issue 340567](https://gitlab.com/gitlab-org/gitlab/-/issues/340567). + ### GitLab `/help` tests Several [RSpec tests](https://gitlab.com/gitlab-org/gitlab/-/blob/master/spec/features/help_pages_spec.rb) diff --git a/qa/lib/gitlab.rb b/qa/lib/gitlab.rb index eecc6dce392..4418e51facb 100644 --- a/qa/lib/gitlab.rb +++ b/qa/lib/gitlab.rb @@ -9,12 +9,18 @@ module Gitlab module Page module Main autoload :Login, 'gitlab/page/main/login' + autoload :SignUp, 'gitlab/page/main/sign_up' end module Subscriptions autoload :New, 'gitlab/page/subscriptions/new' end + module Admin + autoload :Dashboard, 'gitlab/page/admin/dashboard' + autoload :Subscription, 'gitlab/page/admin/subscription' + end + module Group module Settings autoload :Billing, 'gitlab/page/group/settings/billing' diff --git a/qa/lib/gitlab/page/admin/dashboard.rb b/qa/lib/gitlab/page/admin/dashboard.rb new file mode 100644 index 00000000000..f1a732f8fac --- /dev/null +++ b/qa/lib/gitlab/page/admin/dashboard.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Gitlab + module Page + module Admin + class Dashboard < Chemlab::Page + path '/admin' + + h2 :users_in_license + h2 :billable_users + h3 :number_of_users + end + end + end +end diff --git a/qa/lib/gitlab/page/admin/dashboard.stub.rb b/qa/lib/gitlab/page/admin/dashboard.stub.rb new file mode 100644 index 00000000000..820acf79b9b --- /dev/null +++ b/qa/lib/gitlab/page/admin/dashboard.stub.rb @@ -0,0 +1,81 @@ +# frozen_string_literal: true + +module Gitlab + module Page + module Admin + module Dashboard + # @note Defined as +h2 :users_in_license+ + # @return [String] The text content or value of +users_in_license+ + def users_in_license + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @example + # Gitlab::Page::Admin::Dashboard.perform do |dashboard| + # expect(dashboard.users_in_license_element).to exist + # end + # @return [Watir::H2] The raw +H2+ element + def users_in_license_element + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @example + # Gitlab::Page::Admin::Dashboard.perform do |dashboard| + # expect(dashboard).to be_users_in_license + # end + # @return [Boolean] true if the +users_in_license+ element is present on the page + def users_in_license? + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @note Defined as +h2 :billable_users+ + # @return [String] The text content or value of +billable_users+ + def billable_users + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @example + # Gitlab::Page::Admin::Dashboard.perform do |dashboard| + # expect(dashboard.billable_users_element).to exist + # end + # @return [Watir::H2] The raw +H2+ element + def billable_users_element + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @example + # Gitlab::Page::Admin::Dashboard.perform do |dashboard| + # expect(dashboard).to be_billable_users + # end + # @return [Boolean] true if the +billable_users+ element is present on the page + def billable_users? + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @note Defined as +h3 :number_of_users+ + # @return [String] The text content or value of +number_of_users+ + def number_of_users + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @example + # Gitlab::Page::Admin::Dashboard.perform do |dashboard| + # expect(dashboard.number_of_users_element).to exist + # end + # @return [Watir::H3] The raw +H3+ element + def number_of_users_element + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @example + # Gitlab::Page::Admin::Dashboard.perform do |dashboard| + # expect(dashboard).to be_number_of_users + # end + # @return [Boolean] true if the +number_of_users+ element is present on the page + def number_of_users? + # This is a stub, used for indexing. The method is dynamically generated. + end + end + end + end +end diff --git a/qa/lib/gitlab/page/admin/subscription.rb b/qa/lib/gitlab/page/admin/subscription.rb new file mode 100644 index 00000000000..0f7c6b4c211 --- /dev/null +++ b/qa/lib/gitlab/page/admin/subscription.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Gitlab + module Page + module Admin + class Subscription < Chemlab::Page + path '/admin/subscription' + + h2 :users_in_subscription + end + end + end +end diff --git a/qa/lib/gitlab/page/admin/subscription.stub.rb b/qa/lib/gitlab/page/admin/subscription.stub.rb new file mode 100644 index 00000000000..51f23e7f0d0 --- /dev/null +++ b/qa/lib/gitlab/page/admin/subscription.stub.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Gitlab + module Page + module Admin + module Subscription + # @note Defined as +h2 :users_in_subscription+ + # @return [String] The text content or value of +users_in_subscription+ + def users_in_subscription + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @example + # Gitlab::Page::Admin::Subscription.perform do |subscription| + # expect(subscription.users_in_subscription_element).to exist + # end + # @return [Watir::H2] The raw +H2+ element + def users_in_subscription_element + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @example + # Gitlab::Page::Admin::Subscription.perform do |subscription| + # expect(subscription).to be_users_in_subscription + # end + # @return [Boolean] true if the +users_in_subscription+ element is present on the page + def users_in_subscription? + # This is a stub, used for indexing. The method is dynamically generated. + end + end + end + end +end diff --git a/qa/lib/gitlab/page/main/sign_up.rb b/qa/lib/gitlab/page/main/sign_up.rb new file mode 100644 index 00000000000..85d7f482461 --- /dev/null +++ b/qa/lib/gitlab/page/main/sign_up.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +module Gitlab + module Page + module Main + class SignUp < Chemlab::Page + path '/users/sign_up' + + # TODO: Refactor data-qa-selectors to be more terse + text_field :first_name, 'data-qa-selector': 'new_user_first_name_field' + text_field :last_name, 'data-qa-selector': 'new_user_last_name_field' + + text_field :username, 'data-qa-selector': 'new_user_username_field' + + text_field :email, 'data-qa-selector': 'new_user_email_field' + text_field :password, 'data-qa-selector': 'new_user_password_field' + + button :register, 'data-qa-selector': 'new_user_register_button' + + # Register a user + # @param [Resource::User] user the user to register + def register_user(user) + raise ArgumentError, 'User must be of type Resource::User' unless user.is_a? ::QA::Resource::User + + self.first_name = user.first_name + self.last_name = user.last_name + self.username = user.username + self.email = user.email + self.password = user.password + + self.register + end + end + end + end +end diff --git a/qa/lib/gitlab/page/main/sign_up.stub.rb b/qa/lib/gitlab/page/main/sign_up.stub.rb new file mode 100644 index 00000000000..881bd922c45 --- /dev/null +++ b/qa/lib/gitlab/page/main/sign_up.stub.rb @@ -0,0 +1,203 @@ +# frozen_string_literal: true + +module Gitlab + module Page + module Main + module SignUp + # @note Defined as +text_field :first_name+ + # @return [String] The text content or value of +first_name+ + def first_name + # This is a stub, used for indexing. The method is dynamically generated. + end + + # Set the value of first_name + # @example + # Gitlab::Page::Main::SignUp.perform do |sign_up| + # sign_up.first_name = 'value' + # end + # @param value [String] The value to set. + def first_name=(value) + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @example + # Gitlab::Page::Main::SignUp.perform do |sign_up| + # expect(sign_up.first_name_element).to exist + # end + # @return [Watir::TextField] The raw +TextField+ element + def first_name_element + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @example + # Gitlab::Page::Main::SignUp.perform do |sign_up| + # expect(sign_up).to be_first_name + # end + # @return [Boolean] true if the +first_name+ element is present on the page + def first_name? + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @note Defined as +text_field :last_name+ + # @return [String] The text content or value of +last_name+ + def last_name + # This is a stub, used for indexing. The method is dynamically generated. + end + + # Set the value of last_name + # @example + # Gitlab::Page::Main::SignUp.perform do |sign_up| + # sign_up.last_name = 'value' + # end + # @param value [String] The value to set. + def last_name=(value) + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @example + # Gitlab::Page::Main::SignUp.perform do |sign_up| + # expect(sign_up.last_name_element).to exist + # end + # @return [Watir::TextField] The raw +TextField+ element + def last_name_element + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @example + # Gitlab::Page::Main::SignUp.perform do |sign_up| + # expect(sign_up).to be_last_name + # end + # @return [Boolean] true if the +last_name+ element is present on the page + def last_name? + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @note Defined as +text_field :username+ + # @return [String] The text content or value of +username+ + def username + # This is a stub, used for indexing. The method is dynamically generated. + end + + # Set the value of username + # @example + # Gitlab::Page::Main::SignUp.perform do |sign_up| + # sign_up.username = 'value' + # end + # @param value [String] The value to set. + def username=(value) + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @example + # Gitlab::Page::Main::SignUp.perform do |sign_up| + # expect(sign_up.username_element).to exist + # end + # @return [Watir::TextField] The raw +TextField+ element + def username_element + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @example + # Gitlab::Page::Main::SignUp.perform do |sign_up| + # expect(sign_up).to be_username + # end + # @return [Boolean] true if the +username+ element is present on the page + def username? + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @note Defined as +text_field :email+ + # @return [String] The text content or value of +email+ + def email + # This is a stub, used for indexing. The method is dynamically generated. + end + + # Set the value of email + # @example + # Gitlab::Page::Main::SignUp.perform do |sign_up| + # sign_up.email = 'value' + # end + # @param value [String] The value to set. + def email=(value) + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @example + # Gitlab::Page::Main::SignUp.perform do |sign_up| + # expect(sign_up.email_element).to exist + # end + # @return [Watir::TextField] The raw +TextField+ element + def email_element + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @example + # Gitlab::Page::Main::SignUp.perform do |sign_up| + # expect(sign_up).to be_email + # end + # @return [Boolean] true if the +email+ element is present on the page + def email? + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @note Defined as +text_field :password+ + # @return [String] The text content or value of +password+ + def password + # This is a stub, used for indexing. The method is dynamically generated. + end + + # Set the value of password + # @example + # Gitlab::Page::Main::SignUp.perform do |sign_up| + # sign_up.password = 'value' + # end + # @param value [String] The value to set. + def password=(value) + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @example + # Gitlab::Page::Main::SignUp.perform do |sign_up| + # expect(sign_up.password_element).to exist + # end + # @return [Watir::TextField] The raw +TextField+ element + def password_element + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @example + # Gitlab::Page::Main::SignUp.perform do |sign_up| + # expect(sign_up).to be_password + # end + # @return [Boolean] true if the +password+ element is present on the page + def password? + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @note Defined as +button :register+ + # Clicks +register+ + def register + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @example + # Gitlab::Page::Main::SignUp.perform do |sign_up| + # expect(sign_up.register_element).to exist + # end + # @return [Watir::Button] The raw +Button+ element + def register_element + # This is a stub, used for indexing. The method is dynamically generated. + end + + # @example + # Gitlab::Page::Main::SignUp.perform do |sign_up| + # expect(sign_up).to be_register + # end + # @return [Boolean] true if the +register+ element is present on the page + def register? + # This is a stub, used for indexing. The method is dynamically generated. + end + end + end + end +end diff --git a/qa/qa/resource/user.rb b/qa/qa/resource/user.rb index 811ce5e0505..d64c7db4215 100644 --- a/qa/qa/resource/user.rb +++ b/qa/qa/resource/user.rb @@ -123,6 +123,10 @@ module QA "/users/#{id}/block" end + def api_approve_path + "/users/#{id}/approve" + end + def api_post_body { admin: admin, @@ -148,6 +152,13 @@ module QA end end + def approve! + response = post(Runtime::API::Request.new(api_client, api_approve_path).url, nil) + return if response.code == 201 + + raise ResourceUpdateFailedError, "Failed to approve user. Request returned (#{response.code}): `#{response}`" + end + def block! response = post(Runtime::API::Request.new(api_client, api_block_path).url, nil) return if response.code == HTTP_STATUS_CREATED |