alchemy_cms 3.1.3 → 3.2.0.beta

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 (110) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +2 -2
  3. data/.hound.yml +2 -0
  4. data/.rubocop.yml +1063 -0
  5. data/.travis.yml +14 -10
  6. data/Gemfile +4 -7
  7. data/README.md +16 -8
  8. data/alchemy_cms.gemspec +8 -7
  9. data/app/assets/javascripts/alchemy/alchemy.base.js.coffee +10 -11
  10. data/app/assets/javascripts/alchemy/alchemy.js +1 -1
  11. data/app/assets/stylesheets/alchemy/{admin.css.scss → admin.scss} +1 -0
  12. data/app/assets/stylesheets/alchemy/{icon-font.css.scss → icon-font.scss} +0 -0
  13. data/app/assets/stylesheets/alchemy/{menubar.css.scss → menubar.scss} +0 -0
  14. data/app/assets/stylesheets/alchemy/{print.css.scss → print.scss} +0 -0
  15. data/app/assets/stylesheets/alchemy/selects.scss +0 -6
  16. data/app/controllers/alchemy/admin/contents_controller.rb +3 -4
  17. data/app/controllers/alchemy/admin/pictures_controller.rb +0 -2
  18. data/app/controllers/alchemy/api/contents_controller.rb +1 -1
  19. data/app/controllers/alchemy/api/elements_controller.rb +2 -2
  20. data/app/controllers/alchemy/api/pages_controller.rb +1 -1
  21. data/app/controllers/alchemy/elements_controller.rb +0 -6
  22. data/app/controllers/alchemy/pages_controller.rb +17 -13
  23. data/app/controllers/alchemy/pictures_controller.rb +1 -0
  24. data/app/helpers/alchemy/admin/navigation_helper.rb +1 -1
  25. data/app/models/alchemy/element.rb +41 -17
  26. data/app/models/alchemy/page/page_naming.rb +16 -29
  27. data/bin/alchemy +1 -1
  28. data/config/routes.rb +1 -2
  29. data/db/migrate/20130827094554_alchemy_two_point_six.rb +0 -17
  30. data/lib/alchemy/capistrano.rb +3 -4
  31. data/lib/alchemy/controller_actions.rb +2 -1
  32. data/lib/alchemy/engine.rb +1 -0
  33. data/lib/alchemy/errors.rb +7 -0
  34. data/lib/alchemy/essence.rb +4 -4
  35. data/lib/alchemy/permissions.rb +1 -1
  36. data/lib/alchemy/shell.rb +26 -11
  37. data/lib/alchemy/test_support/controller_requests.rb +48 -12
  38. data/lib/alchemy/upgrader.rb +1 -0
  39. data/lib/alchemy/upgrader/three_point_one.rb +0 -1
  40. data/lib/alchemy/upgrader/three_point_two.rb +39 -0
  41. data/lib/alchemy/version.rb +1 -1
  42. data/lib/rails/templates/alchemy.rb +2 -2
  43. data/lib/tasks/alchemy/install.rake +2 -1
  44. data/spec/controllers/admin/attachments_controller_spec.rb +14 -14
  45. data/spec/controllers/admin/clipboard_controller_spec.rb +5 -5
  46. data/spec/controllers/admin/contents_controller_spec.rb +8 -14
  47. data/spec/controllers/admin/dashboard_controller_spec.rb +12 -12
  48. data/spec/controllers/admin/elements_controller_spec.rb +30 -31
  49. data/spec/controllers/admin/essence_files_controller_spec.rb +6 -6
  50. data/spec/controllers/admin/essence_pictures_controller_spec.rb +17 -17
  51. data/spec/controllers/admin/languages_controller_spec.rb +3 -3
  52. data/spec/controllers/admin/layoutpages_controller_spec.rb +3 -3
  53. data/spec/controllers/admin/pages_controller_spec.rb +48 -48
  54. data/spec/controllers/admin/pictures_controller_spec.rb +19 -19
  55. data/spec/controllers/admin/resources_controller_spec.rb +2 -2
  56. data/spec/controllers/admin/trash_controller_spec.rb +5 -5
  57. data/spec/controllers/alchemy/admin/tags_controller_spec.rb +5 -5
  58. data/spec/controllers/alchemy/api/contents_controller_spec.rb +46 -11
  59. data/spec/controllers/alchemy/api/elements_controller_spec.rb +42 -14
  60. data/spec/controllers/alchemy/api/pages_controller_spec.rb +26 -16
  61. data/spec/controllers/attachments_controller_spec.rb +7 -7
  62. data/spec/controllers/elements_controller_spec.rb +16 -19
  63. data/spec/controllers/messages_controller_spec.rb +15 -15
  64. data/spec/controllers/pages_controller_spec.rb +16 -25
  65. data/spec/controllers/pictures_controller_spec.rb +75 -49
  66. data/spec/dummy/Rakefile +1 -1
  67. data/spec/dummy/app/assets/stylesheets/application.css +5 -3
  68. data/spec/dummy/config/application.rb +11 -1
  69. data/spec/dummy/config/boot.rb +1 -1
  70. data/spec/dummy/config/environment.rb +1 -1
  71. data/spec/dummy/config/environments/development.rb +14 -2
  72. data/spec/dummy/config/environments/production.rb +18 -21
  73. data/spec/dummy/config/environments/test.rb +9 -4
  74. data/spec/dummy/config/initializers/assets.rb +11 -0
  75. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  76. data/spec/dummy/config/initializers/mime_types.rb +0 -1
  77. data/spec/dummy/config/initializers/session_store.rb +1 -1
  78. data/spec/dummy/config/secrets.yml +22 -0
  79. data/spec/dummy/db/migrate/20130827094554_alchemy_two_point_six.rb +380 -0
  80. data/spec/dummy/db/migrate/20130828121054_remove_do_not_index_from_alchemy_essence_texts.rb +5 -0
  81. data/spec/dummy/db/migrate/20130828121120_remove_do_not_index_from_alchemy_essence_richtexts.rb +5 -0
  82. data/spec/dummy/db/migrate/20130918201742_add_published_at_to_alchemy_pages.rb +5 -0
  83. data/spec/dummy/db/migrate/20150122213511_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb +31 -0
  84. data/{db/migrate/20140107192720_add_missing_unique_indices_to_tags_and_taggings.rb → spec/dummy/db/migrate/20150122213512_add_missing_unique_indices.acts_as_taggable_on_engine.rb} +5 -6
  85. data/{db/migrate/20140701160159_add_taggings_counter_cache_to_tags.rb → spec/dummy/db/migrate/20150122213513_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb} +2 -1
  86. data/{db/migrate/20140701160225_add_missing_taggable_index.rb → spec/dummy/db/migrate/20150122213514_add_missing_taggable_index.acts_as_taggable_on_engine.rb} +1 -0
  87. data/spec/dummy/db/schema.rb +27 -31
  88. data/spec/dummy/public/404.html +20 -11
  89. data/spec/dummy/public/422.html +20 -11
  90. data/spec/dummy/public/500.html +19 -10
  91. data/spec/features/admin/page_creation_feature_spec.rb +2 -2
  92. data/spec/libraries/resource_spec.rb +1 -1
  93. data/spec/libraries/shell_spec.rb +2 -0
  94. data/spec/models/page_spec.rb +1 -13
  95. data/spec/spec_helper.rb +6 -4
  96. data/spec/support/rspec-activemodel-mocks_patch.rb +8 -0
  97. metadata +63 -56
  98. data/app/controllers/alchemy/contents_controller.rb +0 -18
  99. data/spec/controllers/contents_controller_spec.rb +0 -22
  100. data/spec/dummy/app/models/dummy_model.rb +0 -3
  101. data/spec/dummy/db/migrate/20130827094554_alchemy_two_point_six.rb +0 -1
  102. data/spec/dummy/db/migrate/20130828121054_remove_do_not_index_from_alchemy_essence_texts.rb +0 -1
  103. data/spec/dummy/db/migrate/20130828121120_remove_do_not_index_from_alchemy_essence_richtexts.rb +0 -1
  104. data/spec/dummy/db/migrate/20130918201742_add_published_at_to_alchemy_pages.rb +0 -1
  105. data/spec/dummy/db/migrate/20140107192720_add_missing_unique_indices_to_tags_and_taggings.rb +0 -1
  106. data/spec/dummy/db/migrate/20140701160159_add_taggings_counter_cache_to_tags.rb +0 -1
  107. data/spec/dummy/db/migrate/20140701160225_add_missing_taggable_index.rb +0 -1
  108. data/spec/dummy/db/migrate/20150412103152_create_dummy_model.rb +0 -7
  109. data/spec/dummy/spec/javascripts +0 -1
  110. data/spec/models/dummy_model_spec.rb +0 -11
