locomotive_cms 0.0.2.7 → 0.0.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/Gemfile +29 -27
  2. data/LICENSE +21 -0
  3. data/README.textile +23 -3
  4. data/app/controllers/admin/theme_assets_controller.rb +1 -0
  5. data/app/helpers/admin/base_helper.rb +1 -1
  6. data/app/helpers/admin/custom_fields_helper.rb +1 -1
  7. data/app/models/content_type.rb +1 -1
  8. data/app/models/extensions/page/tree.rb +3 -3
  9. data/app/models/layout.rb +2 -3
  10. data/app/models/theme_asset.rb +2 -2
  11. data/app/uploaders/asset_uploader.rb +2 -0
  12. data/app/uploaders/theme_asset_uploader.rb +1 -1
  13. data/app/views/admin/custom_fields/_custom_form.html.haml +14 -1
  14. data/app/views/admin/mailer/confirmation_instructions.html.haml +8 -0
  15. data/app/views/admin/mailer/reset_password_instructions.html.haml +12 -0
  16. data/app/views/admin/mailer/unlock_instructions.html.haml +10 -0
  17. data/app/views/admin/shared/_footer.html.haml +2 -5
  18. data/app/views/admin/shared/_head.html.haml +2 -2
  19. data/app/views/admin/theme_assets/_form.html.haml +2 -2
  20. data/app/views/admin/theme_assets/index.html.haml +9 -0
  21. data/config/initializers/devise.rb +1 -1
  22. data/config/locales/admin_ui_en.yml +7 -2
  23. data/config/locales/admin_ui_fr.yml +348 -0
  24. data/config/locales/default_en.yml +4 -0
  25. data/config/locales/default_fr.yml +172 -1
  26. data/config/locales/devise.en.yml +47 -21
  27. data/config/locales/devise.fr.yml +67 -0
  28. data/lib/locomotive.rb +3 -0
  29. data/lib/locomotive/carrierwave.rb +3 -0
  30. data/lib/locomotive/carrierwave/base.rb +15 -0
  31. data/{config/initializers/carrierwave.rb → lib/locomotive/carrierwave/patches.rb} +0 -1
  32. data/lib/locomotive/custom_fields.rb +18 -0
  33. data/lib/locomotive/engine.rb +1 -0
  34. data/lib/locomotive/httparty.rb +2 -0
  35. data/lib/locomotive/httparty/patches.rb +18 -0
  36. data/lib/locomotive/httparty/webservice.rb +24 -0
  37. data/lib/locomotive/liquid/drops/content.rb +3 -1
  38. data/lib/locomotive/liquid/filters/text.rb +16 -0
  39. data/lib/locomotive/liquid/tags/consume.rb +46 -0
  40. data/lib/locomotive/liquid/tags/nav.rb +60 -0
  41. data/lib/locomotive/liquid/tags/paginate.rb +2 -2
  42. data/lib/locomotive/liquid/tags/snippet.rb +2 -7
  43. data/lib/locomotive/mongoid.rb +2 -1
  44. data/{config/initializers/mongoid.rb → lib/locomotive/mongoid/patches.rb} +24 -0
  45. data/lib/locomotive/regexps.rb +1 -1
  46. data/public/images/admin/nocoffee.png +0 -0
  47. data/public/javascripts/admin/contents.js +3 -0
  48. data/public/javascripts/admin/locales/datepicker_fr.js +18 -0
  49. data/public/javascripts/admin/theme_assets.js +1 -1
  50. data/public/stylesheets/admin/formtastic_changes.css +14 -4
  51. data/public/stylesheets/admin/jquery/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  52. data/public/stylesheets/admin/jquery/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  53. data/public/stylesheets/admin/jquery/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  54. data/public/stylesheets/admin/jquery/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  55. data/public/stylesheets/admin/jquery/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  56. data/public/stylesheets/admin/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  57. data/public/stylesheets/admin/jquery/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  58. data/public/stylesheets/admin/jquery/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  59. data/public/stylesheets/admin/jquery/images/ui-icons_222222_256x240.png +0 -0
  60. data/public/stylesheets/admin/jquery/images/ui-icons_2e83ff_256x240.png +0 -0
  61. data/public/stylesheets/admin/jquery/images/ui-icons_454545_256x240.png +0 -0
  62. data/public/stylesheets/admin/jquery/images/ui-icons_888888_256x240.png +0 -0
  63. data/public/stylesheets/admin/jquery/images/ui-icons_cd0a0a_256x240.png +0 -0
  64. data/public/stylesheets/admin/jquery/ui.css +406 -0
  65. data/public/stylesheets/admin/layout.css +13 -9
  66. data/spec/factories.rb +1 -1
  67. data/spec/lib/locomotive/httparty/patches_spec.rb +19 -0
  68. data/spec/lib/locomotive/httparty/webservice_spec.rb +24 -0
  69. data/spec/lib/locomotive/liquid/filters/text_spec.rb +11 -0
  70. data/spec/lib/locomotive/liquid/tags/consume_spec.rb +40 -0
  71. data/spec/lib/locomotive/liquid/tags/nav_spec.rb +41 -0
  72. data/spec/models/asset_collections_spec.rb +5 -2
  73. data/spec/models/layout_spec.rb +2 -2
  74. data/spec/models/page_spec.rb +1 -1
  75. data/vendor/plugins/custom_fields/Gemfile +6 -5
  76. data/vendor/plugins/custom_fields/lib/custom_fields.rb +3 -0
  77. data/vendor/plugins/custom_fields/lib/custom_fields/field.rb +4 -2
  78. data/vendor/plugins/custom_fields/lib/custom_fields/types/category.rb +1 -1
  79. data/vendor/plugins/custom_fields/lib/custom_fields/types/date.rb +35 -0
  80. data/vendor/plugins/custom_fields/lib/custom_fields/types/default.rb +2 -2
  81. data/vendor/plugins/custom_fields/lib/custom_fields/types/file.rb +27 -0
  82. data/vendor/plugins/custom_fields/spec/fixtures/doc.txt +1 -0
  83. data/vendor/plugins/custom_fields/spec/integration/types/file_spec.rb +18 -0
  84. data/vendor/plugins/custom_fields/spec/spec_helper.rb +4 -8
  85. data/vendor/plugins/custom_fields/spec/support/carrierwave.rb +31 -0
  86. data/vendor/plugins/custom_fields/spec/support/mongoid.rb +6 -0
  87. data/vendor/plugins/custom_fields/spec/unit/types/date_spec.rb +59 -0
  88. data/vendor/plugins/custom_fields/spec/unit/types/file_spec.rb +23 -0
  89. metadata +82 -14
  90. data/app/views/devise/mailer/confirmation_instructions.html.haml +0 -8
  91. data/app/views/devise/mailer/reset_password_instructions.html.haml +0 -12
  92. data/app/views/devise/mailer/unlock_instructions.html.haml +0 -10
  93. data/lib/locomotive/patches.rb +0 -1
