diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-08-20 13:21:22 -0700 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-08-20 13:21:22 -0700 |
commit | 48e25a019a7dacbadeb3a49ed96e41d2c2241feb (patch) | |
tree | 282df780a058b5265d516eaa8d86a3ecbce22b1f | |
parent | 6110e175dc3bcf6d9ef416c7b95696efe509d02b (diff) | |
download | gitlab-ce-48e25a019a7dacbadeb3a49ed96e41d2c2241feb.tar.gz |
Add stub_reply_by_email_setting helper.
-rw-r--r-- | spec/lib/gitlab/email/receiver_spec.rb | 3 | ||||
-rw-r--r-- | spec/lib/gitlab/reply_by_email_spec.rb | 12 | ||||
-rw-r--r-- | spec/support/stub_configuration.rb | 4 |
3 files changed, 11 insertions, 8 deletions
diff --git a/spec/lib/gitlab/email/receiver_spec.rb b/spec/lib/gitlab/email/receiver_spec.rb index a6f682a2711..af44c1242ed 100644 --- a/spec/lib/gitlab/email/receiver_spec.rb +++ b/spec/lib/gitlab/email/receiver_spec.rb @@ -2,8 +2,7 @@ require "spec_helper" describe Gitlab::Email::Receiver do before do - allow(Gitlab.config.reply_by_email).to receive(:enabled).and_return(true) - allow(Gitlab.config.reply_by_email).to receive(:address).and_return("reply+%{reply_key}@appmail.adventuretime.ooo") + stub_reply_by_email_setting(enabled: true, address: "reply+%{reply_key}@appmail.adventuretime.ooo") end let(:reply_key) { "59d8df8370b7e95c5a49fbf86aeb2c93" } diff --git a/spec/lib/gitlab/reply_by_email_spec.rb b/spec/lib/gitlab/reply_by_email_spec.rb index a52af51e97c..a678c7e1a76 100644 --- a/spec/lib/gitlab/reply_by_email_spec.rb +++ b/spec/lib/gitlab/reply_by_email_spec.rb @@ -4,12 +4,12 @@ describe Gitlab::ReplyByEmail do describe "self.enabled?" do context "when reply by email is enabled" do before do - allow(Gitlab.config.reply_by_email).to receive(:enabled).and_return(true) + stub_reply_by_email_setting(enabled: true) end context "when the address is valid" do before do - allow(Gitlab.config.reply_by_email).to receive(:address).and_return("replies+%{reply_key}@example.com") + stub_reply_by_email_setting(address: "replies+%{reply_key}@example.com") end it "returns true" do @@ -19,7 +19,7 @@ describe Gitlab::ReplyByEmail do context "when the address is invalid" do before do - allow(Gitlab.config.reply_by_email).to receive(:address).and_return("replies@example.com") + stub_reply_by_email_setting(address: "replies@example.com") end it "returns false" do @@ -30,7 +30,7 @@ describe Gitlab::ReplyByEmail do context "when reply by email is disabled" do before do - allow(Gitlab.config.reply_by_email).to receive(:enabled).and_return(false) + stub_reply_by_email_setting(enabled: false) end it "returns false" do @@ -66,7 +66,7 @@ describe Gitlab::ReplyByEmail do context "self.reply_address" do before do - allow(Gitlab.config.reply_by_email).to receive(:address).and_return("replies+%{reply_key}@example.com") + stub_reply_by_email_setting(address: "replies+%{reply_key}@example.com") end it "returns the address with an interpolated reply key" do @@ -76,7 +76,7 @@ describe Gitlab::ReplyByEmail do context "self.reply_key_from_address" do before do - allow(Gitlab.config.reply_by_email).to receive(:address).and_return("replies+%{reply_key}@example.com") + stub_reply_by_email_setting(address: "replies+%{reply_key}@example.com") end it "returns reply key" do diff --git a/spec/support/stub_configuration.rb b/spec/support/stub_configuration.rb index e4004ec8f79..ef3a120d44a 100644 --- a/spec/support/stub_configuration.rb +++ b/spec/support/stub_configuration.rb @@ -17,6 +17,10 @@ module StubConfiguration allow(Gitlab.config.gravatar).to receive_messages(messages) end + def stub_reply_by_email_setting(messages) + allow(Gitlab.config.reply_by_email).to receive_messages(messages) + end + private # Modifies stubbed messages to also stub possible predicate versions |