summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-10-28 16:15:31 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-10-28 16:15:31 +0200
commitc71792d98c3bcf6b15f28f27b89359b0be081914 (patch)
tree19f817c1c5c6d311731574cab45188418d641759 /spec
parentd0ebdedf985be25f81230283daeb54c2ee586327 (diff)
parent9306d8fca2290ea6011d62f0eb62d2ac7fde9eb9 (diff)
downloadgitlab-ce-c71792d98c3bcf6b15f28f27b89359b0be081914.tar.gz
Merge branch 'master' of dev.gitlab.org:gitlab/gitlabhq
Diffstat (limited to 'spec')
-rw-r--r--spec/finders/snippets_finder_spec.rb7
-rw-r--r--spec/helpers/gitlab_markdown_helper_spec.rb4
-rw-r--r--spec/lib/disable_email_interceptor_spec.rb26
-rw-r--r--spec/lib/gitlab/ldap/config_spec.rb16
4 files changed, 51 insertions, 2 deletions
diff --git a/spec/finders/snippets_finder_spec.rb b/spec/finders/snippets_finder_spec.rb
index 5af76968183..c645cbc964c 100644
--- a/spec/finders/snippets_finder_spec.rb
+++ b/spec/finders/snippets_finder_spec.rb
@@ -64,6 +64,13 @@ describe SnippetsFinder do
snippets = SnippetsFinder.new.execute(user, filter: :by_user, user: user)
snippets.should include(@snippet1, @snippet2, @snippet3)
end
+
+ it "returns only public snippets if unauthenticated user" do
+ snippets = SnippetsFinder.new.execute(nil, filter: :by_user, user: user)
+ snippets.should include(@snippet3)
+ snippets.should_not include(@snippet2, @snippet1)
+ end
+
end
context 'by_project filter' do
diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb
index 61751a82369..3c636b747d1 100644
--- a/spec/helpers/gitlab_markdown_helper_spec.rb
+++ b/spec/helpers/gitlab_markdown_helper_spec.rb
@@ -594,7 +594,9 @@ describe GitlabMarkdownHelper do
end
it "should generate absolute urls for emoji" do
- markdown(":smile:").should include("src=\"http://localhost/assets/emoji/smile.png")
+ markdown(':smile:').should(
+ include(%(src="#{Gitlab.config.gitlab.url}/assets/emoji/smile.png))
+ )
end
it "should generate absolute urls for emoji if relative url is present" do
diff --git a/spec/lib/disable_email_interceptor_spec.rb b/spec/lib/disable_email_interceptor_spec.rb
new file mode 100644
index 00000000000..8bf6ee2ed50
--- /dev/null
+++ b/spec/lib/disable_email_interceptor_spec.rb
@@ -0,0 +1,26 @@
+require 'spec_helper'
+
+describe DisableEmailInterceptor do
+ before do
+ ActionMailer::Base.register_interceptor(DisableEmailInterceptor)
+ end
+
+ it 'should not send emails' do
+ Gitlab.config.gitlab.stub(:email_enabled).and_return(false)
+ expect {
+ deliver_mail
+ }.not_to change(ActionMailer::Base.deliveries, :count)
+ end
+
+ after 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.class_variable_set(:@@delivery_interceptors, [])
+ end
+
+ def deliver_mail
+ key = create :personal_key
+ Notify.new_ssh_key_email(key.id)
+ end
+end
diff --git a/spec/lib/gitlab/ldap/config_spec.rb b/spec/lib/gitlab/ldap/config_spec.rb
index 76cc7f95c47..3ebb8aae243 100644
--- a/spec/lib/gitlab/ldap/config_spec.rb
+++ b/spec/lib/gitlab/ldap/config_spec.rb
@@ -16,5 +16,19 @@ describe Gitlab::LDAP::Config do
it "raises an error if a unknow provider is used" do
expect{ Gitlab::LDAP::Config.new 'unknown' }.to raise_error
end
+
+ context "if 'ldap' is the provider name" do
+ let(:provider) { 'ldap' }
+
+ context "and 'ldap' is not in defined as a provider" do
+ before { Gitlab::LDAP::Config.stub(providers: %w{ldapmain}) }
+
+ it "uses the first provider" do
+ # Fetch the provider_name attribute from 'options' so that we know
+ # that the 'options' Hash is not empty/nil.
+ expect(config.options['provider_name']).to eq('ldapmain')
+ end
+ end
+ end
end
-end \ No newline at end of file
+end