@@ -134,13 +134,23 @@ body {
134
134
  /* ___ footer ___ */
135
135
 
136
136
  #footer {
137
+ padding-top: 10px;
137
138
  background: transparent url(/images/admin/background/footer.png) no-repeat 0 0;
138
139
  }
139
140
 
140
141
  #footer p {
141
142
  padding: 15px 8px 0 0;
142
- font-size: 0.6em;
143
- color: #444;
143
+ font-size: 0.8em;
144
+ color: #E6E6E6;
145
+ }
146
+
147
+ #footer p a {
148
+ color: #1F82BC;
149
+ text-decoration: none;
150
+ }
151
+
152
+ #footer p a:hover {
153
+ text-decoration: underline;
144
154
  }
145
155
 
146
156
  /* ___ Alignements ___ */
@@ -166,10 +176,4 @@ body {
166
176
 
167
177
  /* ___ NoCoffee / Rails Tags ___ */
168
178
 
169
- a#nocoffee { text-decoration: none; font-size: 1.1em; line-height: 20px; color: #505b64; padding-right: 20px; margin: 0 4px; background: transparent url(../../images/admin/nocoffee.gif) no-repeat right 0px; }
170
- a#nocoffee em { color: #ef3f44; font-weight: normal; font-style: normal; }
171
-
172
- a#powered-by { text-decoration: none; font-size: 1.1em; color: #666; }
173
- a#powered-by:hover{ text-decoration: underline; color: #aaa; }
174
-
175
-
179
+ a#nocoffee { color: #b0b4c0 !important; text-decoration: none; line-height: 20px; padding-right: 20px; margin: 0 4px; background: transparent url(../../images/admin/nocoffee.png) no-repeat right 0px; }
@@ -44,7 +44,7 @@ Factory.define :layout do |l|
44
44
  <title>My website</title>
45
45
  </head>
46
46
  <body>
47
- <div id="sidebar">\{\{ content_for_sidebar "Left Sidebar"\}\}</div>
47
+ <div id="sidebar">\{\{ content_for_left_sidebar \}\}</div>
48
48
  <div id="main">\{\{ content_for_layout \}\}</div>
49
49
  </body>
50
50
  </html>}
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Httparty patches' do
4
+
5
+ describe 'Crack patch' do
6
+
7
+ context '#parsing json' do
8
+
9
+ it 'fixes an issue about json input beginning by a variable declaration' do
10
+ lambda {
11
+ Crack::JSON.parse('var json = { "foo": 42 };')
12
+ }.should_not raise_error
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe Locomotive::Httparty::Webservice do
4
+
5
+ context '#consuming' do
6
+
7
+ it 'sets the base uri from a simple url' do
8
+ Locomotive::Httparty::Webservice.expects(:get).with('/', { :base_uri => 'http://blog.locomotiveapp.org' })
9
+ Locomotive::Httparty::Webservice.consume('http://blog.locomotiveapp.org')
10
+ end
11
+
12
+ it 'sets both the base uri and the path from an url with parameters' do
13
+ Locomotive::Httparty::Webservice.expects(:get).with('/api/read/json?num=3', { :base_uri => 'http://blog.locomotiveapp.org' })
14
+ Locomotive::Httparty::Webservice.consume('http://blog.locomotiveapp.org/api/read/json?num=3')
15
+ end
16
+
17
+ it 'sets auth credentials' do
18
+ Locomotive::Httparty::Webservice.expects(:get).with('/', { :base_uri => 'http://blog.locomotiveapp.org', :basic_auth => { :username => 'john', :password => 'foo' } })
19
+ Locomotive::Httparty::Webservice.consume('http://blog.locomotiveapp.org', { :username => 'john', :password => 'foo' })
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Locomotive::Liquid::Filters::Text do
4
+
5
+ include Locomotive::Liquid::Filters::Text
6
+
7
+ it 'transforms a textile input into HTML' do
8
+ textile('This is *my* text.').should == "<p>This is <strong>my</strong> text.</p>"
9
+ end
10
+
11
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe Locomotive::Liquid::Tags::Consume do
4
+
5
+ context '#validating syntax' do
6
+
7
+ it 'validates a basic syntax' do
8
+ markup = 'blog from "http://blog.locomotiveapp.org"'
9
+ lambda do
10
+ Locomotive::Liquid::Tags::Consume.new('consume', markup, ["{% endconsume %}"])
11
+ end.should_not raise_error
12
+ end
13
+
14
+ it 'validates more complex syntax with attributes' do
15
+ markup = 'blog from "http://www.locomotiveapp.org" username: "john", password: "easyone"'
16
+ lambda do
17
+ Locomotive::Liquid::Tags::Consume.new('consume', markup, ["{% endconsume %}"])
18
+ end.should_not raise_error
19
+ end
20
+
21
+ it 'raises an error if the syntax is incorrect' do
22
+ markup = 'blog from http://www.locomotiveapp.org'
23
+ lambda do
24
+ Locomotive::Liquid::Tags::Consume.new('consume', markup, ["{% endconsume %}"])
25
+ end.should raise_error
26
+ end
27
+
28
+ end
29
+
30
+ context '#rendering' do
31
+
32
+ it 'puts the response into the liquid variable' do
33
+ Locomotive::Httparty::Webservice.stubs(:get).returns({ 'title' => 'Locomotive rocks !' })
34
+ template = "{% consume blog from \"http://blog.locomotiveapp.org/api/read\" %}{{ blog.title }}{% endconsume %}"
35
+ Liquid::Template.parse(template).render.should == 'Locomotive rocks !'
36
+ end
37
+
38
+ end
39
+
40
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe Locomotive::Liquid::Tags::Nav do
4
+
5
+ before(:each) do
6
+ @home = Factory.build(:page)
7
+ @home.stubs(:children).returns([
8
+ Page.new(:title => 'Child #1', :fullpath => 'child_1', :slug => 'child_1'),
9
+ Page.new(:title => 'Child #2', :fullpath => 'child_2', :slug => 'child_2')
10
+ ])
11
+ @home.children.last.stubs(:children).returns([
12
+ Page.new(:title => 'Child #2.1', :fullpath => 'child_2/sub_child_1', :slug => 'sub_child_1'),
13
+ Page.new(:title => 'Child #2.2', :fullpath => 'child_2/sub_child_2', :slug => 'sub_child_2')
14
+ ])
15
+ @site = Factory.build(:site)
16
+ @site.stubs(:pages).returns([@home])
17
+ end
18
+
19
+ context '#rendering' do
20
+
21
+ it 'renders from site' do
22
+ render_nav.should == '<ul id="nav"><li id="child-1" class="link"><a href="/child_1">Child #1</a></li><li id="child-2" class="link"><a href="/child_2">Child #2</a></li></ul>'
23
+ end
24
+
25
+ it 'renders from page' do
26
+ (page = @home.children.last.children.first).stubs(:parent).returns(@home.children.last)
27
+ output = render_nav 'page', { :page => page }
28
+ output.should == '<ul id="nav"><li id="sub-child-1" class="link on"><a href="/child_2/sub_child_1">Child #2.1</a></li><li id="sub-child-2" class="link"><a href="/child_2/sub_child_2">Child #2.2</a></li></ul>'
29
+ end
30
+
31
+ end
32
+
33
+ def render_nav(source = 'site', registers = {})
34
+ registers = { :site => @site, :page => @home }.merge(registers)
35
+ liquid_context = ::Liquid::Context.new({}, registers)
36
+
37
+ output = Liquid::Template.parse("{% nav #{source} %}").render(liquid_context)
38
+ output.gsub(/\n\s{0,}/, '')
39
+ end
40
+
41
+ end
@@ -15,6 +15,8 @@ describe AssetCollection do
15
15
  @collection = Factory.build(:asset_collection, :site => site)
16
16
  @collection.asset_custom_fields.build :label => 'My Description', :_alias => 'description', :kind => 'Text'
17
17
  @collection.asset_custom_fields.build :label => 'Active', :kind => 'Boolean'
18
+ # AssetCollection.collection.logger = Logger.new($stdout)
19
+ # AssetCollection.db.connection.instance_variable_set(:@logger, Logger.new($stdout))
18
20
  end
19
21
 
20
22
  context 'unit' do
@@ -156,10 +158,11 @@ describe AssetCollection do
156
158
  @collection.update_attributes(:asset_custom_fields_attributes => {
157
159
  '0' => { 'label' => 'My Description', 'kind' => 'Text', '_destroy' => "1" },
158
160
  '1' => { 'label' => 'Active', 'kind' => 'Boolean', '_destroy' => "0" },
159
- '2' => { 'label' => 'My Title !', 'kind' => 'String' }
161
+ '2' => { 'label' => 'My Title !', 'kind' => 'String' },
162
+ 'new_record' => { 'label' => 'Published at', 'kind' => 'String' }
160
163
  })
161
164
  @collection = AssetCollection.first
162
- @collection.asset_custom_fields.size.should == 1
165
+ @collection.asset_custom_fields.size.should == 2
163
166
  @collection.asset_custom_fields.first.label.should == 'My Title !'
