refinerycms-resources 2.1.5 → 3.0.0

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.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/refinery/admin/resources_controller.rb +41 -17
  3. data/app/models/refinery/resource.rb +20 -9
  4. data/app/views/refinery/admin/resources/_actions.html.erb +2 -4
  5. data/app/views/refinery/admin/resources/_existing_resource.html.erb +1 -1
  6. data/app/views/refinery/admin/resources/_form.html.erb +18 -9
  7. data/app/views/refinery/admin/resources/_records.html.erb +3 -3
  8. data/app/views/refinery/admin/resources/_resource.html.erb +31 -16
  9. data/app/views/refinery/admin/resources/insert.html.erb +1 -1
  10. data/config/locales/ca.yml +36 -0
  11. data/config/locales/cs.yml +3 -4
  12. data/config/locales/en.yml +3 -0
  13. data/config/locales/fr.yml +3 -0
  14. data/config/locales/id.yml +36 -0
  15. data/config/locales/it.yml +6 -16
  16. data/config/routes.rb +1 -1
  17. data/db/migrate/20150430180959_add_translated_title_to_refinery_resources.rb +11 -0
  18. data/lib/generators/refinery/resources/templates/config/initializers/refinery/resources.rb.erb +1 -2
  19. data/lib/refinery/resources.rb +4 -1
  20. data/lib/refinery/resources/configuration.rb +12 -4
  21. data/lib/refinery/resources/dragonfly.rb +33 -25
  22. data/lib/refinery/resources/engine.rb +2 -3
  23. data/license.md +1 -1
  24. data/refinerycms-resources.gemspec +7 -4
  25. data/spec/factories/resource.rb +1 -1
  26. data/spec/features/refinery/admin/resources_spec.rb +53 -30
  27. data/spec/lib/generators/refinery/resources/resources_generator_spec.rb +1 -1
  28. data/spec/lib/resources_spec.rb +15 -11
  29. data/spec/models/refinery/resource_spec.rb +54 -25
  30. metadata +36 -14
  31. data/app/helpers/refinery/admin/resources_helper.rb +0 -6
@@ -1,80 +1,109 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Refinery
4
- describe Resource do
4
+ describe Resource, :type => :model do
5
5
  let(:resource) { FactoryGirl.create(:resource) }
6
+ let(:titled_resource) { FactoryGirl.create(:resource, resource_title: 'Resource Title')}
6
7
 
7
8
  context "with valid attributes" do
8
9
  it "should create successfully" do
9
- resource.errors.should be_empty
10
+ expect(resource.errors).to be_empty
10
11
  end
11
12
  end
12
13
 
13
14
  context "resource url" do
14
15
  it "should respond to .url" do
15
- resource.should respond_to(:url)
16
+ expect(resource).to respond_to(:url)
16
17
  end
17
18
 
18
19
  it "should not support thumbnailing like images do" do
19
- resource.should_not respond_to(:thumbnail)
20
+ expect(resource).not_to respond_to(:thumbnail)
20
21
  end
21
22
 
22
23
  it "should contain its filename at the end" do
