Skip to content

Commit 7dbf0dc

Browse files
committed
fixing tests
1 parent ad1153f commit 7dbf0dc

File tree

6 files changed

+38
-40
lines changed

6 files changed

+38
-40
lines changed

lib/s3-upnow.rb

+1-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,4 @@
88
require 's3-upnow/config_aws'
99
require 's3-upnow/form_helper'
1010
require 's3-upnow/engine' if defined?(Rails)
11-
require 's3-upnow/railtie' if defined?(Rails)
12-
13-
ActionView::Base.send(:include, S3UpNow::S3UpNowHelper) if defined?(ActionView::Base)
14-
ActionView::Helpers::FormBuilder.send(:include, S3UpNow::S3UpNowFieldHelper)
11+
require 's3-upnow/railtie' if defined?(Rails)

lib/s3-upnow/engine.rb

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
module S3UpNow
22
class Engine < ::Rails::Engine
3+
initializer "s3-upnow.setup", before: :load_environment_config do
4+
ActionView::Base.send(:include, S3UpNow::S3UpNowHelper) if defined?(ActionView::Base)
5+
ActionView::Helpers::FormBuilder.send(:include, S3UpNow::S3UpNowFieldHelper)
6+
end
37
end
48
end

spec/existance_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
require 'spec_helper'
22
describe S3UpNow do
33
it "version must be defined" do
4-
S3UpNow::VERSION.should be_true
4+
expect(S3UpNow::VERSION).to be
55
end
66

77
it "config must be defined" do
8-
S3UpNow.config.should be_true
8+
expect(S3UpNow.config).to be
99
end
1010

1111
end

spec/generator_spec.rb

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
require "spec_helper"
2+
3+
describe S3UpNow::Generator do
4+
describe "policy_data" do
5+
describe "starts-with $key" do
6+
it "is configurable with the key_starts_with option" do
7+
key_starts_with = "uploads/"
8+
generator = S3UpNow::Generator.new({:key_starts_with => key_starts_with})
9+
expect(generator.policy_data[:conditions]).to include ["starts-with", "$key", key_starts_with]
10+
end
11+
12+
it "defaults to 'uploads/'" do
13+
generator = S3UpNow::Generator.new({})
14+
expect(generator.policy_data[:conditions]).to include ["starts-with", "$key", "uploads/"]
15+
end
16+
end
17+
18+
describe "starts-with $content-type" do
19+
it "is configurable with the content_type_starts_with option" do
20+
content_type_starts_with = "image/"
21+
generator = S3UpNow::Generator.new({:content_type_starts_with => content_type_starts_with})
22+
expect(generator.policy_data[:conditions]).to include ["starts-with", "$content-type", content_type_starts_with]
23+
end
24+
25+
it "is defaults to an empty string" do
26+
generator = S3UpNow::Generator.new({})
27+
expect(generator.policy_data[:conditions]).to include ["starts-with", "$content-type", ""]
28+
end
29+
end
30+
end
31+
end

spec/helpers/form_helper_spec.rb

-33
This file was deleted.

spec/spec_helper.rb

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
require 's3-upnow'
33

44
RSpec.configure do |config|
5-
config.treat_symbols_as_metadata_keys_with_true_values = true
65
config.run_all_when_everything_filtered = true
76
config.filter_run :focus
87

0 commit comments

Comments
 (0)