paperclip-time-stamped 1.0.4 → 1.0.5

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/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.4
1
+ 1.0.5
@@ -1,5 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'active_record'
3
+ require 'paperclip'
3
4
 
4
5
  ActiveRecord::Base.class_eval do
5
6
 
@@ -22,7 +23,7 @@ ActiveRecord::Base.class_eval do
22
23
  end
23
24
 
24
25
  define_method("#{name}?") do |*style|
25
- style.empty? ? send(name).exists? : File.file?(send("#{name}_path", style.first))
26
+ send(name).exists? && (style.empty? || File.file?(send("#{name}_path", style.first)))
26
27
  end
27
28
 
28
29
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{paperclip-time-stamped}
8
- s.version = "1.0.4"
8
+ s.version = "1.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Marcin Nowicki"]
@@ -1,8 +1,11 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
  require 'active_record_connectionless'
3
3
 
4
+ Paperclip::Attachment::RAILS_ROOT = '/'
5
+
4
6
  class PaperclipTimeStamped < ActiveRecord::Base
5
7
 
8
+ has_attached_file :name, :styles => {:thumbnail=> "80x80>", :small => "180x180>"}, :path => '/'
6
9
  has_timestamped_paperclip_attachment :name
7
10
 
8
11
  end
@@ -28,17 +31,33 @@ describe "PaperclipTimeStamped" do
28
31
  end
29
32
 
30
33
  describe 'name?' do
31
- it 'should be delegated to name.exists? when there is no style given' do
32
- @name.should_receive(:exists?).and_return(true)
34
+ it 'should be true when name.exists? is true and no style given' do
33
35
  @paperclip_time_stamped.should_receive(:name).and_return(@name)
36
+ @name.should_receive(:exists?).and_return(true)
34
37
  @paperclip_time_stamped.name?.should be_true
35
38
  end
36
39
 
37
- it 'should return File.file? on given file with style when style given' do
40
+ it 'should be true when name.exists? is true and File.file? on given file with style is true' do
41
+ @paperclip_time_stamped.should_receive(:name).and_return(@name)
42
+ @name.should_receive(:exists?).and_return(true)
38
43
  File.should_receive(:file?).with('path').and_return(true)
39
44
  @paperclip_time_stamped.should_receive(:name_path).with(:small).and_return('path')
40
45
  @paperclip_time_stamped.name?(:small).should be_true
41
46
  end
47
+
48
+ it 'should be false when name.exists? is false' do
49
+ @paperclip_time_stamped.should_receive(:name).and_return(@name)
50
+ @name.should_receive(:exists?).and_return(false)
51
+ @paperclip_time_stamped.name?(:small).should be_false
52
+ end
53
+
54
+ it 'should be false when name.exists? is true but File.file? on given file with style is false' do
55
+ @name.should_receive(:exists?).and_return(true)
56
+ @paperclip_time_stamped.should_receive(:name).and_return(@name)
57
+ File.should_receive(:file?).with('path').and_return(false)
58
+ @paperclip_time_stamped.should_receive(:name_path).with(:small).and_return('path')
59
+ @paperclip_time_stamped.name?(:small).should be_false
60
+ end
42
61
  end
43
62
 
44
63
  describe 'name_timestamp' do
@@ -61,4 +80,8 @@ describe "PaperclipTimeStamped" do
61
80
  @paperclip_time_stamped.timestamped_name_url(:small).should == 'name_url?1000000000'
62
81
  end
63
82
 
83
+ it 'should work in normal environment' do
84
+ @paperclip_time_stamped.timestamped_name_url(:thumbnail)
85
+ end
86
+
64
87
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip-time-stamped
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Nowicki