Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/helpers/application_helper_spec.rb')
-rw-r--r--spec/helpers/application_helper_spec.rb86
1 files changed, 66 insertions, 20 deletions
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index 01be083b506..6ef57f8e22c 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -200,6 +200,60 @@ RSpec.describe ApplicationHelper do
it { expect(helper.active_when(false)).to eq(nil) }
end
+ describe '#linkedin_url?' do
+ using RSpec::Parameterized::TableSyntax
+
+ let(:user) { build_stubbed(:user) }
+
+ subject { helper.linkedin_url(user) }
+
+ before do
+ user.linkedin = linkedin_name
+ end
+
+ where(:linkedin_name, :linkedin_url) do
+ nil | 'https://www.linkedin.com/in/'
+ '' | 'https://www.linkedin.com/in/'
+ 'alice' | 'https://www.linkedin.com/in/alice'
+ 'http://www.linkedin.com/in/alice' | 'http://www.linkedin.com/in/alice'
+ 'http://linkedin.com/in/alice' | 'http://linkedin.com/in/alice'
+ 'https://www.linkedin.com/in/alice' | 'https://www.linkedin.com/in/alice'
+ 'https://linkedin.com/in/alice' | 'https://linkedin.com/in/alice'
+ 'https://linkedin.com/in/alice/more/path' | 'https://linkedin.com/in/alice/more/path'
+ end
+
+ with_them do
+ it { is_expected.to eq(linkedin_url) }
+ end
+ end
+
+ describe '#twitter_url?' do
+ using RSpec::Parameterized::TableSyntax
+
+ let(:user) { build_stubbed(:user) }
+
+ subject { helper.twitter_url(user) }
+
+ before do
+ user.twitter = twitter_name
+ end
+
+ where(:twitter_name, :twitter_url) do
+ nil | 'https://twitter.com/'
+ '' | 'https://twitter.com/'
+ 'alice' | 'https://twitter.com/alice'
+ 'http://www.twitter.com/alice' | 'http://www.twitter.com/alice'
+ 'http://twitter.com/alice' | 'http://twitter.com/alice'
+ 'https://www.twitter.com/alice' | 'https://www.twitter.com/alice'
+ 'https://twitter.com/alice' | 'https://twitter.com/alice'
+ 'https://twitter.com/alice/more/path' | 'https://twitter.com/alice/more/path'
+ end
+
+ with_them do
+ it { is_expected.to eq(twitter_url) }
+ end
+ end
+
unless Gitlab.jh?
describe '#promo_host' do
subject { helper.promo_host }
@@ -433,7 +487,8 @@ RSpec.describe ApplicationHelper do
page: 'application',
page_type_id: nil,
find_file: nil,
- group: nil
+ group: nil,
+ group_full_path: nil
}
)
end
@@ -449,7 +504,8 @@ RSpec.describe ApplicationHelper do
page: 'application',
page_type_id: nil,
find_file: nil,
- group: group.path
+ group: group.path,
+ group_full_path: group.full_path
}
)
end
@@ -473,6 +529,7 @@ RSpec.describe ApplicationHelper do
page_type_id: nil,
find_file: nil,
group: nil,
+ group_full_path: nil,
project_id: project.id,
project: project.path,
namespace_id: project.namespace.id
@@ -491,6 +548,7 @@ RSpec.describe ApplicationHelper do
page_type_id: nil,
find_file: nil,
group: project.group.name,
+ group_full_path: project.group.full_path,
project_id: project.id,
project: project.path,
namespace_id: project.namespace.id
@@ -517,6 +575,7 @@ RSpec.describe ApplicationHelper do
page_type_id: issue.id,
find_file: nil,
group: nil,
+ group_full_path: nil,
project_id: issue.project.id,
project: issue.project.path,
namespace_id: issue.project.namespace.id
@@ -590,12 +649,13 @@ RSpec.describe ApplicationHelper do
it 'adds custom form builder to options and calls `form_for`' do
options = { html: { class: 'foo-bar' } }
- expected_options = options.merge({ builder: ::Gitlab::FormBuilders::GitlabUiFormBuilder, url: '/root' })
+ expected_options = options.merge({ builder: ::Gitlab::FormBuilders::GitlabUiFormBuilder })
expect do |b|
helper.gitlab_ui_form_for(user, options, &b)
end.to yield_with_args(::Gitlab::FormBuilders::GitlabUiFormBuilder)
- expect(helper).to have_received(:form_for).with(user, expected_options)
+
+ expect(helper).to have_received(:form_for).with(user, a_hash_including(expected_options))
end
end
@@ -719,22 +779,8 @@ RSpec.describe ApplicationHelper do
end
describe 'stylesheet_link_tag_defer' do
- it 'uses print stylesheet when feature flag disabled' do
- stub_feature_flags(remove_startup_css: false)
-
- expect(helper.stylesheet_link_tag_defer('test')).to eq( '<link rel="stylesheet" media="print" href="/stylesheets/test.css" />')
- end
-
- it 'uses regular stylesheet when feature flag enabled' do
- stub_feature_flags(remove_startup_css: true)
-
- expect(helper.stylesheet_link_tag_defer('test')).to eq( '<link rel="stylesheet" media="all" href="/stylesheets/test.css" />')
- end
-
- it 'uses regular stylesheet when no_startup_css param present' do
- allow(helper.controller).to receive(:params).and_return({ no_startup_css: '' })
-
- expect(helper.stylesheet_link_tag_defer('test')).to eq( '<link rel="stylesheet" media="all" href="/stylesheets/test.css" />')
+ it 'uses media="all" in stylesheet' do
+ expect(helper.stylesheet_link_tag_defer('test')).to eq( '<link rel="stylesheet" href="/stylesheets/test.css" media="all" />')
end
end