@@ -37,7 +37,8 @@ module Alchemy
37
37
  # Makes a slug of all ancestors urlnames including mine and delimit them be slash.
38
38
  # So the whole path is stored as urlname in the database.
39
39
  def update_urlname!
40
- new_urlname = nested_url_name(slug)
40
+ names = ancestors.visible.contentpages.where(language_root: nil).map(&:slug).compact
41
+ new_urlname = (names << slug).join('/')
41
42
  if urlname != new_urlname
42
43
  legacy_urls.create(urlname: urlname)
43
44
  update_column(:urlname, new_urlname)
@@ -55,18 +56,6 @@ module Alchemy
55
56
  "http://#{urlname}"
56
57
  end
57
58
 
58
- # Returns an array of visible/non-language_root ancestors.
59
- def visible_ancestors
60
- return [] unless parent
61
- if new_record?
62
- parent.visible_ancestors.tap do |base|
63
- base.push(parent) if parent.visible?
64
- end
65
- else
66
- ancestors.visible.contentpages.where(language_root: nil).to_a
67
- end
68
- end
69
-
70
59
  private
71
60
 
72
61
  def update_descendants_urlnames
@@ -82,15 +71,18 @@ module Alchemy
82
71
  # If url_nesting is enabled the urlname contains the whole path.
