Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 46 lines (41 sloc) 2.441 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
Feature: Mount an Uploader on ActiveRecord class
In order to easily attach files to a form
As a web developer using CarrierWave
I want to mount an uploader on an ActiveRecord class

Background:
Given an uploader class that uses the 'file' storage
And a datamapper class that has a 'avatar' column
And the uploader class is mounted on the 'avatar' column
And an instance of the datamapper class

Scenario: assign a file
When I assign the file 'fixtures/bork.txt' to the 'avatar' column
Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'

Scenario: assign a file and save the record
When I assign the file 'fixtures/bork.txt' to the 'avatar' column
And I save the datamapper record
Then there should be a file at 'public/uploads/bork.txt'
And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
And the url for the column 'avatar' should be '/uploads/bork.txt'

Scenario: assign a file and retrieve it from cache
When I assign the file 'fixtures/bork.txt' to the 'avatar' column
And I retrieve the file later from the cache name for the column 'avatar'
And I save the datamapper record
Then there should be a file at 'public/uploads/bork.txt'
And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
And the url for the column 'avatar' should be '/uploads/bork.txt'

# Scenario: store a file and retrieve it later
# When I assign the file 'fixtures/bork.txt' to the 'avatar' column
# And I retrieve the file later from the cache name for the column 'avatar'
# And I save the datamapper record
# Then there should be a file at 'public/uploads/bork.txt'
# When I reload the datamapper record
# Then the url for the column 'avatar' should be '/uploads/bork.txt'
#
# Scenario: store a file and delete the record
# When I assign the file 'fixtures/bork.txt' to the 'avatar' column
# And I retrieve the file later from the cache name for the column 'avatar'
# And I save the datamapper record
# Then there should be a file at 'public/uploads/bork.txt'
# When I delete the datamapper record
# Then there should not be a file at 'public/uploads/bork.txt'
Something went wrong with that request. Please try again.