diff --git a/app/helpers/filestack_rails/application_helper.rb b/app/helpers/filestack_rails/application_helper.rb
index 6be4472..39bb367 100644
--- a/app/helpers/filestack_rails/application_helper.rb
+++ b/app/helpers/filestack_rails/application_helper.rb
@@ -35,7 +35,7 @@ def filestack_image(url, options = {})
transform_object.add_external_url url
image_tag transform_object.fs_url, options
else
- image_tag url
+ image_tag url, options
end
end
diff --git a/filestack-rails.gemspec b/filestack-rails.gemspec
index 39d3c15..89d7fc6 100644
--- a/filestack-rails.gemspec
+++ b/filestack-rails.gemspec
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
s.add_dependency 'rails', '>= 4.0'
- s.add_dependency "filestack", '~> 2.6.0'
+ s.add_dependency "filestack", '~> 2.6.5'
s.add_development_dependency 'coveralls'
s.add_development_dependency 'sqlite3', '~> 1.3', '>= 1.3.6'
diff --git a/lib/filestack_rails/filestack_js.rb b/lib/filestack_rails/filestack_js.rb
index d2239da..4472a23 100644
--- a/lib/filestack_rails/filestack_js.rb
+++ b/lib/filestack_rails/filestack_js.rb
@@ -6,13 +6,17 @@ def initialize
end
def filestack_js_url
- "https://static.filestackapi.com/filestack-js/#{version}/filestack.min.js"
+ "https://static.#{domain}/filestack-js/#{version}/filestack.min.js"
end
def version
::Rails.application.config.filestack_rails.version
end
+ def domain
+ ::Rails.application.config.filestack_rails.cname || 'filestackapi.com'
+ end
+
def picker(client_name, api_key, options, callback, other_callbacks = nil)
options_string = options[1..-2] # removed curly brackets help to generate pickerOptions in js
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index 8406f4a..4a57fb1 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -39,11 +39,17 @@
end
describe "#filestack_image" do
- it "returns the correct tag" do
+ it "returns the image tag with transformation" do
image = filestack_image 'www.example.com', transform: filestack_transform.resize(width: 100, height: 100)
correct = '
'
expect(image).to eq(correct)
end
+
+ it "returns the image tag with attributes" do
+ image = filestack_image 'https://cdn.filestackcontent.com/7Djkxw9TPyEWdjxILnUQ', size: '16x10'
+ correct = '
'
+ expect(image).to eq(correct)
+ end
end
describe "#get_policy_and_signature" do
diff --git a/spec/lib/filestack_js_spec.rb b/spec/lib/filestack_js_spec.rb
index 4ca8c7c..547a6f5 100644
--- a/spec/lib/filestack_js_spec.rb
+++ b/spec/lib/filestack_js_spec.rb
@@ -59,5 +59,18 @@
expect(security).to eq({ security: { signature: signature, policy: policy } }.to_json)
end
end
+
+ context 'when cname is configured' do
+ before do
+ configuration.cname = 'fs.domain.com'
+ configuration.version = '3.x.x'
+ end
+
+ it 'returns filestack-js url with cname' do
+ expect(get_filestack_js.url).to eq(
+ "https://static.#{configuration.cname}/filestack-js/#{configuration.version}/filestack.min.js"
+ )
+ end
+ end
end
end