23
- resource.url.split('/').last.should == resource.file_name
24
+ expect(resource.url.split('/').last).to match(/\A#{resource.file_name}/)
25
+ end
26
+
27
+ context "when Dragonfly.verify_urls is true" do
28
+ before do
29
+ allow(Refinery::Resources).to receive(:dragonfly_verify_urls).and_return(true)
30
+ ::Refinery::Resources::Dragonfly.configure!
31
+ end
32
+
33
+ it "returns a url with an SHA parameter" do
34
+ expect(resource.url).to match(/\?sha=[\da-fA-F]{16}\z/)
35
+ end
36
+ end
37
+
38
+ context "when Dragonfly.verify_urls is false" do
39
+ before do
40
+ allow(Refinery::Resources).to receive(:dragonfly_verify_urls).and_return(false)
41
+ ::Refinery::Resources::Dragonfly.configure!
42
+ end
43
+ it "returns a url without an SHA parameter" do
44
+ expect(resource.url).not_to match(/\?sha=[\da-fA-F]{16}\z/)
45
+ end
24
46
  end
25
47
  end
26
48
 
27
49
  describe "#type_of_content" do
28
50
  it "returns formated mime type" do
29
- resource.type_of_content.should == "text plain"
51
+ expect(resource.type_of_content).to eq("text plain")
30
52
  end
31
53
  end
32
54
 
33
55
  describe "#title" do
34
- it "returns a titleized version of the filename" do
35
- resource.title.should == "Refinery Is Awesome"
56
+ context 'when a specific title has not been given' do
57
+ it "returns a titleized version of the filename" do
58
+ expect(resource.title).to eq("Refinery Is Awesome")
59
+ end
60
+ end
61
+ context 'when a specific title has been given' do
62
+ it 'returns that title' do
63
+ expect(titled_resource.title).to eq('Resource Title')
64
+ end
36
65
  end
37
66
  end
38
67
 
39
68
  describe ".per_page" do
40
69
  context "dialog is true" do
41
70
  it "returns resource count specified by Resources.pages_per_dialog option" do
42
- Resource.per_page(true).should == Resources.pages_per_dialog
71
+ expect(Resource.per_page(true)).to eq(Resources.pages_per_dialog)
43
72
  end
44
73
  end
45
74
 
46
75
  context "dialog is false" do
47
76
  it "returns resource count specified by Resources.pages_per_admin_index constant" do
48
- Resource.per_page.should == Resources.pages_per_admin_index
77
+ expect(Resource.per_page).to eq(Resources.pages_per_admin_index)
49
78
  end
50
79
  end
51
80
  end
52
81
 
53
82
  describe ".create_resources" do
54
- let(:file) { Refinery.roots(:'refinery/resources').join("spec/fixtures/refinery_is_awesome.txt") }
83
+ let(:file) { Refinery.roots('refinery/resources').join("spec/fixtures/refinery_is_awesome.txt") }
55
84
 
56
85
  context "only one resource uploaded" do
57
86
  it "returns an array containing one resource" do
58
- Resource.create_resources(:file => file).should have(1).item
87
+ expect(Resource.create_resources(:file => file).size).to eq(1)
59
88
  end
60
89
  end
61
90
 
62
91
  context "many resources uploaded at once" do
63
92
  it "returns an array containing all those resources" do
64
- Resource.create_resources(:file => [file, file, file]).should have(3).items
93
+ expect(Resource.create_resources(:file => [file, file, file]).size).to eq(3)
65
94
  end
66
95
  end
67
96
 
68
97
  specify "each returned array item should be an instance of resource" do
69
98
  Resource.create_resources(:file => [file, file, file]).each do |r|
70
- r.should be_an_instance_of(Resource)
99
+ expect(r).to be_an_instance_of(Resource)
71
100
  end
72
101
  end
73
102
 
74
103
  specify "each returned array item should be passed form parameters" do
75
104
  params = {:file => [file, file, file], :fake_param => 'blah'}
76
105
 
77
- Resource.should_receive(:create).exactly(3).times.with({:file => file, :fake_param => 'blah'})
106
+ expect(Resource).to receive(:create).exactly(3).times.with({:file => file, :fake_param => 'blah'})
78
107
  Resource.create_resources(params)
79
108
  end
80
109
  end
@@ -82,33 +111,33 @@ module Refinery
82
111
  describe "validations" do
83
112
  describe "valid #file" do
84
113
  before do
85
- @file = Refinery.roots(:'refinery/resources').join("spec/fixtures/refinery_is_awesome.txt")
114
+ @file = Refinery.roots('refinery/resources').join("spec/fixtures/refinery_is_awesome.txt")
86
115
  Resources.max_file_size = (File.read(@file).size + 10)
87
116
  end
88
117
 
89
118
  it "should be valid when size does not exceed .max_file_size" do
90
- Resource.new(:file => @file).should be_valid
119
+ expect(Resource.new(:file => @file)).to be_valid
91
120
  end
92
121
  end
93
122
 
94
123
  describe "too large #file" do
95
124
  before do
96
- @file = Refinery.roots(:'refinery/resources').join("spec/fixtures/refinery_is_awesome.txt")
125
+ @file = Refinery.roots('refinery/resources').join("spec/fixtures/refinery_is_awesome.txt")
97
126
  Resources.max_file_size = (File.read(@file).size - 10)
98
127
  @resource = Resource.new(:file => @file)
99
128
  end
100
129
 
101
130
  it "should not be valid when size exceeds .max_file_size" do
102
- @resource.should_not be_valid
131
+ expect(@resource).not_to be_valid
103
132
  end
104
133
 
105
134
  it "should contain an error message" do
106
135
  @resource.valid?
107
- @resource.errors.should_not be_empty
108
- @resource.errors[:file].should == Array(::I18n.t(
136
+ expect(@resource.errors).not_to be_empty
137
+ expect(@resource.errors[:file]).to eq(Array(::I18n.t(
109
138
  'too_big', :scope => 'activerecord.errors.models.refinery/resource',
110
139
  :size => Resources.max_file_size
111
- ))
140
+ )))
112
141
  end
113
142
  end
114
143
 
@@ -119,10 +148,10 @@ module Refinery
119
148
 
120
149
  it "has an error message" do
121
150
  @resource.valid?
122
- @resource.errors.should_not be_empty
123
- @resource.errors[:file].should == Array(::I18n.t(
151
+ expect(@resource.errors).not_to be_empty
152
+ expect(@resource.errors[:file]).to eq(Array(::I18n.t(
124
153
  'blank', :scope => 'activerecord.errors.models.refinery/resource'
125
- ))
154
+ )))
126
155
  end
127
156
  end
128
157
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.5
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Arndt
@@ -10,58 +10,77 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-11-07 00:00:00.000000000 Z
13
+ date: 2015-09-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: dragonfly
16
+ name: acts_as_indexed
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
19
  - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: 0.9.12
21
+ version: 0.8.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - "~>"
27
27
  - !ruby/object:Gem::Version
28
- version: 0.9.12
28
+ version: 0.8.0
29
29
  - !ruby/object:Gem::Dependency
30
- name: acts_as_indexed
30
+ name: dragonfly
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - "~>"
34
34
  - !ruby/object:Gem::Version
35
- version: 0.8.0
35
+ version: 1.0.0
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: 0.8.0
42
+ version: 1.0.0
43
+ - !ruby/object:Gem::Dependency
44
+ name: globalize
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 4.0.0
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '5.2'
53
+ type: :runtime
54
+ prerelease: false
55
+ version_requirements: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 4.0.0
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '5.2'
43
63
  - !ruby/object:Gem::Dependency
44
64
  name: refinerycms-core
45
65
  requirement: !ruby/object:Gem::Requirement
46
66
  requirements:
47
67
  - - '='
48
68
  - !ruby/object:Gem::Version
49
- version: 2.1.5
69
+ version: 3.0.0
50
70
  type: :runtime
51
71
  prerelease: false
52
72
  version_requirements: !ruby/object:Gem::Requirement
53
73
  requirements:
54
74
  - - '='
55
75
  - !ruby/object:Gem::Version
56
- version: 2.1.5
76
+ version: 3.0.0
57
77
  description: Handles all file upload and processing functionality in Refinery CMS.
58
- email: info@refinerycms.com
78
+ email: refinerycms@p.arndt.io
59
79
  executables: []
60
80
  extensions: []
61
81
  extra_rdoc_files: []
62
82
  files:
63
83
  - app/controllers/refinery/admin/resources_controller.rb
64
- - app/helpers/refinery/admin/resources_helper.rb
65
84
  - app/models/refinery/resource.rb
66
85
  - app/views/refinery/admin/resources/_actions.html.erb
67
86
  - app/views/refinery/admin/resources/_existing_resource.html.erb
@@ -74,6 +93,7 @@ files:
74
93
  - app/views/refinery/admin/resources/insert.html.erb
75
94
  - app/views/refinery/admin/resources/new.html.erb
76
95
  - config/locales/bg.yml
96
+ - config/locales/ca.yml
77
97
  - config/locales/cs.yml
78
98
  - config/locales/da.yml
79
99
  - config/locales/de.yml
@@ -83,6 +103,7 @@ files:
83
103
  - config/locales/fi.yml
84
104
  - config/locales/fr.yml
85
105
  - config/locales/hu.yml
106
+ - config/locales/id.yml
86
107
  - config/locales/it.yml
87
108
  - config/locales/ja.yml
88
109
  - config/locales/ko.yml
@@ -105,6 +126,7 @@ files:
105
126
  - config/locales/zh-TW.yml
106
127
  - config/routes.rb
107
128
  - db/migrate/20100913234709_create_refinerycms_resources_schema.rb
129
+ - db/migrate/20150430180959_add_translated_title_to_refinery_resources.rb
108
130
  - lib/generators/refinery/resources/resources_generator.rb
109
131
  - lib/generators/refinery/resources/templates/config/initializers/refinery/resources.rb.erb
110
132
  - lib/refinery/resources.rb
@@ -135,7 +157,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
157
  requirements:
136
158
  - - ">="
137
159
  - !ruby/object:Gem::Version
138
- version: '0'
160
+ version: 2.0.0
139
161
  required_rubygems_version: !ruby/object:Gem::Requirement
140
162
  requirements:
141
163
  - - ">="
@@ -143,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
165
  version: '0'
144
166
  requirements: []
145
167
  rubyforge_project: refinerycms
146
- rubygems_version: 2.2.2
168
+ rubygems_version: 2.4.5.1
147
169
  signing_key:
148
170
  specification_version: 4
149
171
  summary: Resources extension for Refinery CMS
@@ -1,6 +0,0 @@
1
- module Refinery
2
- module Admin
3
- module ResourcesHelper
4
- end
5
- end
6
- end