83
72
  def set_urlname
84
73
  if Config.get(:url_nesting)
85
- value = slug
74
+ url_name = [
75
+ parent_urlname,
76
+ convert_url_name(urlname.blank? ? name : slug)
77
+ ].compact.join('/')
86
78
  else
87
- value = urlname
79
+ url_name = convert_url_name(urlname.blank? ? name : urlname)
88
80
  end
89
- self[:urlname] = nested_url_name(value)
81
+ write_attribute :urlname, url_name
90
82
  end
91
83
 
92
84
  def set_title
93
- self[:title] = name
85
+ write_attribute :title, name
94
86
  end
95
87
 
96
88
  # Converts the given name into an url friendly string.
@@ -98,8 +90,8 @@ module Alchemy
98
90
  # Names shorter than 3 will be filled up with dashes,
99
91
  # so it does not collidate with the language code.
100
92
  #
101
- def convert_url_name(value)
102
- url_name = convert_to_urlname(value.blank? ? name : value)
93
+ def convert_url_name(name)
94
+ url_name = convert_to_urlname(name)
103
95
  if url_name.length < 3
104
96
  ('-' * (3 - url_name.length)) + url_name
105
97
  else
@@ -107,16 +99,11 @@ module Alchemy
107
99
  end
108
100
  end
109
101
 
110
- def nested_url_name(value)
111
- (ancestor_slugs << convert_url_name(value)).join('/')
112
- end
113
-
114
- # Slugs of all visible/non-language_root ancestors.
115
- # Returns [], if there is no parent, the parent is
116
- # the root page itself, or url_nesting is off.
117
- def ancestor_slugs
118
- return [] if !Config.get(:url_nesting) || parent.nil? || parent.root?
119
- visible_ancestors.map(&:slug).compact
102
+ # Urlname of parent page.
103
+ # Returns nil, if the parent is either a language root page or the root page itself
104
+ def parent_urlname
105
+ return if parent.nil? || parent.language_root? || parent.root?
106
+ parent.urlname
120
107
  end
121
108
  end
