Commit 1be878f1 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'reduce-diff-with-ce-in-spec-helpers' into 'master'

[EE] Reduce diff with EE in `spec/helpers`

Closes #10143

See merge request gitlab-org/gitlab-ee!10477
parents 547c5d19 952d64f8
# frozen_string_literal: true
require "spec_helper"
describe AuthHelper do
describe "button_based_providers" do
it 'excludes group_saml' do
allow(helper).to receive(:auth_providers) { [:group_saml] }
expect(helper.button_based_providers).to eq([])
end
end
describe "providers_for_base_controller" do
it 'excludes group_saml' do
allow(helper).to receive(:auth_providers) { [:group_saml] }
expect(helper.providers_for_base_controller).to eq([])
end
end
describe "form_based_providers" do
it 'includes kerberos provider' do
allow(helper).to receive(:auth_providers) { [:twitter, :kerberos] }
expect(helper.form_based_providers).to eq %i(kerberos)
end
end
describe 'form_based_auth_provider_has_active_class?' do
it 'selects main LDAP server' do
allow(helper).to receive(:auth_providers) { [:twitter, :ldapprimary, :ldapsecondary, :kerberos] }
expect(helper.form_based_auth_provider_has_active_class?(:twitter)).to be(false)
expect(helper.form_based_auth_provider_has_active_class?(:ldapprimary)).to be(true)
expect(helper.form_based_auth_provider_has_active_class?(:ldapsecondary)).to be(false)
expect(helper.form_based_auth_provider_has_active_class?(:kerberos)).to be(false)
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe IssuablesHelper do
describe '#issuable_initial_data' do
let(:user) { create(:user) }
before do
allow(helper).to receive(:current_user).and_return(user)
allow(helper).to receive(:can?).and_return(true)
stub_commonmark_sourcepos_disabled
end
it 'returns the correct data that includes canAdmin: true' do
issue = create(:issue, author: user, description: 'issue text')
@project = issue.project
expect(helper.issuable_initial_data(issue)).to include(canAdmin: true)
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe MergeRequestsHelper do
describe '#render_items_list' do
it "returns one item in the list" do
expect(render_items_list(["user"])).to eq("user")
end
it "returns two items in the list" do
expect(render_items_list(%w(user user1))).to eq("user and user1")
end
it "returns three items in the list" do
expect(render_items_list(%w(user user1 user2))).to eq("user, user1 and user2")
end
end
end
......@@ -32,4 +32,15 @@ describe ProjectsHelper do
end
end
end
describe 'default_clone_protocol' do
context 'when gitlab.config.kerberos is enabled and user is logged in' do
it 'returns krb5 as default protocol' do
allow(Gitlab.config.kerberos).to receive(:enabled).and_return(true)
allow(helper).to receive(:current_user).and_return(double)
expect(helper.send(:default_clone_protocol)).to eq('krb5')
end
end
end
end
......@@ -65,12 +65,10 @@ describe AppearancesHelper do
end
describe '#brand_title' do
it 'returns the default CE title when no appearance is present' do
allow(helper)
.to receive(:current_appearance)
.and_return(nil)
it 'returns the default title when no appearance is present' do
allow(helper).to receive(:current_appearance).and_return(nil)
expect(helper.brand_title).to eq('GitLab Enterprise Edition')
expect(helper.brand_title).to eq(helper.default_brand_title)
end
end
end
# frozen_string_literal: true
require "spec_helper"
describe AuthHelper do
......@@ -12,11 +14,6 @@ describe AuthHelper do
expect(helper.button_based_providers).to include(:twitter)
end
it 'excludes group_saml' do
allow(helper).to receive(:auth_providers) { [:group_saml] }
expect(helper.button_based_providers).to eq([])
end
it 'returns empty array' do
allow(helper).to receive(:auth_providers) { [] }
expect(helper.button_based_providers).to eq([])
......@@ -33,11 +30,6 @@ describe AuthHelper do
allow(helper).to receive(:auth_providers) { [:twitter, :ldapmain] }
expect(helper.providers_for_base_controller).not_to include(:ldapmain)
end
it 'excludes group_saml' do
allow(helper).to receive(:auth_providers) { [:group_saml] }
expect(helper.providers_for_base_controller).to eq([])
end
end
describe "form_based_providers" do
......@@ -50,21 +42,6 @@ describe AuthHelper do
allow(helper).to receive(:auth_providers) { [:twitter, :crowd] }
expect(helper.form_based_providers).to eq %i(crowd)
end
it 'includes kerberos provider' do
allow(helper).to receive(:auth_providers) { [:twitter, :kerberos] }
expect(helper.form_based_providers).to eq %i(kerberos)
end
end
describe 'form_based_auth_provider_has_active_class?' do
it 'selects main LDAP server' do
allow(helper).to receive(:auth_providers) { [:twitter, :ldapprimary, :ldapsecondary, :kerberos] }
expect(helper.form_based_auth_provider_has_active_class?(:twitter)).to be(false)
expect(helper.form_based_auth_provider_has_active_class?(:ldapprimary)).to be(true)
expect(helper.form_based_auth_provider_has_active_class?(:ldapsecondary)).to be(false)
expect(helper.form_based_auth_provider_has_active_class?(:kerberos)).to be(false)
end
end
describe 'form_based_auth_provider_has_active_class?' do
......
# frozen_string_literal: true
require 'spec_helper'
describe GroupsHelper do
......@@ -90,7 +92,7 @@ describe GroupsHelper do
let(:deep_nested_group) { create(:group, parent: nested_group) }
let!(:very_deep_nested_group) { create(:group, parent: deep_nested_group) }
it 'outputs the groups in the correct order', :postgresql do
it 'outputs the groups in the correct order' do
expect(helper.group_title(very_deep_nested_group))
.to match(%r{<li style="text-indent: 16px;"><a.*>#{deep_nested_group.name}.*</li>.*<a.*>#{very_deep_nested_group.name}</a>}m)
end
......
# frozen_string_literal: true
require 'spec_helper'
describe IssuablesHelper do
......@@ -185,7 +187,6 @@ describe IssuablesHelper do
updateEndpoint: "/#{@project.full_path}/issues/#{issue.iid}.json",
canUpdate: true,
canDestroy: true,
canAdmin: true,
issuableRef: "##{issue.iid}",
markdownPreviewPath: "/#{@project.full_path}/preview_markdown",
markdownDocsPath: '/help/user/markdown',
......@@ -199,7 +200,7 @@ describe IssuablesHelper do
initialDescriptionText: 'issue text',
initialTaskStatus: '0 of 0 tasks completed'
}
expect(helper.issuable_initial_data(issue)).to eq(expected_data)
expect(helper.issuable_initial_data(issue)).to match(hash_including(expected_data))
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe MergeRequestsHelper do
......@@ -44,20 +46,6 @@ describe MergeRequestsHelper do
end
end
describe '#render_items_list' do
it "returns one item in the list" do
expect(render_items_list(["user"])).to eq("user")
end
it "returns two items in the list" do
expect(render_items_list(%w(user user1))).to eq("user and user1")
end
it "returns three items in the list" do
expect(render_items_list(%w(user user1 user2))).to eq("user, user1 and user2")
end
end
describe '#tab_link_for' do
let(:merge_request) { create(:merge_request, :simple) }
let(:options) { Hash.new }
......
# frozen_string_literal: true
require 'spec_helper'
describe ProjectsHelper do
......@@ -350,15 +352,6 @@ describe ProjectsHelper do
expect(helper.send(:default_clone_protocol)).to eq('https')
end
end
context 'when gitlab.config.kerberos is enabled and user is logged in' do
it 'returns krb5 as default protocol' do
allow(Gitlab.config.kerberos).to receive(:enabled).and_return(true)
allow(helper).to receive(:current_user).and_return(double)
expect(helper.send(:default_clone_protocol)).to eq('krb5')
end
end
end
describe '#last_push_event' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment