Permalink
Browse files

More development improvements

  • Loading branch information...
grantovich committed Nov 2, 2012
1 parent 97ba140 commit b792ac8359b209e489b55db421e303f7a7fe76f8
Showing with 547 additions and 538 deletions.
  1. +1 −1 .gitignore
  2. +1 −0 Rakefile
  3. +0 −5 spec/config.example.yml
  4. +0 −5 spec/dropbox.yml
  5. +5 −0 spec/dropbox.yml.example
  6. +13 −13 spec/paperclip/storage/dropbox_spec.rb
  7. +17 −4 spec/spec_helper.rb
  8. +21 −21 spec/vcr_cassettes/Paperclip_Storage_Dropbox/CUD/create/puts_the_file_on_Dropbox.yml
  9. +21 −21 spec/vcr_cassettes/Paperclip_Storage_Dropbox/CUD/create/raises_an_exception_on_same_filenames.yml
  10. +20 −20 spec/vcr_cassettes/Paperclip_Storage_Dropbox/CUD/destroy/deletes_the_uploaded_file.yml
  11. +16 −16 ...es/Paperclip_Storage_Dropbox/CUD/destroy/doesn_t_raise_errors_if_there_are_no_files_to_delete.yml
  12. +56 −56 ...r_cassettes/Paperclip_Storage_Dropbox/CUD/update/deletes_the_old_file_and_uploads_the_new_one.yml
  13. +20 −20 spec/vcr_cassettes/Paperclip_Storage_Dropbox/CUD/update/deletes_the_old_file_if_set_to_nil.yml
  14. +43 −43 spec/vcr_cassettes/Paperclip_Storage_Dropbox/_url/accepts_the_download_option.yml
  15. +33 −33 spec/vcr_cassettes/Paperclip_Storage_Dropbox/_url/defaults_to_original_size.yml
  16. +43 −43 spec/vcr_cassettes/Paperclip_Storage_Dropbox/_url/is_valid.yml
  17. +33 −33 spec/vcr_cassettes/Paperclip_Storage_Dropbox/_url/returns_nil_when_the_file_doesn_t_exist.yml
  18. +37 −37 ..._Dropbox/arguments_for_has_attached_file/dropbox_options/path/doesn_t_duplicate_the_extension.yml
  19. +37 −37 ...ropbox/arguments_for_has_attached_file/dropbox_options/path/has_the_original_filename_default.yml
  20. +41 −41 ...ions/path/puts_the_instance_in_the_scope_passes_the_style_and_appends_the_extension_and_style.yml
  21. +65 −65 ...ox/arguments_for_has_attached_file/dropbox_options/unique_filename/makes_the_file_path_unique.yml
  22. +24 −24 spec/vcr_cassettes/Paperclip_Storage_Dropbox/setter/handles_files_with_spaces_in_their_filename.yml