122
109
  end
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: UTF-8
3
- gem 'rails', '~> 4.1.0'
3
+ gem 'rails', '~> 4.2.0'
4
4
 
5
5
  require 'rails/version'
6
6
  require "thor"
@@ -24,14 +24,13 @@ Alchemy::Engine.routes.draw do
24
24
  :as => :show_picture
25
25
  get '/pictures/:id/zoom/:name.:format' => 'pictures#zoom',
26
26
  :as => :zoom_picture
27
- get "/pictures/:id/thumbnails/:size(/:crop)(/:crop_from/:crop_size)/:name.:format" => 'pictures#thumbnail',
27
+ get "/pictures/:id/thumbnails(/:size)(/:crop)(/:crop_from/:crop_size)/:name.:format" => 'pictures#thumbnail',
28
28
  :as => :thumbnail, :defaults => {:format => 'png', :name => "thumbnail"}
29
29
 
30
30
  get '/admin/leave' => 'admin/base#leave', :as => :leave_admin
31
31
 
32
32
  resources :messages, :only => [:index, :new, :create]
33
33
  resources :elements, :only => :show
34
- resources :contents, :only => :show
35
34
 
36
35
  namespace :api, defaults: {format: 'json'} do
37
36
  resources :contents, only: [:index, :show]
@@ -293,23 +293,6 @@ class AlchemyTwoPointSix < ActiveRecord::Migration
293
293
  add_index "alchemy_sites", ["host", "public"], name: "alchemy_sites_public_hosts_idx"
294
294
  add_index "alchemy_sites", ["host"], name: "index_alchemy_sites_on_host"
295
295
  end
296
-
297
- unless table_exists?('taggings')
298
- create_table "taggings" do |t|
299
- t.integer "tag_id"
300
- t.integer "taggable_id"
301
- t.string "taggable_type"
302
- t.integer "tagger_id"
303
- t.string "tagger_type"
304
- t.string "context"
305
- t.datetime "created_at"
306
- end
307
- add_index "taggings", ["tag_id"], name: "index_taggings_on_tag_id"
308
- add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context"
309
- create_table "tags" do |t|
310
- t.string "name"
311
- end
312
- end
313
296
  end
314
297
 
315
298
  def down
@@ -23,18 +23,17 @@ include Alchemy::Tasks::Helpers
23
23
  run "mkdir -p #{shared_path}/uploads/pictures"
24
24
  run "mkdir -p #{shared_path}/uploads/attachments"
25
25
  run "mkdir -p #{shared_picture_cache_path}"
26
- run "mkdir -p #{shared_path}/cache/assets"
26
+ run "mkdir -p #{shared_path}/cache"
27
27
  end
28
28
 
29
- # This task sets the symlinks for uploads, assets and picture cache folder.
29
+ # This task symlinks the uploads, picture and general cache folder to the new release.
30
30
  desc "Sets the symlinks for uploads and picture cache folder. Called after deploy:finalize_update"
31
31
  task :symlink, :roles => :app do
32
32
  run "rm -rf #{release_path}/uploads"
33
33
  run "ln -nfs #{shared_path}/uploads #{release_path}/"
34
34
  run "mkdir -p #{public_path_with_mountpoint}"
35
35
  run "ln -nfs #{shared_picture_cache_path} #{public_path_with_mountpoint('pictures')}"
36
- run "mkdir -p #{release_path}/tmp/cache"
37
- run "ln -nfs #{shared_path}/cache/assets #{release_path}/tmp/cache/assets"
36
+ run "ln -nfs #{shared_path}/cache #{release_path}/tmp/cache"
38
37
  end
39
38
 
40
39
  def shared_picture_cache_path
@@ -3,7 +3,8 @@ module Alchemy
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- prepend_before_action :set_alchemy_language, :set_current_alchemy_site
6
+ before_action :set_current_alchemy_site
7
+ before_action :set_alchemy_language
7
8
 
8
9
  helper 'alchemy/pages'
9
10
 
@@ -13,6 +13,7 @@ require 'jquery-ui-rails'
13
13
  require 'kaminari'
14
14
  require 'non-stupid-digest-assets'
15
15
  require 'request_store'