164
167
  end
165
168
 
@@ -27,8 +27,8 @@ describe Layout do
27
27
  @layout.parts.first.name.should == 'Body'
28
28
  @layout.parts.first.slug.should == 'layout'
29
29
 
30
- @layout.parts.last.name.should == 'Left Sidebar'
31
- @layout.parts.last.slug.should == 'sidebar'
30
+ @layout.parts.last.name.should == 'Left sidebar'
31
+ @layout.parts.last.slug.should == 'left_sidebar'
32
32
  end
33
33
 
34
34
  it 'should not add parts to pages if layout does not change' do
@@ -293,7 +293,7 @@ describe Page do
293
293
  before(:each) do
294
294
  @page = Factory.build(:page, :site => nil)
295
295
  @page.parts.build :slug => 'layout', :value => 'Hello world !'
296
- @page.parts.build :slug => 'sidebar', :value => 'A sidebar...'
296
+ @page.parts.build :slug => 'left_sidebar', :value => 'A sidebar...'
297
297
  @page.send(:store_template)
298
298
  @layout = Factory.build(:layout, :site => nil)
299
299
  @layout.send(:store_template)
@@ -1,9 +1,10 @@
1
- source "http://gemcutter.org"
1
+ source 'http://gemcutter.org'
2
2
 
