summaryrefslogtreecommitdiff
path: root/spec/views
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 11:18:50 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 11:18:50 +0000
commit8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch)
treea77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/views
parent00b35af3db1abfe813a778f643dad221aad51fca (diff)
downloadgitlab-ce-8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781.tar.gz
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/views')
-rw-r--r--spec/views/admin/application_settings/_repository_storage.html.haml_spec.rb20
-rw-r--r--spec/views/layouts/_head.html.haml_spec.rb13
-rw-r--r--spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb6
-rw-r--r--spec/views/profiles/preferences/show.html.haml_spec.rb3
-rw-r--r--spec/views/projects/edit.html.haml_spec.rb16
-rw-r--r--spec/views/projects/issues/import_csv/_button.html.haml_spec.rb43
-rw-r--r--spec/views/projects/merge_requests/show.html.haml_spec.rb4
-rw-r--r--spec/views/projects/services/_form.haml_spec.rb4
-rw-r--r--spec/views/shared/milestones/_top.html.haml_spec.rb16
9 files changed, 87 insertions, 38 deletions
diff --git a/spec/views/admin/application_settings/_repository_storage.html.haml_spec.rb b/spec/views/admin/application_settings/_repository_storage.html.haml_spec.rb
index 3029bfb6df5..63236dbb0c4 100644
--- a/spec/views/admin/application_settings/_repository_storage.html.haml_spec.rb
+++ b/spec/views/admin/application_settings/_repository_storage.html.haml_spec.rb
@@ -3,26 +3,34 @@
require 'spec_helper'
describe 'admin/application_settings/_repository_storage.html.haml' do
- let(:app_settings) { build(:application_setting) }
- let(:storages) do
+ let(:app_settings) { create(:application_setting) }
+ let(:repository_storages_weighted_attributes) { [:repository_storages_weighted_default, :repository_storages_weighted_mepmep, :repository_storages_weighted_foobar]}
+ let(:repository_storages_weighted) do
{
- "mepmep" => { "path" => "/tmp" },
- "foobar" => { "path" => "/tmp" }
+ "default" => 100,
+ "mepmep" => 50
}
end
before do
+ allow(app_settings).to receive(:repository_storages_weighted).and_return(repository_storages_weighted)
+ allow(app_settings).to receive(:repository_storages_weighted_mepmep).and_return(100)
+ allow(app_settings).to receive(:repository_storages_weighted_foobar).and_return(50)
assign(:application_setting, app_settings)
- stub_storage_settings(storages)
+ allow(ApplicationSetting).to receive(:repository_storages_weighted_attributes).and_return(repository_storages_weighted_attributes)
end
context 'when multiple storages are available' do
it 'lists them all' do
render
- storages.keys.each do |storage_name|
+ # lists storages that are saved with weights
+ repository_storages_weighted.each do |storage_name, storage_weight|
expect(rendered).to have_content(storage_name)
end
+
+ # lists storage not saved with weight
+ expect(rendered).to have_content('foobar')
end
end
end
diff --git a/spec/views/layouts/_head.html.haml_spec.rb b/spec/views/layouts/_head.html.haml_spec.rb
index 8d7dcfc2416..7011fa23327 100644
--- a/spec/views/layouts/_head.html.haml_spec.rb
+++ b/spec/views/layouts/_head.html.haml_spec.rb
@@ -50,7 +50,7 @@ describe 'layouts/_head' do
it 'adds a link preconnect tag' do
render
- expect(rendered).to match(%Q(<link crossorigin="" href="#{asset_host}" rel="preconnnect">))
+ expect(rendered).to match(%Q(<link crossorigin="" href="#{asset_host}" rel="preconnect">))
end
end
@@ -64,18 +64,25 @@ describe 'layouts/_head' do
context 'when an asset_host is set and snowplow url is set' do
let(:asset_host) { 'http://test.host' }
+ let(:snowplow_collector_hostname) { 'www.snow.plow' }
before do
allow(ActionController::Base).to receive(:asset_host).and_return(asset_host)
allow(Gitlab::CurrentSettings).to receive(:snowplow_enabled?).and_return(true)
- allow(Gitlab::CurrentSettings).to receive(:snowplow_collector_hostname).and_return('www.snow.plow')
+ allow(Gitlab::CurrentSettings).to receive(:snowplow_collector_hostname).and_return(snowplow_collector_hostname)
end
it 'adds a snowplow script tag with asset host' do
render
expect(rendered).to match('http://test.host/assets/snowplow/')
expect(rendered).to match('window.snowplow')
- expect(rendered).to match('www.snow.plow')
+ expect(rendered).to match(snowplow_collector_hostname)
+ end
+
+ it 'adds a link preconnect tag' do
+ render
+
+ expect(rendered).to match(%Q(<link crossorigin="" href="#{snowplow_collector_hostname}" rel="preconnect">))
end
end
diff --git a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
index 3d5c34ae1e0..881ea818cb0 100644
--- a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
+++ b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
@@ -66,7 +66,7 @@ describe 'layouts/nav/sidebar/_project' do
it 'shows the wiki tab with the wiki internal link' do
render
- expect(rendered).to have_link('Wiki', href: project_wiki_path(project, :home))
+ expect(rendered).to have_link('Wiki', href: wiki_path(project.wiki))
end
end
@@ -76,7 +76,7 @@ describe 'layouts/nav/sidebar/_project' do
it 'does not show the wiki tab' do
render
- expect(rendered).not_to have_link('Wiki', href: project_wiki_path(project, :home))
+ expect(rendered).not_to have_link('Wiki', href: wiki_path(project.wiki))
end
end
end
@@ -104,7 +104,7 @@ describe 'layouts/nav/sidebar/_project' do
it 'does not show the external wiki tab' do
render
- expect(rendered).not_to have_link('External Wiki', href: project_wiki_path(project, :home))
+ expect(rendered).not_to have_link('External Wiki')
end
end
end
diff --git a/spec/views/profiles/preferences/show.html.haml_spec.rb b/spec/views/profiles/preferences/show.html.haml_spec.rb
index 16e4bd9c6d1..2e50e329cfd 100644
--- a/spec/views/profiles/preferences/show.html.haml_spec.rb
+++ b/spec/views/profiles/preferences/show.html.haml_spec.rb
@@ -32,8 +32,7 @@ describe 'profiles/preferences/show' do
end
before do
- # Can't use stub_feature_flags because we use Feature.get to check if conditinally applied
- Feature.get(:sourcegraph).enable sourcegraph_feature
+ stub_feature_flags(sourcegraph: sourcegraph_feature)
stub_application_setting(sourcegraph_enabled: sourcegraph_enabled)
end
diff --git a/spec/views/projects/edit.html.haml_spec.rb b/spec/views/projects/edit.html.haml_spec.rb
index e95dec56a2d..0c0f74a41f0 100644
--- a/spec/views/projects/edit.html.haml_spec.rb
+++ b/spec/views/projects/edit.html.haml_spec.rb
@@ -32,26 +32,28 @@ describe 'projects/edit' do
it 'displays all possible variables' do
render
- expect(rendered).to have_content('%{project_path}')
- expect(rendered).to have_content('%{project_name}')
- expect(rendered).to have_content('%{file_path}')
expect(rendered).to have_content('%{branch_name}')
- expect(rendered).to have_content('%{username}')
+ expect(rendered).to have_content('%{files_count}')
+ expect(rendered).to have_content('%{file_paths}')
+ expect(rendered).to have_content('%{project_name}')
+ expect(rendered).to have_content('%{project_path}')
expect(rendered).to have_content('%{user_full_name}')
+ expect(rendered).to have_content('%{username}')
+ expect(rendered).to have_content('%{suggestions_count}')
end
it 'displays a placeholder if none is set' do
render
- expect(rendered).to have_field('project[suggestion_commit_message]', placeholder: 'Apply suggestion to %{file_path}')
+ expect(rendered).to have_field('project[suggestion_commit_message]', placeholder: "Apply %{suggestions_count} suggestion(s) to %{files_count} file(s)")
end
it 'displays the user entered value' do
- project.update!(suggestion_commit_message: 'refactor: changed %{file_path}')
+ project.update!(suggestion_commit_message: 'refactor: changed %{file_paths}')
render
- expect(rendered).to have_field('project[suggestion_commit_message]', with: 'refactor: changed %{file_path}')
+ expect(rendered).to have_field('project[suggestion_commit_message]', with: 'refactor: changed %{file_paths}')
end
end
diff --git a/spec/views/projects/issues/import_csv/_button.html.haml_spec.rb b/spec/views/projects/issues/import_csv/_button.html.haml_spec.rb
new file mode 100644
index 00000000000..440edd376e0
--- /dev/null
+++ b/spec/views/projects/issues/import_csv/_button.html.haml_spec.rb
@@ -0,0 +1,43 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe 'projects/issues/import_csv/_button' do
+ include Devise::Test::ControllerHelpers
+
+ context 'when the user does not have edit permissions' do
+ before do
+ render
+ end
+
+ it 'shows a dropdown button to import CSV' do
+ expect(rendered).to have_text('Import CSV')
+ end
+
+ it 'does not show a button to import from Jira' do
+ expect(rendered).not_to have_text('Import from Jira')
+ end
+ end
+
+ context 'when the user has edit permissions' do
+ let(:project) { create(:project) }
+ let(:current_user) { create(:user, maintainer_projects: [project]) }
+
+ before do
+ allow(view).to receive(:project_import_jira_path).and_return('import/jira')
+ allow(view).to receive(:current_user).and_return(current_user)
+
+ assign(:project, project)
+
+ render
+ end
+
+ it 'shows a dropdown button to import CSV' do
+ expect(rendered).to have_text('Import CSV')
+ end
+
+ it 'shows a button to import from Jira' do
+ expect(rendered).to have_text('Import from Jira')
+ end
+ end
+end
diff --git a/spec/views/projects/merge_requests/show.html.haml_spec.rb b/spec/views/projects/merge_requests/show.html.haml_spec.rb
index 665003d137a..e0acf5d1507 100644
--- a/spec/views/projects/merge_requests/show.html.haml_spec.rb
+++ b/spec/views/projects/merge_requests/show.html.haml_spec.rb
@@ -3,6 +3,10 @@
require 'spec_helper'
describe 'projects/merge_requests/show.html.haml' do
+ before do
+ allow(view).to receive(:experiment_enabled?).and_return(false)
+ end
+
include_context 'merge request show action'
describe 'merge request assignee sidebar' do
diff --git a/spec/views/projects/services/_form.haml_spec.rb b/spec/views/projects/services/_form.haml_spec.rb
index a3faa92b50e..720e0aaf450 100644
--- a/spec/views/projects/services/_form.haml_spec.rb
+++ b/spec/views/projects/services/_form.haml_spec.rb
@@ -15,7 +15,8 @@ describe 'projects/services/_form' do
allow(view).to receive_messages(current_user: user,
can?: true,
- current_application_settings: Gitlab::CurrentSettings.current_application_settings)
+ current_application_settings: Gitlab::CurrentSettings.current_application_settings,
+ request: double(referrer: '/services'))
end
context 'commit_events and merge_request_events' do
@@ -30,6 +31,7 @@ describe 'projects/services/_form' do
expect(rendered).to have_content('Event will be triggered when a commit is created/updated')
expect(rendered).to have_content('Event will be triggered when a merge request is created/updated/merged')
+ expect(rendered).to have_css("input[name='redirect_to'][value='/services']", count: 1, visible: false)
end
end
end
diff --git a/spec/views/shared/milestones/_top.html.haml_spec.rb b/spec/views/shared/milestones/_top.html.haml_spec.rb
index 1e209ad6f3f..2d72e278706 100644
--- a/spec/views/shared/milestones/_top.html.haml_spec.rb
+++ b/spec/views/shared/milestones/_top.html.haml_spec.rb
@@ -12,22 +12,6 @@ describe 'shared/milestones/_top.html.haml' do
allow(milestone).to receive(:milestone) { milestone }
end
- it 'renders a deprecation message for a legacy milestone' do
- allow(milestone).to receive(:legacy_group_milestone?) { true }
-
- render 'shared/milestones/top', milestone: milestone
-
- expect(rendered).to have_css('.milestone-deprecation-message')
- end
-
- it 'renders a deprecation message for a dashboard milestone' do
- allow(milestone).to receive(:dashboard_milestone?) { true }
-
- render 'shared/milestones/top', milestone: milestone
-
- expect(rendered).to have_css('.milestone-deprecation-message')
- end
-
it 'does not render a deprecation message for a non-legacy and non-dashboard milestone' do
assign :group, group