16
+ require 'responders'
16
17
  require 'sass-rails'
17
18
  require 'sassy-buttons'
18
19
  require 'simple_form'
@@ -19,6 +19,13 @@ module Alchemy
19
19
 
20
20
  class ElementDefinitionError < StandardError
21
21
  # Raised if element definition can not be found.
22
+ def initialize(attributes)
23
+ @name = attributes[:name]
24
+ end
25
+
26
+ def message
27
+ "Element definition for #{@name} not found. Please check your elements.yml"
28
+ end
22
29
  end
23
30
 
24
31
  class EssenceMissingError < StandardError
@@ -36,11 +36,11 @@ module Alchemy #:nodoc:
36
36
  stampable stamper_class_name: Alchemy.user_class_name
37
37
  validate :validate_ingredient, :on => :update, :if => 'validations.any?'
38
38
 
39
- has_one :content, :as => :essence, class_name: "Alchemy::Content"
40
- has_one :element, :through => :content, class_name: "Alchemy::Element"
41
- has_one :page, :through => :element, class_name: "Alchemy::Page"
39
+ has_one :content, :as => :essence
40
+ has_one :element, :through => :content
41
+ has_one :page, :through => :element
42
42
 
43
- scope :available, -> { joins(:element).merge(Alchemy::Element.available) }
43
+ scope :available, -> { joins(:element).merge(Element.available) }
44
44
  scope :from_element, ->(name) { joins(:element).where(alchemy_elements: { name: name }) }
45
45
 
46
46
  delegate :restricted?, to: :page, allow_nil: true
@@ -184,7 +184,7 @@ module Alchemy
184
184
  def user_role_rules
185
185
  return alchemy_guest_user_rules if @user.alchemy_roles.blank?
186
186
  @user.alchemy_roles.each do |role|
187
- exec_role_rules(role) if @user.alchemy_roles.include?(role)
187
+ exec_role_rules(role)
188
188
  end
189
189
  end
190
190
 
@@ -7,10 +7,23 @@ module Alchemy
7
7
  # in a list on the shell / log
8
8
  #
9
9
  module Shell
10
+ def self.silence!
11
+ @silenced = true
12
+ end
13
+
14
+ def self.verbose!
15
+ @silenced = false
16
+ end
17
+
18
+ def self.silenced?
19
+ @silenced ||= false
20
+ end
10
21
 
11
22
  def desc(message)
12
- puts "\n#{message}"
13
- puts "#{'-' * message.length}\n"
23
+ unless Alchemy::Shell.silenced?
24
+ puts "\n#{message}"
25
+ puts "#{'-' * message.length}\n"
26
+ end
14
27
  end
15
28
 
16
29
  def todo(todo, title='')
@@ -54,15 +67,17 @@ module Alchemy
54
67
  # @param [Symbol] type
55
68
  #
56
69
  def log(message, type=nil)
57
- case type
58
- when :skip
59
- puts "#{color(:yellow)}== Skipping! #{message}#{color(:clear)}"
60
- when :error
61
- puts "#{color(:red)}!! ERROR: #{message}#{color(:clear)}"
62
- when :message
63
- puts "#{color(:clear)}#{message}"
64
- else
65
- puts "#{color(:green)}== #{message}#{color(:clear)}"
70
+ unless Alchemy::Shell.silenced?
71
+ case type
72
+ when :skip
73
+ puts "#{color(:yellow)}== Skipping! #{message}#{color(:clear)}"
74
+ when :error
75
+ puts "#{color(:red)}!! ERROR: #{message}#{color(:clear)}"
76
+ when :message
77
+ puts "#{color(:clear)}#{message}"
78
+ else
79
+ puts "#{color(:green)}== #{message}#{color(:clear)}"
80
+ end
66
81
  end
67
82
  end
68
83
 
