Commit 54b04f1c authored by Douwe Maan's avatar Douwe Maan

Add fixture_file helper.

parent ac268674
require "spec_helper" require "spec_helper"
describe Gitlab::Email::AttachmentUploader do describe Gitlab::Email::AttachmentUploader do
def fixture_file(filename)
return '' if filename.blank?
file_path = File.expand_path(Rails.root + 'spec/fixtures/' + filename)
File.read(file_path)
end
describe "#execute" do describe "#execute" do
let(:project) { build(:project) } let(:project) { build(:project) }
let(:message_raw) { fixture_file("emails/attachment.eml") } let(:message_raw) { fixture_file("emails/attachment.eml") }
let(:message) { Mail::Message.new(message_raw) } let(:message) { Mail::Message.new(message_raw) }
it "creates a post with an attachment" do it "uploads all attachments and returns their links" do
links = described_class.new(message).execute(project) links = described_class.new(message).execute(project)
link = links.first link = links.first
......
require "spec_helper" require "spec_helper"
describe Gitlab::Email::Receiver do describe Gitlab::Email::Receiver do
def fixture_file(filename)
return '' if filename.blank?
file_path = File.expand_path(Rails.root + 'spec/fixtures/' + filename)
File.read(file_path)
end
before do before do
allow(Gitlab.config.reply_by_email).to receive(:enabled).and_return(true) 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") allow(Gitlab.config.reply_by_email).to receive(:address).and_return("reply+%{reply_key}@appmail.adventuretime.ooo")
......
...@@ -2,12 +2,6 @@ require "spec_helper" ...@@ -2,12 +2,6 @@ require "spec_helper"
# Inspired in great part by Discourse's Email::Receiver # Inspired in great part by Discourse's Email::Receiver
describe Gitlab::Email::ReplyParser do describe Gitlab::Email::ReplyParser do
def fixture_file(filename)
return '' if filename.blank?
file_path = File.expand_path(Rails.root + 'spec/fixtures/' + filename)
File.read(file_path)
end
describe '#execute' do describe '#execute' do
def test_parse_body(mail_string) def test_parse_body(mail_string)
described_class.new(Mail::Message.new(mail_string)).execute described_class.new(Mail::Message.new(mail_string)).execute
......
require "spec_helper" require "spec_helper"
describe Gitlab::GoogleCodeImport::Client do describe Gitlab::GoogleCodeImport::Client do
let(:raw_data) { JSON.parse(File.read(Rails.root.join("spec/fixtures/GoogleCodeProjectHosting.json"))) } let(:raw_data) { JSON.parse(fixture_file("GoogleCodeProjectHosting.json")) }
subject { described_class.new(raw_data) } subject { described_class.new(raw_data) }
describe "#valid?" do describe "#valid?" do
......
...@@ -2,7 +2,7 @@ require "spec_helper" ...@@ -2,7 +2,7 @@ require "spec_helper"
describe Gitlab::GoogleCodeImport::Importer do describe Gitlab::GoogleCodeImport::Importer do
let(:mapped_user) { create(:user, username: "thilo123") } let(:mapped_user) { create(:user, username: "thilo123") }
let(:raw_data) { JSON.parse(File.read(Rails.root.join("spec/fixtures/GoogleCodeProjectHosting.json"))) } let(:raw_data) { JSON.parse(fixture_file("GoogleCodeProjectHosting.json")) }
let(:client) { Gitlab::GoogleCodeImport::Client.new(raw_data) } let(:client) { Gitlab::GoogleCodeImport::Client.new(raw_data) }
let(:import_data) do let(:import_data) do
{ {
......
module FixtureHelpers
def fixture_file(filename)
return '' if filename.blank?
file_path = File.expand_path(Rails.root.join('spec/fixtures/', filename))
File.read(file_path)
end
end
RSpec.configure do |config|
config.include FixtureHelpers
end
...@@ -100,7 +100,7 @@ class MarkdownFeature ...@@ -100,7 +100,7 @@ class MarkdownFeature
end end
def raw_markdown def raw_markdown
fixture = Rails.root.join('spec/fixtures/markdown.md.erb') markdown = fixture_file('markdown.md.erb')
ERB.new(File.read(fixture)).result(binding) ERB.new(markdown).result(binding)
end end
end end
require "spec_helper" require "spec_helper"
describe EmailReceiverWorker do describe EmailReceiverWorker do
def fixture_file(filename)
return '' if filename.blank?
file_path = File.expand_path(Rails.root + 'spec/fixtures/' + filename)
File.read(file_path)
end
let(:raw_message) { fixture_file('emails/valid_reply.eml') } let(:raw_message) { fixture_file('emails/valid_reply.eml') }
context "when reply by email is enabled" do context "when reply by email is enabled" 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