Commit cddc5cac authored by Rémy Coutable's avatar Rémy Coutable

Use described_class when possible

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent ddccd24c
......@@ -5,37 +5,37 @@ describe Settings do
describe '#host_without_www' do
context 'URL with protocol' do
it 'returns the host' do
expect(Settings.host_without_www('http://foo.com')).to eq 'foo.com'
expect(Settings.host_without_www('http://www.foo.com')).to eq 'foo.com'
expect(Settings.host_without_www('http://secure.foo.com')).to eq 'secure.foo.com'
expect(Settings.host_without_www('http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com'
expect(described_class.host_without_www('http://foo.com')).to eq 'foo.com'
expect(described_class.host_without_www('http://www.foo.com')).to eq 'foo.com'
expect(described_class.host_without_www('http://secure.foo.com')).to eq 'secure.foo.com'
expect(described_class.host_without_www('http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com'
expect(Settings.host_without_www('https://foo.com')).to eq 'foo.com'
expect(Settings.host_without_www('https://www.foo.com')).to eq 'foo.com'
expect(Settings.host_without_www('https://secure.foo.com')).to eq 'secure.foo.com'
expect(Settings.host_without_www('https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'secure.gravatar.com'
expect(described_class.host_without_www('https://foo.com')).to eq 'foo.com'
expect(described_class.host_without_www('https://www.foo.com')).to eq 'foo.com'
expect(described_class.host_without_www('https://secure.foo.com')).to eq 'secure.foo.com'
expect(described_class.host_without_www('https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'secure.gravatar.com'
end
end
context 'URL without protocol' do
it 'returns the host' do
expect(Settings.host_without_www('foo.com')).to eq 'foo.com'
expect(Settings.host_without_www('www.foo.com')).to eq 'foo.com'
expect(Settings.host_without_www('secure.foo.com')).to eq 'secure.foo.com'
expect(Settings.host_without_www('www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com'
expect(described_class.host_without_www('foo.com')).to eq 'foo.com'
expect(described_class.host_without_www('www.foo.com')).to eq 'foo.com'
expect(described_class.host_without_www('secure.foo.com')).to eq 'secure.foo.com'
expect(described_class.host_without_www('www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com'
end
context 'URL with user/port' do
it 'returns the host' do
expect(Settings.host_without_www('bob:pass@foo.com:8080')).to eq 'foo.com'
expect(Settings.host_without_www('bob:pass@www.foo.com:8080')).to eq 'foo.com'
expect(Settings.host_without_www('bob:pass@secure.foo.com:8080')).to eq 'secure.foo.com'
expect(Settings.host_without_www('bob:pass@www.gravatar.com:8080/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com'
expect(described_class.host_without_www('bob:pass@foo.com:8080')).to eq 'foo.com'
expect(described_class.host_without_www('bob:pass@www.foo.com:8080')).to eq 'foo.com'
expect(described_class.host_without_www('bob:pass@secure.foo.com:8080')).to eq 'secure.foo.com'
expect(described_class.host_without_www('bob:pass@www.gravatar.com:8080/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com'
expect(Settings.host_without_www('http://bob:pass@foo.com:8080')).to eq 'foo.com'
expect(Settings.host_without_www('http://bob:pass@www.foo.com:8080')).to eq 'foo.com'
expect(Settings.host_without_www('http://bob:pass@secure.foo.com:8080')).to eq 'secure.foo.com'
expect(Settings.host_without_www('http://bob:pass@www.gravatar.com:8080/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com'
expect(described_class.host_without_www('http://bob:pass@foo.com:8080')).to eq 'foo.com'
expect(described_class.host_without_www('http://bob:pass@www.foo.com:8080')).to eq 'foo.com'
expect(described_class.host_without_www('http://bob:pass@secure.foo.com:8080')).to eq 'secure.foo.com'
expect(described_class.host_without_www('http://bob:pass@www.gravatar.com:8080/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com'
end
end
end
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe DisableEmailInterceptor do
before do
Mail.register_interceptor(DisableEmailInterceptor)
Mail.register_interceptor(described_class)
end
it 'does not send emails' do
......@@ -14,7 +14,7 @@ describe DisableEmailInterceptor do
# Removing interceptor from the list because unregister_interceptor is
# implemented in later version of mail gem
# See: https://github.com/mikel/mail/pull/705
Mail.unregister_interceptor(DisableEmailInterceptor)
Mail.unregister_interceptor(described_class)
end
def deliver_mail
......
......@@ -16,42 +16,42 @@ describe EventFilter do
let!(:left_event) { create(:event, :left, project: public_project, target: public_project, author: source_user) }
it 'applies push filter' do
events = EventFilter.new(EventFilter.push).apply_filter(Event.all)
events = described_class.new(described_class.push).apply_filter(Event.all)
expect(events).to contain_exactly(push_event)
end
it 'applies merged filter' do
events = EventFilter.new(EventFilter.merged).apply_filter(Event.all)
events = described_class.new(described_class.merged).apply_filter(Event.all)
expect(events).to contain_exactly(merged_event)
end
it 'applies issue filter' do
events = EventFilter.new(EventFilter.issue).apply_filter(Event.all)
events = described_class.new(described_class.issue).apply_filter(Event.all)
expect(events).to contain_exactly(created_event, updated_event, closed_event, reopened_event)
end
it 'applies comments filter' do
events = EventFilter.new(EventFilter.comments).apply_filter(Event.all)
events = described_class.new(described_class.comments).apply_filter(Event.all)
expect(events).to contain_exactly(comments_event)
end
it 'applies team filter' do
events = EventFilter.new(EventFilter.team).apply_filter(Event.all)
events = described_class.new(described_class.team).apply_filter(Event.all)
expect(events).to contain_exactly(joined_event, left_event)
end
it 'applies all filter' do
events = EventFilter.new(EventFilter.all).apply_filter(Event.all)
events = described_class.new(described_class.all).apply_filter(Event.all)
expect(events).to contain_exactly(push_event, merged_event, created_event, updated_event, closed_event, reopened_event, comments_event, joined_event, left_event)
end
it 'applies no filter' do
events = EventFilter.new(nil).apply_filter(Event.all)
events = described_class.new(nil).apply_filter(Event.all)
expect(events).to contain_exactly(push_event, merged_event, created_event, updated_event, closed_event, reopened_event, comments_event, joined_event, left_event)
end
it 'applies unknown filter' do
events = EventFilter.new('').apply_filter(Event.all)
events = described_class.new('').apply_filter(Event.all)
expect(events).to contain_exactly(push_event, merged_event, created_event, updated_event, closed_event, reopened_event, comments_event, joined_event, left_event)
end
end
......
require 'spec_helper'
describe ExtractsPath do
include ExtractsPath
include described_class
include RepoHelpers
include Gitlab::Routing
......
require 'spec_helper'
describe FileSizeValidator do
let(:validator) { FileSizeValidator.new(options) }
let(:validator) { described_class.new(options) }
let(:attachment) { AttachmentUploader.new }
let(:note) { create(:note) }
......
......@@ -58,7 +58,7 @@ describe Gitlab::BitbucketImport::Importer do
)
end
let(:importer) { Gitlab::BitbucketImport::Importer.new(project) }
let(:importer) { described_class.new(project) }
let(:issues_statuses_sample_data) do
{
......
......@@ -27,7 +27,7 @@ describe Gitlab::BitbucketImport::ProjectCreator do
it 'creates project' do
allow_any_instance_of(Project).to receive(:add_import_job)
project_creator = Gitlab::BitbucketImport::ProjectCreator.new(repo, 'vim', namespace, user, access_params)
project_creator = described_class.new(repo, 'vim', namespace, user, access_params)
project = project_creator.execute
expect(project.import_url).to eq("ssh://git@bitbucket.org/asd/vim.git")
......
require 'spec_helper'
describe Gitlab::CiAccess do
let(:access) { Gitlab::CiAccess.new }
let(:access) { described_class.new }
describe '#can_do_action?' do
context 'when action is :build_download_code' do
......
......@@ -10,7 +10,7 @@ describe Gitlab::Conflict::File do
let(:index) { rugged.merge_commits(our_commit, their_commit) }
let(:conflict) { index.conflicts.last }
let(:merge_file_result) { index.merge_file('files/ruby/regex.rb') }
let(:conflict_file) { Gitlab::Conflict::File.new(merge_file_result, conflict, merge_request: merge_request) }
let(:conflict_file) { described_class.new(merge_file_result, conflict, merge_request: merge_request) }
describe '#resolve_lines' do
let(:section_keys) { conflict_file.sections.map { |section| section[:id] }.compact }
......@@ -220,7 +220,7 @@ end
FILE
end
let(:conflict_file) { Gitlab::Conflict::File.new({ data: file }, conflict, merge_request: merge_request) }
let(:conflict_file) { described_class.new({ data: file }, conflict, merge_request: merge_request) }
let(:sections) { conflict_file.sections }
it 'sets the correct match line headers' do
......
require 'spec_helper'
describe Gitlab::Conflict::Parser do
let(:parser) { Gitlab::Conflict::Parser.new }
let(:parser) { described_class.new }
describe '#parse' do
def parse_text(text)
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::Database::MigrationHelpers do
let(:model) do
ActiveRecord::Migration.new.extend(
Gitlab::Database::MigrationHelpers
described_class
)
end
......
......@@ -10,7 +10,7 @@ describe Gitlab::Diff::Highlight do
describe '#highlight' do
context "with a diff file" do
let(:subject) { Gitlab::Diff::Highlight.new(diff_file, repository: project.repository).highlight }
let(:subject) { described_class.new(diff_file, repository: project.repository).highlight }
it 'returns Gitlab::Diff::Line elements' do
expect(subject.first).to be_an_instance_of(Gitlab::Diff::Line)
......@@ -41,7 +41,7 @@ describe Gitlab::Diff::Highlight do
end
context "with diff lines" do
let(:subject) { Gitlab::Diff::Highlight.new(diff_file.diff_lines, repository: project.repository).highlight }
let(:subject) { described_class.new(diff_file.diff_lines, repository: project.repository).highlight }
it 'returns Gitlab::Diff::Line elements' do
expect(subject.first).to be_an_instance_of(Gitlab::Diff::Line)
......
......@@ -6,7 +6,7 @@ describe Gitlab::Diff::Parser do
let(:project) { create(:project) }
let(:commit) { project.commit(sample_commit.id) }
let(:diff) { commit.raw_diffs.first }
let(:parser) { Gitlab::Diff::Parser.new }
let(:parser) { described_class.new }
describe '#parse' do
let(:diff) do
......
......@@ -5,7 +5,7 @@ describe Gitlab::Git::Hook do
before do
# We need this because in the spec/spec_helper.rb we define it like this:
# allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([true, nil])
allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_call_original
allow_any_instance_of(described_class).to receive(:trigger).and_call_original
end
describe "#trigger" do
......@@ -48,7 +48,7 @@ describe Gitlab::Git::Hook do
it "returns success with no errors" do
create_hook(hook_name)
hook = Gitlab::Git::Hook.new(hook_name, project)
hook = described_class.new(hook_name, project)
blank = Gitlab::Git::BLANK_SHA
ref = Gitlab::Git::BRANCH_REF_PREFIX + 'new_branch'
......@@ -66,7 +66,7 @@ describe Gitlab::Git::Hook do
context "when the hook is unsuccessful" do
it "returns failure with errors" do
create_failing_hook(hook_name)
hook = Gitlab::Git::Hook.new(hook_name, project)
hook = described_class.new(hook_name, project)
blank = Gitlab::Git::BLANK_SHA
ref = Gitlab::Git::BRANCH_REF_PREFIX + 'new_branch'
......@@ -80,7 +80,7 @@ describe Gitlab::Git::Hook do
context "when the hook doesn't exist" do
it "returns success with no errors" do
hook = Gitlab::Git::Hook.new('unknown_hook', project)
hook = described_class.new('unknown_hook', project)
blank = Gitlab::Git::BLANK_SHA
ref = Gitlab::Git::BRANCH_REF_PREFIX + 'new_branch'
......
......@@ -11,7 +11,7 @@ describe Gitlab::Git::RevList do
end
context "#new_refs" do
let(:rev_list) { Gitlab::Git::RevList.new(newrev: 'newrev', path_to_repo: project.repository.path_to_repo) }
let(:rev_list) { described_class.new(newrev: 'newrev', path_to_repo: project.repository.path_to_repo) }
it 'calls out to `popen`' do
expect(Gitlab::Popen).to receive(:popen).with([
......@@ -33,7 +33,7 @@ describe Gitlab::Git::RevList do
end
context "#missed_ref" do
let(:rev_list) { Gitlab::Git::RevList.new(oldrev: 'oldrev', newrev: 'newrev', path_to_repo: project.repository.path_to_repo) }
let(:rev_list) { described_class.new(oldrev: 'oldrev', newrev: 'newrev', path_to_repo: project.repository.path_to_repo) }
it 'calls out to `popen`' do
expect(Gitlab::Popen).to receive(:popen).with([
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::GitAccess do
let(:pull_access_check) { access.check('git-upload-pack', '_any') }
let(:push_access_check) { access.check('git-receive-pack', '_any') }
let(:access) { Gitlab::GitAccess.new(actor, project, protocol, authentication_abilities: authentication_abilities, redirected_path: redirected_path) }
let(:access) { described_class.new(actor, project, protocol, authentication_abilities: authentication_abilities, redirected_path: redirected_path) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:actor) { user }
......@@ -280,7 +280,7 @@ describe Gitlab::GitAccess do
context 'when project is public' do
let(:public_project) { create(:project, :public, :repository) }
let(:access) { Gitlab::GitAccess.new(nil, public_project, 'web', authentication_abilities: []) }
let(:access) { described_class.new(nil, public_project, 'web', authentication_abilities: []) }
context 'when repository is enabled' do
it 'give access to download code' do
......@@ -441,7 +441,7 @@ describe Gitlab::GitAccess do
end
permissions_matrix[role].each do |action, allowed|
context action do
context action.to_s do
subject { access.send(:check_push_access!, changes[action]) }
it do
......
require 'spec_helper'
describe Gitlab::GitAccessWiki do
let(:access) { Gitlab::GitAccessWiki.new(user, project, 'web', authentication_abilities: authentication_abilities, redirected_path: redirected_path) }
let(:access) { described_class.new(user, project, 'web', authentication_abilities: authentication_abilities, redirected_path: redirected_path) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:redirected_path) { nil }
......
require 'spec_helper'
describe Gitlab::GitRefValidator do
it { expect(Gitlab::GitRefValidator.validate('feature/new')).to be_truthy }
it { expect(Gitlab::GitRefValidator.validate('implement_@all')).to be_truthy }
it { expect(Gitlab::GitRefValidator.validate('my_new_feature')).to be_truthy }
it { expect(Gitlab::GitRefValidator.validate('#1')).to be_truthy }
it { expect(Gitlab::GitRefValidator.validate('feature/refs/heads/foo')).to be_truthy }
it { expect(Gitlab::GitRefValidator.validate('feature/~new/')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('feature/^new/')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('feature/:new/')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('feature/?new/')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('feature/*new/')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('feature/[new/')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('feature/new/')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('feature/new.')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('feature\@{')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('feature\new')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('feature//new')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('feature new')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('refs/heads/')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('refs/remotes/')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('refs/heads/feature')).to be_falsey }
it { expect(Gitlab::GitRefValidator.validate('refs/remotes/origin')).to be_falsey }
it { expect(described_class.validate('feature/new')).to be_truthy }
it { expect(described_class.validate('implement_@all')).to be_truthy }
it { expect(described_class.validate('my_new_feature')).to be_truthy }
it { expect(described_class.validate('#1')).to be_truthy }
it { expect(described_class.validate('feature/refs/heads/foo')).to be_truthy }
it { expect(described_class.validate('feature/~new/')).to be_falsey }
it { expect(described_class.validate('feature/^new/')).to be_falsey }
it { expect(described_class.validate('feature/:new/')).to be_falsey }
it { expect(described_class.validate('feature/?new/')).to be_falsey }
it { expect(described_class.validate('feature/*new/')).to be_falsey }
it { expect(described_class.validate('feature/[new/')).to be_falsey }
it { expect(described_class.validate('feature/new/')).to be_falsey }
it { expect(described_class.validate('feature/new.')).to be_falsey }
it { expect(described_class.validate('feature\@{')).to be_falsey }
it { expect(described_class.validate('feature\new')).to be_falsey }
it { expect(described_class.validate('feature//new')).to be_falsey }
it { expect(described_class.validate('feature new')).to be_falsey }
it { expect(described_class.validate('refs/heads/')).to be_falsey }
it { expect(described_class.validate('refs/remotes/')).to be_falsey }
it { expect(described_class.validate('refs/heads/feature')).to be_falsey }
it { expect(described_class.validate('refs/remotes/origin')).to be_falsey }
end
......@@ -6,7 +6,7 @@ describe Gitlab::Git do
describe 'committer_hash' do
it "returns a hash containing the given email and name" do
committer_hash = Gitlab::Git.committer_hash(email: committer_email, name: committer_name)
committer_hash = described_class.committer_hash(email: committer_email, name: committer_name)
expect(committer_hash[:email]).to eq(committer_email)
expect(committer_hash[:name]).to eq(committer_name)
......@@ -15,7 +15,7 @@ describe Gitlab::Git do
context 'when email is nil' do
it "returns nil" do
committer_hash = Gitlab::Git.committer_hash(email: nil, name: committer_name)
committer_hash = described_class.committer_hash(email: nil, name: committer_name)
expect(committer_hash).to be_nil
end
......@@ -23,7 +23,7 @@ describe Gitlab::Git do
context 'when name is nil' do
it "returns nil" do
committer_hash = Gitlab::Git.committer_hash(email: committer_email, name: nil)
committer_hash = described_class.committer_hash(email: committer_email, name: nil)
expect(committer_hash).to be_nil
end
......
......@@ -4,7 +4,7 @@ describe Gitlab::GitlabImport::Client do
include ImportSpecHelper
let(:token) { '123456' }
let(:client) { Gitlab::GitlabImport::Client.new(token) }
let(:client) { described_class.new(token) }
before do
stub_omniauth_provider('gitlab')
......
......@@ -23,7 +23,7 @@ describe Gitlab::GitlabImport::ProjectCreator do
it 'creates project' do
allow_any_instance_of(Project).to receive(:add_import_job)
project_creator = Gitlab::GitlabImport::ProjectCreator.new(repo, namespace, user, access_params)
project_creator = described_class.new(repo, namespace, user, access_params)
project = project_creator.execute
expect(project.import_url).to eq("https://oauth2:asdffg@gitlab.com/asd/vim.git")
......
......@@ -18,7 +18,7 @@ describe Gitlab::GoogleCodeImport::ProjectCreator do
it 'creates project' do
allow_any_instance_of(Project).to receive(:add_import_job)
project_creator = Gitlab::GoogleCodeImport::ProjectCreator.new(repo, namespace, user)
project_creator = described_class.new(repo, namespace, user)
project = project_creator.execute
expect(project.import_url).to eq("https://vim.googlecode.com/git/")
......
......@@ -12,7 +12,7 @@ describe Gitlab::Highlight do
let(:blob) { repository.blob_at_branch(branch, path) }
let(:highlighter) do
Gitlab::Highlight.new(blob.path, blob.data, repository: repository)
described_class.new(blob.path, blob.data, repository: repository)
end
before do
......@@ -42,7 +42,7 @@ describe Gitlab::Highlight do
let(:path) { 'files/whitespace' }
let(:blob) { repository.blob_at_branch(branch, path) }
let(:lines) do
Gitlab::Highlight.highlight(blob.path, blob.data, repository: repository).lines
described_class.highlight(blob.path, blob.data, repository: repository).lines
end
it 'strips extra LFs' do
......
......@@ -6,7 +6,7 @@ describe Gitlab::KeyFingerprint do
describe "#fingerprint" do
it "generates the key's fingerprint" do
expect(Gitlab::KeyFingerprint.new(key).fingerprint).to eq(fingerprint)
expect(described_class.new(key).fingerprint).to eq(fingerprint)
end
end
end
require 'spec_helper'
describe Gitlab::LDAP::Access do
let(:access) { Gitlab::LDAP::Access.new user }
let(:access) { described_class.new user }
let(:user) { create(:omniauth_user) }
describe '.allowed?' do
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Gitlab::LDAP::AuthHash do
let(:auth_hash) do
Gitlab::LDAP::AuthHash.new(
described_class.new(
OmniAuth::AuthHash.new(
uid: '123456',
provider: 'ldapmain',
......
......@@ -3,11 +3,11 @@ require 'spec_helper'
describe Gitlab::LDAP::Config do
include LdapHelpers
let(:config) { Gitlab::LDAP::Config.new('ldapmain') }
let(:config) { described_class.new('ldapmain') }
describe '#initialize' do
it 'requires a provider' do
expect{ Gitlab::LDAP::Config.new }.to raise_error ArgumentError
expect{ described_class.new }.to raise_error ArgumentError
end
it 'works' do
......@@ -15,7 +15,7 @@ describe Gitlab::LDAP::Config do
end
it 'raises an error if a unknown provider is used' do
expect{ Gitlab::LDAP::Config.new 'unknown' }.to raise_error(RuntimeError)
expect{ described_class.new 'unknown' }.to raise_error(RuntimeError)
end
end
......
require 'spec_helper'
describe Gitlab::LDAP::User do
let(:ldap_user) { Gitlab::LDAP::User.new(auth_hash) }
let(:ldap_user) { described_class.new(auth_hash) }
let(:gl_user) { ldap_user.gl_user }
let(:info) do
{
......@@ -13,7 +13,7 @@ describe Gitlab::LDAP::User do
let(:auth_hash) do
OmniAuth::AuthHash.new(uid: 'my-uid', provider: 'ldapmain', info: info)
end
let(:ldap_user_upper_case) { Gitlab::LDAP::User.new(auth_hash_upper_case) }
let(:ldap_user_upper_case) { described_class.new(auth_hash_upper_case) }
let(:info_upper_case) do
{
name: 'John',
......
......@@ -5,36 +5,36 @@ describe Gitlab::MarkupHelper do
%w(textile rdoc org creole wiki
mediawiki rst adoc ad asciidoc mdown md markdown).each do |type|
it "returns true for #{type} files" do
expect(Gitlab::MarkupHelper.markup?("README.#{type}")).to be_truthy
expect(described_class.markup?("README.#{type}")).to be_truthy
end
end
it 'returns false when given a non-markup filename' do
expect(Gitlab::MarkupHelper.markup?('README.rb')).not_to be_truthy
expect(described_class.markup?('README.rb')).not_to be_truthy
end
end
describe '#gitlab_markdown?' do
%w(mdown mkd mkdn md markdown).each do |type|
it "returns true for #{type} files" do
expect(Gitlab::MarkupHelper.gitlab_markdown?("README.#{type}")).to be_truthy
expect(described_class.gitlab_markdown?("README.#{type}")).to be_truthy
end
end
it 'returns false when given a non-markdown filename' do
expect(Gitlab::MarkupHelper.gitlab_markdown?('README.rb')).not_to be_truthy
expect(described_class.gitlab_markdown?('README.rb')).not_to be_truthy
end
end
describe '#asciidoc?' do
%w(adoc ad asciidoc ADOC).each do |type|
it "returns true for #{type} files" do
expect(Gitlab::MarkupHelper.asciidoc?("README.#{type}")).to be_truthy
expect(described_class.asciidoc?("README.#{type}")).to be_truthy
end
end
it 'returns false when given a non-asciidoc filename' do
expect(Gitlab::MarkupHelper.asciidoc?('README.rb')).not_to be_truthy
expect(described_class.asciidoc?('README.rb')).not_to be_truthy
end
end
end
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Gitlab::OAuth::AuthHash do
let(:auth_hash) do