@@ -1,37 +1,73 @@
1
- # Based on spree commerce controller hacks.
2
- # https://github.com/spree/spree/blob/master/core/spec/support/controller_hacks.rb
3
- # Thanks!
4
-
1
+ # Use this module to easily test Alchemy actions within Alchemy components
2
+ # or inside your application to test routes for the mounted Alchemy engine.
3
+ #
4
+ # Inside your spec_helper.rb, include this module inside the RSpec.configure
5
+ # block by doing this:
6
+ #
7
+ # require 'alchemy/test_support/controller_requests'
8
+ # RSpec.configure do |c|
9
+ # c.include Alchemy::TestSupport::ControllerRequests, type: :controller
10
+ # end
11
+ #
12
+ # Then, in your controller tests, you can access alchemy routes like this:
13
+ #
14
+ # require 'spec_helper'
15
+ #
16
+ # describe Alchemy::Admin::PagesController do
17
+ # it "can see all the pages" do
18
+ # alchemy_get :index
19
+ # end
20
+ # end
21
+ #
22
+ # Use alchemy_get, alchemy_post, alchemy_put or alchemy_delete to make requests
23
+ # to the Alchemy engine, and use regular get, post, put or delete to make
24
+ # requests to your application.
25
+ #
26
+ # Note: Based on Spree::TestingSupport::ControllerRequests. Thanks <3
27
+ #
5
28
  module Alchemy
6
29
  module TestSupport
7
30
  module ControllerRequests
31
+ extend ActiveSupport::Concern
8
32
 
9
- def get(action, parameters = nil, session = nil, flash = nil)
33
+ # Executes a request simulating GET HTTP method
34
+ def alchemy_get(action, parameters = nil, session = nil, flash = nil)
10
35
  process_alchemy_action(action, parameters, session, flash, "GET")
11
36
  end
12
37
 
13
- # Executes a request simulating POST HTTP method and set/volley the response
14
- def post(action, parameters = nil, session = nil, flash = nil)
38
+ # Executes a request simulating POST HTTP method
39
+ def alchemy_post(action, parameters = nil, session = nil, flash = nil)
15
40
  process_alchemy_action(action, parameters, session, flash, "POST")
16
41
  end
17
42
 
18
- # Executes a request simulating PUT HTTP method and set/volley the response
19
- def put(action, parameters = nil, session = nil, flash = nil)
43
+ # Executes a request simulating PUT HTTP method
44
+ def alchemy_put(action, parameters = nil, session = nil, flash = nil)
20
45
  process_alchemy_action(action, parameters, session, flash, "PUT")
21
46
  end
22
47
 
23
- # Executes a request simulating DELETE HTTP method and set/volley the response
24
- def delete(action, parameters = nil, session = nil, flash = nil)
48
+ # Executes a request simulating DELETE HTTP method
49
+ def alchemy_delete(action, parameters = nil, session = nil, flash = nil)
25
50
  process_alchemy_action(action, parameters, session, flash, "DELETE")
26
51
  end
27
52
 
53
+ # Executes a simulated XHR request
54
+ def alchemy_xhr(method, action, parameters = nil, session = nil, flash = nil)
55
+ process_alchemy_xhr_action(method, action, parameters, session, flash)
56
+ end
57
+
28
58
  private
29
59
 
30
60
  def process_alchemy_action(action, parameters = nil, session = nil, flash = nil, method = "GET")
61
+ @routes = Alchemy::Engine.routes
31
62
  parameters ||= {}
32
- process(action, method, parameters.merge!(:use_route => :alchemy), session, flash)
63
+ process(action, method, parameters, session, flash)
33
64
  end
34
65
 
66
+ def process_alchemy_xhr_action(method, action, parameters = nil, session = nil, flash = nil)
67
+ @routes = Alchemy::Engine.routes
68
+ parameters ||= {}
69
+ xml_http_request(method, action, parameters, session, flash)
70
+ end
35
71
  end
36
72
  end
37
73
  end
@@ -5,6 +5,7 @@ module Alchemy
5
5
 
6
6
  Dir["#{File.dirname(__FILE__)}/upgrader/*.rb"].each { |f| require f }
7
7
 
8
+ extend Alchemy::Upgrader::ThreePointTwo
8
9
  extend Alchemy::Upgrader::ThreePointOne
9
10
  extend Alchemy::Upgrader::ThreePointZero
10
11
 
