saviour 0.4.1 → 0.4.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d67c7eda9780fbf27c6fe5c4c1b621839b81b82a
4
- data.tar.gz: 634ea69a334a72f9690fbc1102dd7ea6b98f3683
3
+ metadata.gz: 2f139cd5d0f7a94b708562c66d560bd070ad4905
4
+ data.tar.gz: d1723105df9ab846a9010b7b5eeb8714ab6bcd5f
5
5
  SHA512:
6
- metadata.gz: 3df7814a85bd316abe2d2a0c82436fdc66bec1860867344faccd834b581d38a81dc9172ba61eff57ffe649d068ede726d1e25ef652a6a4ef8738bc63c4765c64
7
- data.tar.gz: 67b818e120b6f389fecebb883fdc3df26cd2f536222d7e10f0a2ed53b1b22ec0cc43a8f023193ec19129e3407e31d108697931d44375ab67c57ff3245756a2cd
6
+ metadata.gz: bb57633ae2b99c891564f8331f0630c025385f9f9dc644a0e46c5713be2ac08a6102e4e32189918d5c3983acf0d423ec6f9a0edd0eb991ae2e597985a887842f
7
+ data.tar.gz: 250807a0557c9683d0a4953cd666b8b54d988377367af5e2383ba93dd1ee09a79ffd649b636cc3dc50731611a96512be958de171923790b0019b37feacac671f
@@ -36,7 +36,7 @@ module Saviour
36
36
  new_file = ::Saviour::File.new(uploader_klass, self, attach_as)
37
37
 
38
38
  layer = persistence_klass.new(self)
39
- new_file.set_path!(layer.read(attach_as)) if layer.persisted?
39
+ new_file.set_path!(layer.read(attach_as))
40
40
 
41
41
  instance_variable_set("@__uploader_#{attach_as}", new_file)
42
42
  end
@@ -9,7 +9,7 @@ module Saviour
9
9
  end
10
10
 
11
11
  def write(contents, path)
12
- raise(RuntimeError, "The path you're trying to write already exists!") if @overwrite_protection && exists?(path)
12
+ raise(RuntimeError, "The path you're trying to write already exists! (#{path})") if @overwrite_protection && exists?(path)
13
13
 
14
14
  dir = ::File.dirname(real_path(path))
15
15
  FileUtils.mkdir_p(dir) unless ::File.directory?(dir)
@@ -1,4 +1,7 @@
1
- require 'fog/aws'
1
+ begin
2
+ require 'fog/aws'
3
+ rescue LoadError
4
+ end
2
5
 
3
6
  module Saviour
4
7
  class S3Storage
@@ -1,3 +1,3 @@
1
1
  module Saviour
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
data/lib/saviour.rb CHANGED
@@ -13,5 +13,7 @@ require 'saviour/life_cycle'
13
13
  require 'saviour/persistence_layer'
14
14
  require 'saviour/validator'
15
15
 
16
+ require 'tempfile'
17
+
16
18
  module Saviour
17
19
  end
@@ -140,4 +140,21 @@ describe "saving a new file" do
140
140
  end
141
141
  end
142
142
  end
143
+
144
+ describe "dupping" do
145
+ it "maintains file access" do
146
+ with_test_file("example.xml") do |example|
147
+ a = klass.create!
148
+ a.update_attributes(file: example)
149
+
150
+ expect(Saviour::Config.storage.exists?(a[:file])).to be_truthy
151
+
152
+ b = a.dup
153
+ expect(b).to_not be_persisted
154
+
155
+ expect(b.file?).to be true
156
+ expect(b.file.url).to eq a.file.url
157
+ end
158
+ end
159
+ end
143
160
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saviour
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roger Campos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-18 00:00:00.000000000 Z
11
+ date: 2017-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
214
  version: '0'
215
215
  requirements: []
216
216
  rubyforge_project:
217
- rubygems_version: 2.5.1
217
+ rubygems_version: 2.5.2
218
218
  signing_key:
219
219
  specification_version: 4
220
220
  summary: File storage handler following active record model lifecycle