GitLab Commit is coming up on August 3-4. Learn how to innovate together using GitLab, the DevOps platform. Register for free:

Commit 0b8cefd3 authored by Grzegorz Bizon's avatar Grzegorz Bizon 💡
Browse files

Get FileUploader into test harness using factory

This attempts to get CarrierWave's uploader - `FileUploader` into test
harness using a factory. that makes it easier to build an instance of

Along with !3435 it may be easier to use uploaders in tests
parent 701976e0
......@@ -7,9 +7,9 @@ class FileUploader < CarrierWave::Uploader::Base
attr_accessor :project, :secret
def initialize(project, secret = self.class.generate_secret)
def initialize(project, secret = nil)
@project = project
@secret = secret
@secret = secret || self.class.generate_secret
def base_dir
FactoryGirl.define do
factory :file_uploader, class: FileUploader do
secret nil
transient do
path { File.join(Rails.root, 'spec/fixtures/rails_sample.jpg') }
file { }
after(:build) do |uploader, evaluator|!(evaluator.file)
initialize_with do
new(project, secret)
......@@ -7,10 +7,7 @@
let(:rewriter) {, old_project, user) }
context 'text contains links to uploads' do
let(:path) { Rails.root + 'spec/fixtures/rails_sample.jpg' }
let(:file) { fixture_file_upload(path, 'image/jpg') }
let(:uploader) { }
let!(:store) {!(file) } # TODO, see #xxx (carrierwave issue)
let(:uploader) { build(:file_uploader, project: old_project) }
let(:markdown) { uploader.to_h[:markdown] }
let(:text) { "Text and #{markdown}"}
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