@@ -1,6 +1,5 @@
1
1
  module Alchemy
2
2
  module Upgrader::ThreePointOne
3
-
4
3
  private
5
4
 
6
5
  def alchemy_3_1_todos
@@ -0,0 +1,39 @@
1
+ require 'thor'
2
+
3
+ class Alchemy::Upgrader::ThreePointTwoTask < Thor
4
+ include Thor::Actions
5
+
6
+ no_tasks do
7
+
8
+ def patch_acts_as_taggable_on_migrations
9
+ sentinel = /def self.up/
10
+
11
+ aato_file = Dir.glob('db/migrate/*_acts_as_taggable_on_migration.*.rb').first
12
+ if aato_file
13
+ inject_into_file aato_file,
14
+ "\n # inserted by Alchemy CMS upgrader\n return if table_exists?(:tags)\n",
15
+ { after: sentinel, verbose: true }
16
+ end
17
+
18
+ aato_file = Dir.glob('db/migrate/*_add_missing_unique_indices.*.rb').first
19
+ if aato_file
20
+ inject_into_file aato_file,
21
+ "\n # inserted by Alchemy CMS upgrader\n return if index_exists?(:tags, :name)\n",
22
+ { after: sentinel, verbose: true }
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ module Alchemy
29
+ module Upgrader::ThreePointTwo
30
+ private
31
+
32
+ def upgrade_acts_as_taggable_on_migrations
33
+ # We can't invoke this rake task, because Rails will use wrong engine names otherwise
34
+ `bundle exec rake railties:install:migrations`
35
+ Alchemy::Upgrader::ThreePointTwoTask.new.patch_acts_as_taggable_on_migrations
36
+ Rake::Task["db:migrate"].invoke
37
+ end
38
+ end
39
+ end
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
- VERSION = "3.1.3"
2
+ VERSION = "3.2.0.beta"
3
3
 
4
4
  def self.version
5
5
  VERSION
@@ -1,7 +1,7 @@
1
1
  # This rails template installs Alchemy and all depending gems.
2
2
  require File.expand_path("../../../alchemy/version", __FILE__)
3
3
 
4
- gem "alchemy_cms", github: "AlchemyCMS/alchemy_cms", branch: "3.1-stable"
5
- gem "alchemy-devise", github: "AlchemyCMS/alchemy-devise", branch: "2.1-stable"
4
+ gem "alchemy_cms", github: "AlchemyCMS/alchemy_cms", branch: "master"
5
+ gem "alchemy-devise", github: "AlchemyCMS/alchemy-devise", branch: "master"
6
6
 
7
7
  gem "capistrano", "~> 2.15.5", group: "development"
@@ -36,7 +36,8 @@ namespace :alchemy do
36
36
  system("rails g alchemy:scaffold#{ ENV['from_binary'] ? ' --force' : '' }") || exit!(1)
37
37
  Alchemy::InstallTask.new.set_primary_language
38
38
  Rake::Task["db:create"].invoke
39
- Rake::Task["alchemy:install:migrations"].invoke
39
+ # We can't invoke this rake task, because Rails will use wrong engine names otherwise
40
+ `bundle exec rake railties:install:migrations`
40
41
  Rake::Task["db:migrate"].invoke
41
42
  Rake::Task["alchemy:db:seed"].invoke
42
43
  unless ENV['from_binary']
@@ -11,13 +11,13 @@ module Alchemy
11
11
  describe "#index" do
12
12
  it "should always paginate the records" do
13
13
  expect(Attachment).to receive(:find_paginated)
14
- get :index
14
+ alchemy_get :index
15
15
  end
16
16
 
17
17
  context "when params[:tagged_with] is set" do
18
18
  it "should filter the records by tags" do
19
19
  expect(Attachment).to receive(:tagged_with).and_return(Attachment.all)
20
- get :index, tagged_with: "pdf"
20
+ alchemy_get :index, tagged_with: "pdf"
21
21
  end
22
22
  end
23
23
 
@@ -27,7 +27,7 @@ module Alchemy
27
27
  context "is set" do
28
28
  it "it renders the archive_overlay partial" do
