summaryrefslogtreecommitdiff
path: root/spec/factories/file_uploader.rb
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-03-29 12:12:57 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-03-30 10:44:18 +0200
commit0b8cefd3b2385a21cfed779bd659978c0402766d (patch)
tree9c4753cc8a610c153fb64e99dd619f3b8f0fc4d8 /spec/factories/file_uploader.rb
parent701976e0815c273ff4a4c6e4d3489db0ce2f0860 (diff)
downloadgitlab-ce-0b8cefd3b2385a21cfed779bd659978c0402766d.tar.gz
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 it. Along with !3435 it may be easier to use uploaders in tests
Diffstat (limited to 'spec/factories/file_uploader.rb')
-rw-r--r--spec/factories/file_uploader.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/factories/file_uploader.rb b/spec/factories/file_uploader.rb
new file mode 100644
index 00000000000..69a4e6d28fb
--- /dev/null
+++ b/spec/factories/file_uploader.rb
@@ -0,0 +1,19 @@
+FactoryGirl.define do
+ factory :file_uploader, class: FileUploader do
+ project
+ secret nil
+
+ transient do
+ path { File.join(Rails.root, 'spec/fixtures/rails_sample.jpg') }
+ file { Rack::Test::UploadedFile.new(path) }
+ end
+
+ after(:build) do |uploader, evaluator|
+ uploader.store!(evaluator.file)
+ end
+
+ initialize_with do
+ new(project, secret)
+ end
+ end
+end