forked from thoughtbot/paperclip
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated railtie to remove AR reference
- Loading branch information
Showing
53 changed files
with
1,286 additions
and
431 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,7 @@ tmp | |
test/s3.yml | ||
public | ||
paperclip*.gem | ||
capybara*.html | ||
*.rbc | ||
.bundle | ||
*SPIKE* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
appraise "rails2" do | ||
gem "rails", "~>2.3.0" | ||
end | ||
|
||
appraise "rails3" do | ||
gem "rails", "~>3.0.0" | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
source "http://rubygems.org" | ||
gem "shoulda" | ||
gem "mocha" | ||
gem "rake" | ||
gem "ruby-debug" | ||
gem "aws-s3", :require => "aws/s3" | ||
gem "sqlite3-ruby", "~>1.3.0" | ||
gem "appraisal" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
appraisal (0.1) | ||
bundler | ||
rake | ||
aws-s3 (0.6.2) | ||
builder | ||
mime-types | ||
xml-simple | ||
builder (3.0.0) | ||
columnize (0.3.2) | ||
linecache (0.43) | ||
mime-types (1.16) | ||
mocha (0.9.9) | ||
rake | ||
rake (0.8.7) | ||
ruby-debug (0.10.4) | ||
columnize (>= 0.1) | ||
ruby-debug-base (~> 0.10.4.0) | ||
ruby-debug-base (0.10.4) | ||
linecache (>= 0.3) | ||
shoulda (2.11.3) | ||
sqlite3-ruby (1.3.2) | ||
xml-simple (1.0.12) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
appraisal | ||
aws-s3 | ||
mocha | ||
rake | ||
ruby-debug | ||
shoulda | ||
sqlite3-ruby (~> 1.3.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Feature: Running paperclip in a Rails app | ||
|
||
Scenario: Basic utilization | ||
Given I have a rails application | ||
And I save the following as "app/models/user.rb" | ||
""" | ||
class User < ActiveRecord::Base | ||
has_attached_file :avatar | ||
end | ||
""" | ||
When I visit /users/new | ||
And I fill in "user_name" with "something" | ||
And I attach the file "test/fixtures/5k.png" to "user_avatar" | ||
And I press "Submit" | ||
Then I should see "Name: something" | ||
And I should see an image with a path of "/system/avatars/1/original/5k.png" | ||
And the file at "/system/avatars/1/original/5k.png" is the same as "test/fixtures/5k.png" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Feature: Running paperclip in a Rails app using basic S3 support | ||
|
||
Scenario: Basic utilization | ||
Given I have a rails application | ||
And I save the following as "app/models/user.rb" | ||
""" | ||
class User < ActiveRecord::Base | ||
has_attached_file :avatar, | ||
:storage => :s3, | ||
:path => "/:attachment/:id/:style/:filename", | ||
:s3_credentials => Rails.root.join("config/s3.yml") | ||
end | ||
""" | ||
And I validate my S3 credentials | ||
And I save the following as "config/s3.yml" | ||
""" | ||
bucket: <%= ENV['PAPERCLIP_TEST_BUCKET'] || 'paperclip' %> | ||
access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %> | ||
secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %> | ||
""" | ||
When I visit /users/new | ||
And I fill in "user_name" with "something" | ||
And I attach the file "test/fixtures/5k.png" to "user_avatar" | ||
And I press "Submit" | ||
Then I should see "Name: something" | ||
And I should see an image with a path of "http://s3.amazonaws.com/paperclip/avatars/1/original/5k.png" | ||
And the file at "http://s3.amazonaws.com/paperclip/avatars/1/original/5k.png" is the same as "test/fixtures/5k.png" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Then %r{I should see an image with a path of "([^"]*)"} do |path| | ||
page.should have_css("img[src^='#{path}']") | ||
end | ||
|
||
Then %r{^the file at "([^"]*)" is the same as "([^"]*)"$} do |web_file, path| | ||
expected = IO.read(path) | ||
actual = if web_file.match %r{^https?://} | ||
Net::HTTP.get(URI.parse(web_file)) | ||
else | ||
visit(web_file) | ||
page.body | ||
end | ||
actual.should == expected | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
Given "I have a rails application" do | ||
steps %{ | ||
Given I generate a rails application | ||
And this plugin is available | ||
And I have a "users" resource with "name:string" | ||
And I turn off class caching | ||
Given I save the following as "app/models/user.rb" | ||
""" | ||
class User < ActiveRecord::Base | ||
end | ||
""" | ||
And I save the following as "config/s3.yml" | ||
""" | ||
access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %> | ||
secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %> | ||
bucket: paperclip | ||
""" | ||
And I save the following as "app/views/users/new.html.erb" | ||
""" | ||
<% form_for @user, :html => { :multipart => true } do |f| %> | ||
<%= f.text_field :name %> | ||
<%= f.file_field :avatar %> | ||
<%= submit_tag "Submit" %> | ||
<% end %> | ||
""" | ||
And I save the following as "app/views/users/show.html.erb" | ||
""" | ||
<p>Name: <%= @user.name %></p> | ||
<p>Avatar: <%= image_tag @user.avatar.url %></p> | ||
""" | ||
And I run "script/generate paperclip user avatar" | ||
And the rails application is prepped and running | ||
} | ||
end | ||
|
||
Given %r{I generate a rails application} do | ||
FileUtils.rm_rf TEMP_ROOT | ||
FileUtils.mkdir_p TEMP_ROOT | ||
Dir.chdir(TEMP_ROOT) do | ||
`rails _2.3.8_ #{APP_NAME}` | ||
end | ||
end | ||
|
||
When %r{I save the following as "([^"]*)"} do |path, string| | ||
FileUtils.mkdir_p(File.join(CUC_RAILS_ROOT, File.dirname(path))) | ||
File.open(File.join(CUC_RAILS_ROOT, path), 'w') { |file| file.write(string) } | ||
end | ||
|
||
When %r{I turn off class caching} do | ||
Dir.chdir(CUC_RAILS_ROOT) do | ||
file = "config/environments/test.rb" | ||
config = IO.read(file) | ||
config.gsub!(%r{^\s*config.cache_classes.*$}, | ||
"config.cache_classes = false") | ||
File.open(file, "w"){|f| f.write(config) } | ||
end | ||
end | ||
|
||
When %r{the rails application is prepped and running$} do | ||
When "I reset the database" | ||
When "the rails application is running" | ||
end | ||
|
||
When %r{I reset the database} do | ||
When %{I run "rake db:drop db:create db:migrate"} | ||
end | ||
|
||
When %r{the rails application is running} do | ||
Dir.chdir(CUC_RAILS_ROOT) do | ||
require "config/environment" | ||
require "capybara/rails" | ||
end | ||
end | ||
|
||
When %r{this plugin is available} do | ||
$LOAD_PATH << "#{PROJECT_ROOT}/lib" | ||
require 'paperclip' | ||
When %{I save the following as "vendor/plugins/paperclip/rails/init.rb"}, | ||
IO.read("#{PROJECT_ROOT}/rails/init.rb") | ||
end | ||
|
||
When %r{I run "([^"]*)"} do |command| | ||
Dir.chdir(CUC_RAILS_ROOT) do | ||
`#{command}` | ||
end | ||
end | ||
|
||
When %r{I have a "([^"]*)" resource with "([^"]*)"} do |resource, fields| | ||
When %{I run "script/generate scaffold #{resource} #{fields}"} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Given /I validate my S3 credentials/ do | ||
key = ENV['AWS_ACCESS_KEY_ID'] | ||
secret = ENV['AWS_SECRET_ACCESS_KEY'] | ||
|
||
key.should_not be_nil | ||
secret.should_not be_nil | ||
|
||
assert_credentials(key, secret) | ||
end |
Oops, something went wrong.