3
- gem "bson_ext", ">= 1.0.1"
4
- gem "mongo_ext"
5
- gem "mongoid", ">= 2.0.0.beta6"
6
- gem "activesupport", ">= 3.0.0.beta3"
3
+ gem 'bson_ext', '>= 1.0.1'
4
+ gem 'mongo_ext'
5
+ gem 'mongoid', '2.0.0.beta6'
6
+ gem 'activesupport', '3.0.0.beta3'
7
+ gem 'carrierwave-rails3', :require => 'carrierwave'
7
8
 
8
9
  group :test do
9
10
  gem 'rspec', '>= 2.0.0.beta.10'
@@ -1,6 +1,7 @@
1
1
  $:.unshift File.expand_path(File.dirname(__FILE__))
2
2
 
3
3
  require 'active_support'
4
+ require 'carrierwave/orm/mongoid'
4
5
 
5
6
  require 'custom_fields/extensions/mongoid/document'
6
7
  require 'custom_fields/extensions/mongoid/associations/proxy'
@@ -11,6 +12,8 @@ require 'custom_fields/types/string'
11
12
  require 'custom_fields/types/text'
12
13
  require 'custom_fields/types/category'
13
14
  require 'custom_fields/types/boolean'
15
+ require 'custom_fields/types/date'
16
+ require 'custom_fields/types/file'
14
17
  require 'custom_fields/proxy_class_enabler'
15
18
  require 'custom_fields/field'
16
19
  require 'custom_fields/custom_fields_for'
@@ -10,6 +10,8 @@ module CustomFields
10
10
  include Types::Text
11
11
  include Types::Category
12
12
  include Types::Boolean
13
+ include Types::Date
14
+ include Types::File
13
15
 
14
16
  ## fields ##
15
17
  field :label
@@ -26,13 +28,13 @@ module CustomFields
26
28
  ## methods ##
27
29
 
28
30
  def field_type
29
- self.class.field_types[self.kind.to_sym]
31
+ self.class.field_types[self.kind.downcase.to_sym]
30
32
  end
31
33
 
32
34
  def apply(klass)
33
35
  return unless self.valid?
34
36
 
35
- klass.field self._name, :type => self.field_type
37
+ klass.field self._name, :type => self.field_type if self.field_type
36
38
 
37
39
  apply_method_name = :"apply_#{self.kind.downcase}_type"
38
40
 
@@ -11,7 +11,7 @@ module CustomFields
11
11
 
12
12
  accepts_nested_attributes_for :category_items, :allow_destroy => true
13
13
 
14
- register_type :category, String
14
+ register_type :category, ::String
15
15
  end
16
16
 
17
17
  module InstanceMethods
@@ -0,0 +1,35 @@
1
+ module CustomFields
2
+ module Types
3
+ module Date
4
+
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ register_type :date, ::Date
9
+ end
10
+
11
+ module InstanceMethods
12
+
13
+ def apply_date_type(klass)
14
+
15
+ klass.class_eval <<-EOF
16
+ def #{self.safe_alias}
17
+ self.#{self._name}.strftime(I18n.t('date.formats.default')) rescue nil
18
+ end
19
+
20
+ def #{self.safe_alias}=(value)
21
+ if value.is_a?(String)
22
+ date = ::Date._strptime(value, I18n.t('date.formats.default'))
23
+ value = Date.new(date[:year], date[:mon], date[:mday])
24
+ end
25
+ self.#{self._name} = value
26
+ end
27
+ EOF
28
+
29
+ end
30
+
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -20,9 +20,9 @@ module CustomFields
20
20
 
