summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-09-21 09:46:47 +0200
committerDouwe Maan <douwe@gitlab.com>2015-09-21 10:35:37 +0200
commitee028d9d60522f8993a0b2429ac8a0631d59229a (patch)
tree5e028593ff4394df287de8f61824c8d004a81688 /spec
parent11bbc06b4bbcb678f3ee6b8f1d143ed86d25a76c (diff)
downloadgitlab-ce-ee028d9d60522f8993a0b2429ac8a0631d59229a.tar.gz
Rename reply_by_email to incoming_email to prepare for the future.
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/email/receiver_spec.rb2
-rw-r--r--spec/lib/gitlab/incoming_email_spec.rb61
-rw-r--r--spec/lib/gitlab/reply_by_email_spec.rb86
-rw-r--r--spec/support/stub_configuration.rb4
-rw-r--r--spec/workers/email_receiver_worker_spec.rb4
5 files changed, 66 insertions, 91 deletions
diff --git a/spec/lib/gitlab/email/receiver_spec.rb b/spec/lib/gitlab/email/receiver_spec.rb
index 1cc80f35f98..e470b7cd5f5 100644
--- a/spec/lib/gitlab/email/receiver_spec.rb
+++ b/spec/lib/gitlab/email/receiver_spec.rb
@@ -2,7 +2,7 @@ require "spec_helper"
describe Gitlab::Email::Receiver do
before do
- stub_reply_by_email_setting(enabled: true, address: "reply+%{reply_key}@appmail.adventuretime.ooo")
+ stub_incoming_email_setting(enabled: true, address: "reply+%{key}@appmail.adventuretime.ooo")
end
let(:reply_key) { "59d8df8370b7e95c5a49fbf86aeb2c93" }
diff --git a/spec/lib/gitlab/incoming_email_spec.rb b/spec/lib/gitlab/incoming_email_spec.rb
new file mode 100644
index 00000000000..5fdb9c723b1
--- /dev/null
+++ b/spec/lib/gitlab/incoming_email_spec.rb
@@ -0,0 +1,61 @@
+require "spec_helper"
+
+describe Gitlab::IncomingEmail do
+ describe "self.enabled?" do
+ context "when reply by email is enabled" do
+ before do
+ stub_incoming_email_setting(enabled: true)
+ end
+
+ context "when the address is valid" do
+ before do
+ stub_incoming_email_setting(address: "replies+%{key}@example.com")
+ end
+
+ it "returns true" do
+ expect(described_class.enabled?).to be_truthy
+ end
+ end
+
+ context "when the address is invalid" do
+ before do
+ stub_incoming_email_setting(address: "replies@example.com")
+ end
+
+ it "returns false" do
+ expect(described_class.enabled?).to be_falsey
+ end
+ end
+ end
+
+ context "when reply by email is disabled" do
+ before do
+ stub_incoming_email_setting(enabled: false)
+ end
+
+ it "returns false" do
+ expect(described_class.enabled?).to be_falsey
+ end
+ end
+ end
+
+ context "self.reply_address" do
+ before do
+ stub_incoming_email_setting(address: "replies+%{key}@example.com")
+ end
+
+ it "returns the address with an interpolated reply key" do
+ expect(described_class.reply_address("key")).to eq("replies+key@example.com")
+ end
+ end
+
+ context "self.key_from_address" do
+ before do
+ stub_incoming_email_setting(address: "replies+%{key}@example.com")
+ end
+
+ it "returns reply key" do
+ expect(described_class.key_from_address("replies+key@example.com")).to eq("key")
+ end
+ end
+end
diff --git a/spec/lib/gitlab/reply_by_email_spec.rb b/spec/lib/gitlab/reply_by_email_spec.rb
deleted file mode 100644
index a678c7e1a76..00000000000
--- a/spec/lib/gitlab/reply_by_email_spec.rb
+++ /dev/null
@@ -1,86 +0,0 @@
-require "spec_helper"
-
-describe Gitlab::ReplyByEmail do
- describe "self.enabled?" do
- context "when reply by email is enabled" do
- before do
- stub_reply_by_email_setting(enabled: true)
- end
-
- context "when the address is valid" do
- before do
- stub_reply_by_email_setting(address: "replies+%{reply_key}@example.com")
- end
-
- it "returns true" do
- expect(described_class.enabled?).to be_truthy
- end
- end
-
- context "when the address is invalid" do
- before do
- stub_reply_by_email_setting(address: "replies@example.com")
- end
-
- it "returns false" do
- expect(described_class.enabled?).to be_falsey
- end
- end
- end
-
- context "when reply by email is disabled" do
- before do
- stub_reply_by_email_setting(enabled: false)
- end
-
- it "returns false" do
- expect(described_class.enabled?).to be_falsey
- end
- end
- end
-
- describe "self.reply_key" do
- context "when enabled" do
- before do
- allow(described_class).to receive(:enabled?).and_return(true)
- end
-
- it "returns a random hex" do
- key = described_class.reply_key
- key2 = described_class.reply_key
-
- expect(key).not_to eq(key2)
- end
- end
-
- context "when disabled" do
- before do
- allow(described_class).to receive(:enabled?).and_return(false)
- end
-
- it "returns nil" do
- expect(described_class.reply_key).to be_nil
- end
- end
- end
-
- context "self.reply_address" do
- before do
- stub_reply_by_email_setting(address: "replies+%{reply_key}@example.com")
- end
-
- it "returns the address with an interpolated reply key" do
- expect(described_class.reply_address("key")).to eq("replies+key@example.com")
- end
- end
-
- context "self.reply_key_from_address" do
- before do
- stub_reply_by_email_setting(address: "replies+%{reply_key}@example.com")
- end
-
- it "returns reply key" do
- expect(described_class.reply_key_from_address("replies+key@example.com")).to eq("key")
- end
- end
-end
diff --git a/spec/support/stub_configuration.rb b/spec/support/stub_configuration.rb
index ef3a120d44a..f40ee862df8 100644
--- a/spec/support/stub_configuration.rb
+++ b/spec/support/stub_configuration.rb
@@ -17,8 +17,8 @@ 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)
+ def stub_incoming_email_setting(messages)
+ allow(Gitlab.config.incoming_email).to receive_messages(messages)
end
private
diff --git a/spec/workers/email_receiver_worker_spec.rb b/spec/workers/email_receiver_worker_spec.rb
index e8f1bd2fa2f..65a8d7d9197 100644
--- a/spec/workers/email_receiver_worker_spec.rb
+++ b/spec/workers/email_receiver_worker_spec.rb
@@ -5,7 +5,7 @@ describe EmailReceiverWorker do
context "when reply by email is enabled" do
before do
- allow(Gitlab::ReplyByEmail).to receive(:enabled?).and_return(true)
+ allow(Gitlab::IncomingEmail).to receive(:enabled?).and_return(true)
end
it "calls the email receiver" do
@@ -33,7 +33,7 @@ describe EmailReceiverWorker do
context "when reply by email is disabled" do
before do
- allow(Gitlab::ReplyByEmail).to receive(:enabled?).and_return(false)
+ allow(Gitlab::IncomingEmail).to receive(:enabled?).and_return(false)
end
it "doesn't call the email receiver" do