29
29
  expect(Content).to receive(:find_by).and_return(content)
30
- get :index, {content_id: content.id}
30
+ alchemy_get :index, {content_id: content.id}
31
31
  expect(response).to render_template(partial: '_archive_overlay')
32
32
  expect(assigns(:content)).to eq(content)
33
33
  end
@@ -35,7 +35,7 @@ module Alchemy
35
35
 
36
36
  context "is not set" do
37
37
  it "should render the default index view" do
38
- get :index
38
+ alchemy_get :index
39
39
  expect(response).to render_template(:index)
40
40
  end
41
41
  end
@@ -47,7 +47,7 @@ module Alchemy
47
47
 
48
48
  context 'with params[:only]' do
49
49
  it 'only loads attachments with matching content type' do
50
- get :index, only: 'jpeg'
50
+ alchemy_get :index, only: 'jpeg'
51
51
  expect(assigns(:attachments).to_a).to eq([jpg])
52
52
  expect(assigns(:attachments).to_a).to_not eq([png])
53
53
  end
@@ -55,7 +55,7 @@ module Alchemy
55
55
 
56
56
  context 'with params[:except]' do
57
57
  it 'does not load attachments with matching content type' do
58
- get :index, except: 'jpeg'
58
+ alchemy_get :index, except: 'jpeg'
59
59
  expect(assigns(:attachments).to_a).to eq([png])
60
60
  expect(assigns(:attachments).to_a).to_not eq([jpg])
61
61
  end
@@ -69,7 +69,7 @@ module Alchemy
69
69
  end
70
70
 
71
71
  it "renders the show template" do
72
- get :show, id: attachment.id
72
+ alchemy_get :show, id: attachment.id
73
73
  expect(response).to render_template(:show)
74
74
  end
75
75
  end
@@ -82,19 +82,19 @@ module Alchemy
82
82
  end
83
83
 
84
84
  it "should set @while_assigning to true" do
85
- get :new
85
+ alchemy_get :new
86
86
  expect(assigns(:while_assigning)).to eq(true)
87
87
  end
88
88
 
89
89
  it "should set @swap to params[:swap]" do
90
- get :new, swap: 'true'
90
+ alchemy_get :new, swap: 'true'
91
91
  expect(assigns(:swap)).to eq('true')
92
92
  end
93
93
  end
94
94
  end
95
95
 
96
96
  describe '#create' do
97
- subject { post :create, params }
97
+ subject { alchemy_post :create, params }
98
98
 
99
99
  let(:attachment) { mock_model('Attachment', name: 'contract.pdf', to_jq_upload: {}) }
100
100
  let(:params) { {attachment: {name: ''}} }
@@ -145,7 +145,7 @@ module Alchemy
145
145
  end
146
146
 
147
147
  describe '#update' do
148
- subject { put :update, attachment: {name: ''} }
148
+ subject { alchemy_put :update, {id: 1, attachment: {name: ''}} }
149
149
 
150
150
  let(:attachment) { build_stubbed(:attachment) }
151
151
 
@@ -184,7 +184,7 @@ module Alchemy
184
184
 
185
185
  it "destroys the attachment and sets and success message" do
186
186
  expect(attachment).to receive(:destroy)
187
- xhr :delete, :destroy
187
+ alchemy_xhr :delete, :destroy, id: 1
188
188
  expect(assigns(:attachment)).to eq(attachment)
189
189
  expect(assigns(:url)).not_to be_blank
190
190
  expect(flash[:notice]).not_to be_blank
@@ -198,13 +198,13 @@ module Alchemy
198
198
  end
199
199
 
200
200
  it "should assign @attachment with Attachment found by id" do
201
- get :download, id: attachment.id
201
+ alchemy_get :download, id: attachment.id
202
202
  expect(assigns(:attachment)).to eq(attachment)
203
203
  end
204
204
 
205
205
  it "should send the data to the browser" do
206
206
  expect(controller).to receive(:send_data)
207
- get :download, id: attachment.id
207
+ alchemy_get :download, id: attachment.id
208
208
  end
209
209
  end
210
210
  end