21
21
  module ClassMethods
22
22
 
23
- def register_type(kind, klass = String)
23
+ def register_type(kind, klass = ::String)
24
24
  self.field_types ||= {}
25
- self.field_types[kind.to_sym] = klass
25
+ self.field_types[kind.to_sym] = klass unless klass.nil?
26
26
 
27
27
  self.class_eval <<-EOF
28
28
  def #{kind.to_s}?
@@ -0,0 +1,27 @@
1
+ module CustomFields
2
+ module Types
3
+ module File
4
+
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ register_type :file, nil # do not create the default field
9
+ end
10
+
11
+ module InstanceMethods
12
+
13
+ def apply_file_type(klass)
14
+
15
+ klass.mount_uploader self._name, FileUploader
16
+
17
+ self.apply_default_type(klass)
18
+ end
19
+
20
+ end
21
+
22
+ class FileUploader < ::CarrierWave::Uploader::Base
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe CustomFields::Types::File do
4
+
5
+ before(:each) do
6
+ @project = Project.new(:name => 'Locomotive')
7
+ @project.task_custom_fields.build(:label => 'Screenshot', :_alias => 'screenshot', :kind => 'File')
8
+ @project.save
9
+ @task = @project.tasks.build
10
+ end
11
+
12
+ it 'attaches file' do
13
+ @task.screenshot = FixturedFile.open('doc.txt')
14
+ @task.save
15
+ @task.screenshot.url.should == '/uploads/doc.txt'
16
+ end
17
+
18
+ end
@@ -1,7 +1,7 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
3
 
4
- MODELS = File.join(File.dirname(__FILE__), "models")
4
+ MODELS = File.join(File.dirname(__FILE__), 'models')
5
5
  $LOAD_PATH.unshift(MODELS)
6
6
 
7
7
  require 'rubygems'
@@ -16,16 +16,12 @@ require 'custom_fields'
16
16
 
17
17
  Dir[ File.join(MODELS, "*.rb") ].sort.each { |file| require File.basename(file) }
18
18
 
19
- Mongoid.configure do |config|
20
- name = "custom_fields_test"
21
- host = "localhost"
22
- config.master = Mongo::Connection.new.db(name)
23
- # config.master = Mongo::Connection.new('localhost', '27017', :logger => Logger.new($stdout)).db(name)
24
- end
19
+ require 'support/mongoid'
20
+ require 'support/carrierwave'
25
21
 
26
22
  Rspec.configure do |config|
27
23
  config.mock_with :mocha
28
24
  config.after :suite do
29
- Mongoid.master.collections.each(&:drop)
25
+ Mongoid.master.collections.select { |c| c.name != 'system.indexes' }.each(&:drop)
30
26
  end
31
27
  end
@@ -0,0 +1,31 @@
1
+ require 'carrierwave/test/matchers'
2
+
3
+ CarrierWave.configure do |config|
4
+ config.storage = :file
5
+ config.store_dir = "uploads"
6
+ config.cache_dir = "cache"
7
+ config.root = File.join(File.dirname(__FILE__), '..', 'tmp')
8
+ end
9
+
10
+ module FixturedFile
11
+ def self.open(filename)
12
+ File.new(self.path(filename))
13
+ end
14
+
15
+ def self.path(filename)
16
+ File.join(File.dirname(__FILE__), '..', 'fixtures', filename)
17
+ end
18
+
19
+ def self.duplicate(filename)
20
+ dst = File.join(File.dirname(__FILE__), '..', 'tmp', filename)
21
+ FileUtils.cp self.path(filename), dst
22
+ dst
23
+ end
24
+
25
+ def self.reset!
26
+ FileUtils.rm_rf(File.join(File.dirname(__FILE__), '..', 'tmp'))
27
+ FileUtils.mkdir(File.join(File.dirname(__FILE__), '..', 'tmp'))
28
+ end
29
+ end
30
+
31
+ FixturedFile.reset!