View
@@ -5,4 +5,4 @@ pkg/
tmp
.rspec
*.DS_Store
-spec/config.yml
+spec/dropbox.yml
View
@@ -1,6 +1,7 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
require "paperclip/dropbox/rake"
+import 'lib/paperclip/dropbox/tasks/authorize.rake'
Bundler.setup
View
@@ -1,5 +0,0 @@
-app_key: "your app key"
-app_secret: "your app secret"
-access_token: "your access token"
-access_token_secret: "your access token secret"
-user_id: "your user ID"
View
@@ -1,5 +0,0 @@
-app_key: <%= CONFIG[:app_key] %>
-app_secret: <%= CONFIG[:app_secret] %>
-access_token: <%= CONFIG[:access_token] %>
-access_token_secret: <%= CONFIG[:access_token_secret] %>
-user_id: <%= CONFIG[:user_id] %>
View
@@ -0,0 +1,5 @@
+app_key: ""
+app_secret: ""
+access_token: ""
+access_token_secret: ""
+user_id: ""
@@ -49,22 +49,22 @@ def set_options(options)
end
it "accepts a path to file" do
- set_options(dropbox_credentials: "#{RSPEC_DIR}/dropbox.yml")
+ set_options(dropbox_credentials: CREDENTIALS_FILE)
expect { User.new.avatar }.to_not raise_error(KeyError)
end
it "accepts an open file" do
- set_options(dropbox_credentials: File.open("#{RSPEC_DIR}/dropbox.yml"))
+ set_options(dropbox_credentials: File.open(CREDENTIALS_FILE))
expect { User.new.avatar }.to_not raise_error(KeyError)
end
it "accepts a hash" do
- set_options(dropbox_credentials: YAML.load(ERB.new(File.read("#{RSPEC_DIR}/dropbox.yml")).result))
+ set_options(dropbox_credentials: CREDENTIALS)
expect { User.new.avatar }.to_not raise_error(KeyError)
end
it "recognizes environments" do
- hash = YAML.load(ERB.new(File.read("#{RSPEC_DIR}/dropbox.yml")).result)
+ hash = YAML.load(ERB.new(File.read(CREDENTIALS_FILE)).result)
set_options(dropbox_credentials: {development: hash}, dropbox_options: {environment: "development"})
expect { User.new.avatar }.to_not raise_error(KeyError)
@@ -79,7 +79,7 @@ def set_options(options)
stub_const("User", Class.new(ActiveRecord::Base) do
has_attached_file :avatar,
storage: :dropbox,
- dropbox_credentials: "#{RSPEC_DIR}/dropbox.yml",
+ dropbox_credentials: CREDENTIALS_FILE,
dropbox_options: options,
styles: {medium: "300x300"}
end)
@@ -125,7 +125,7 @@ def set_options(options)
class User < ActiveRecord::Base
has_attached_file :avatar,
storage: :dropbox,
- dropbox_credentials: "#{RSPEC_DIR}/dropbox.yml"
+ dropbox_credentials: CREDENTIALS_FILE
end
end
@@ -136,15 +136,15 @@ class User < ActiveRecord::Base
"Public/photo_with_spaces.jpg".should_not be_on_dropbox
end
- after(:all) { Object.send(:remove_const, "User") }
+ after(:all) { Object.send(:remove_const, :User) }
end
describe "#url" do
before(:all) do
class User < ActiveRecord::Base
has_attached_file :avatar,
storage: :dropbox,
- dropbox_credentials: "#{RSPEC_DIR}/dropbox.yml",
+ dropbox_credentials: CREDENTIALS_FILE,
styles: {medium: "300x300"}
end
end
@@ -173,7 +173,7 @@ class User < ActiveRecord::Base
response.code.to_i.should == 200
end
- after(:each) { @user.destroy }
+ after(:each) { @user.destroy if not @user.nil? }
after(:all) { Object.send(:remove_const, :User) }
end
@@ -183,7 +183,7 @@ class User < ActiveRecord::Base
class User < ActiveRecord::Base
has_attached_file :avatar,
storage: :dropbox,
- dropbox_credentials: "#{RSPEC_DIR}/dropbox.yml"
+ dropbox_credentials: CREDENTIALS_FILE
end
end
@@ -198,7 +198,7 @@ class User < ActiveRecord::Base
expect { User.create(avatar: uploaded_file("photo.jpg", "image/jpeg")) }.to raise_error(Paperclip::Storage::Dropbox::FileExists)
end
- after(:each) { @user.destroy }
+ after(:each) { @user.destroy if not @user.nil? }
end
describe "update" do
@@ -216,7 +216,7 @@ class User < ActiveRecord::Base
"Public/another_photo.jpg".should be_on_dropbox
end
- after(:each) { @user.destroy }
+ after(:each) { @user.destroy if not @user.nil? }
end
describe "destroy" do
@@ -232,7 +232,7 @@ class User < ActiveRecord::Base
expect { @user.destroy }.to_not raise_error
end
- after(:each) { @user.destroy }
+ after(:each) { @user.destroy if not @user.nil? }
end
after(:all) do
View
@@ -6,7 +6,16 @@
RSPEC_DIR = File.expand_path(File.dirname(__FILE__))
Dir[File.join(RSPEC_DIR, "support/**/*.rb")].each { |f| require f }
-CONFIG = YAML.load(File.read("#{RSPEC_DIR}/config.yml")).symbolize_keys
+CREDENTIALS_FILE = "#{RSPEC_DIR}/dropbox.yml"
+
+if File.exists?(CREDENTIALS_FILE)
+ CREDENTIALS = YAML.load(ERB.new(File.read(CREDENTIALS_FILE)).result).symbolize_keys
+else
+ puts "\n### ERROR ###"
+ puts "Credential file not found at #{CREDENTIALS_FILE}"
+ puts "Copy dropbox.yml.example and fill in your app credentials.\n\n"
+ raise 'credential file not found'
+end
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
@@ -15,9 +24,13 @@
VCR.configure do |config|
config.cassette_library_dir = 'spec/vcr_cassettes'
config.hook_into :fakeweb
- config.default_cassette_options = {serialize_with: :syck}
- config.filter_sensitive_data('API_KEY') { CONFIG[:app_key] }
- config.filter_sensitive_data('ACCESS_TOKEN') { CONFIG[:app_secret] }
+ CREDENTIALS.keys.each do |key|
+ config.filter_sensitive_data("<#{key.to_s.upcase}>") { CREDENTIALS[key] }
+ end
+ config.default_cassette_options = {
+ serialize_with: :syck,
+ record: :new_episodes
+ }
config.configure_rspec_metadata!
config.allow_http_connections_when_no_cassette = true
end

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit b792ac8

Please sign in to comment.