diff options
author | Mesut Güneş <gunesmes@gmail.com> | 2019-02-01 14:38:07 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2019-02-01 14:38:07 +0000 |
commit | ec3c3d2bd732e1eac9a75629e4a474bc55abb574 (patch) | |
tree | 9093e43f174225fb0f5356a03fa9d14183d62edb /qa/qa | |
parent | 8028a59d7a89ca803902b5b5a206bcf1e83e8c51 (diff) | |
download | gitlab-ce-ec3c3d2bd732e1eac9a75629e4a474bc55abb574.tar.gz |
adding a spec for issues/310
Diffstat (limited to 'qa/qa')
-rw-r--r-- | qa/qa/page/admin/menu.rb | 9 | ||||
-rw-r--r-- | qa/qa/page/admin/settings/component/account_and_limit.rb | 26 | ||||
-rw-r--r-- | qa/qa/page/admin/settings/general.rb | 23 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_file_size_spec.rb | 70 |
4 files changed, 128 insertions, 0 deletions
diff --git a/qa/qa/page/admin/menu.rb b/qa/qa/page/admin/menu.rb index e8c7d274966..25564f2dc6e 100644 --- a/qa/qa/page/admin/menu.rb +++ b/qa/qa/page/admin/menu.rb @@ -9,6 +9,7 @@ module QA element :admin_sidebar_submenu element :admin_settings_item element :admin_settings_repository_item + element :admin_settings_general_item end def go_to_repository_settings @@ -19,6 +20,14 @@ module QA end end + def go_to_general_settings + hover_settings do + within_submenu do + click_element :admin_settings_general_item + end + end + end + private def hover_settings diff --git a/qa/qa/page/admin/settings/component/account_and_limit.rb b/qa/qa/page/admin/settings/component/account_and_limit.rb new file mode 100644 index 00000000000..a61c8cc77cd --- /dev/null +++ b/qa/qa/page/admin/settings/component/account_and_limit.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +module QA + module Page + module Admin + module Settings + module Component + class AccountAndLimit < Page::Base + view 'app/views/admin/application_settings/_account_and_limit.html.haml' do + element :receive_max_input_size_field + element :save_changes_button + end + + def set_max_file_size(size) + fill_element :receive_max_input_size_field, size + end + + def save_settings + click_element :save_changes_button + end + end + end + end + end + end +end diff --git a/qa/qa/page/admin/settings/general.rb b/qa/qa/page/admin/settings/general.rb new file mode 100644 index 00000000000..93b290f7e03 --- /dev/null +++ b/qa/qa/page/admin/settings/general.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module QA + module Page + module Admin + module Settings + class General < Page::Base + include QA::Page::Settings::Common + + view 'app/views/admin/application_settings/show.html.haml' do + element :account_and_limit_settings + end + + def expand_account_and_limit(&block) + expand_section(:account_and_limit_settings) do + Component::AccountAndLimit.perform(&block) + end + end + end + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_file_size_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_file_size_spec.rb new file mode 100644 index 00000000000..23ea55c2e61 --- /dev/null +++ b/qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_file_size_spec.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true + +module QA + context 'Create' do + describe 'push after setting the file size limit via admin/application_settings' do + before(:all) do + push = Resource::Repository::ProjectPush.fabricate! do |p| + p.file_name = 'README.md' + p.file_content = '# This is a test project' + p.commit_message = 'Add README.md' + end + + @project = push.project + end + + before do + Runtime::Browser.visit(:gitlab, Page::Main::Login) + Page::Main::Login.perform(&:sign_in_using_credentials) + end + + after(:all) do + # need to set the default value after test + # default value for file size limit is empty + Runtime::Browser.visit(:gitlab, Page::Main::Login) + Page::Main::Login.perform(&:sign_in_using_credentials) + + set_file_size_limit('') + end + + it 'push successful when the file size is under the limit' do + set_file_size_limit(5) + expect(page).to have_content("Application settings saved successfully") + + push = push_new_file('oversize_file_1.bin') + expect(push.output).not_to have_content 'remote: fatal: pack exceeds maximum allowed size' + end + + it 'push fails when the file size is above the limit' do + set_file_size_limit(1) + expect(page).to have_content("Application settings saved successfully") + + push = push_new_file('oversize_file_2.bin') + expect(push.output).to have_content 'remote: fatal: pack exceeds maximum allowed size' + end + + def set_file_size_limit(limit) + Page::Main::Menu.perform(&:go_to_admin_area) + Page::Admin::Menu.perform(&:go_to_general_settings) + + Page::Admin::Settings::General.perform do |setting| + setting.expand_account_and_limit do |page| + page.set_max_file_size(limit) + page.save_settings + end + end + end + + def push_new_file(file_name) + @project.visit! + + Resource::Repository::ProjectPush.fabricate! do |p| + p.project = @project + p.file_name = file_name + p.file_content = SecureRandom.random_bytes(2000000) + p.commit_message = 'Adding a new file' + end + end + end + end +end |