expiring_asset_links 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -8,14 +8,25 @@ This is helpful when using a WYSIWYG that inserts and previews assets directly f
8
8
 
9
9
  ## Installation
10
10
 
11
- gem install expiring_asset_links
11
+ gem install expiring_asset_links
12
12
 
13
13
  ## Usage
14
14
 
15
- ### Your model
15
+ ### name your uploader mount `:asset`
16
+
17
+ class Images
18
+ mount_uploader :asset, ImageUploader
19
+
20
+ end
21
+
22
+ ### specify the fields that will contain :asset links
16
23
 
17
24
  class Document
18
25
  attr_expiring_asset_links :body
19
26
 
20
27
  end
21
-
28
+
29
+ class Article
30
+ attr_expiring_asset_links :summary, :body
31
+
32
+ end
@@ -3,7 +3,7 @@ module ExpiringAssetLinks
3
3
  module Version
4
4
  MAJOR = 1
5
5
  MINOR = 1
6
- PATCH = 2
6
+ PATCH = 3
7
7
 
8
8
  # Returns a version string by joining <tt>MAJOR</tt>, <tt>MINOR</tt>, and <tt>PATCH</tt> with <tt>'.'</tt>
9
9
  #
@@ -17,16 +17,14 @@ class ExpiringAssetLinksTest < Test::Unit::TestCase
17
17
  config.fog_directory = "test"
18
18
  # config.fog_public = false
19
19
  end
20
-
21
-
22
20
  end
23
21
 
24
22
  def test_should_assert_true
25
- document = Document.new(:title => "This is the Document Title", :body => "<h2>Section One</h2><p>This is the first section in the body of the document. It includes an image.</p><img src=\"https://test.s3-us-east-1.amazonaws.com/uploads/test/file_attachment/asset/1/sample.jpg?AWSAccessKeyId=XXXXXXXXXXXXXXXXXXXX&amp;Signature=XXXXXXXXXXXXXXXXXXXXXXXXXXX%3D&amp;Expires=2222222222\">")
26
- document.save!
27
- # if we had a actual FileAttachment object it would connect to AWS to get a real URL
28
- # to make this work in testing we need to stub CarrierWave
29
- assert_equal "<h2>Section One</h2><p>This is the first section in the body of the document. It includes an image.</p><img src=\"FileAttachment{{\\1}}\">", Document.first.body
23
+ file_attachment = FileAttachment.create(name: "test", asset: AssetUploader.new("https://test.s3-us-east-1.amazonaws.com/uploads/test/file_attachment/asset/1/sample.jpg"))
24
+ document = Document.create(title: "This is the Document Title", body: "<h2>Section One</h2><p>This is the first section in the body of the document. It includes an image.</p><img src=\"#{file_attachment.asset.url}\">")
25
+
26
+ assert_equal "<h2>Section One</h2><p>This is the first section in the body of the document. It includes an image.</p><img src=\"FileAttachment{{1}}\">", Document.find(document.id).attributes["body"]
27
+ assert_equal "<h2>Section One</h2><p>This is the first section in the body of the document. It includes an image.</p><img src=\"https://test.s3-us-east-1.amazonaws.com/uploads/test/file_attachment/asset/1/sample.jpg?AWSAccessKeyId=XXXXXXXXXXXXXXXXXXXX&amp;Signature=XXXXXXXXXXXXXXXXXXXXXXXXXXX%3D&amp;Expires=2222222222\">", Document.find(document.id).body
30
28
  end
31
29
 
32
30
  end
data/test/test_helper.rb CHANGED
@@ -19,18 +19,32 @@ ActiveRecord::Schema.define(:version => 1) do
19
19
  end
20
20
  create_table :file_attachments do |t|
21
21
  t.integer :id
22
- t.integer :url
22
+ t.integer :name
23
+ t.binary :asset
23
24
  end
24
25
  create_table :image_attachments do |t|
25
26
  t.integer :id
26
- t.integer :url
27
+ t.integer :name
28
+ t.binary :asset
27
29
  end
28
30
  end
29
31
 
30
32
  class Document < ActiveRecord::Base
31
33
  attr_expiring_asset_links :body
32
34
  end
35
+
33
36
  class FileAttachment < ActiveRecord::Base
37
+ serialize :asset
34
38
  end
39
+
35
40
  class ImageAttachment < ActiveRecord::Base
41
+ serialize :asset
42
+ end
43
+
44
+ class AssetUploader < Struct.new(:my_url)
45
+ def url(*ignore)
46
+ "#{self.my_url}?AWSAccessKeyId=XXXXXXXXXXXXXXXXXXXX&amp;Signature=XXXXXXXXXXXXXXXXXXXXXXXXXXX%3D&amp;Expires=2222222222"
47
+ end
36
48
  end
49
+
50
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expiring_asset_links
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: