alchemy_cms 2.2.rc13 → 2.2.rc14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. data/Rakefile +3 -0
  2. data/alchemy_cms.gemspec +1 -0
  3. data/app/assets/javascripts/alchemy/alchemy.base.js +95 -94
  4. data/app/assets/javascripts/alchemy/alchemy.buttons.js +15 -11
  5. data/app/assets/javascripts/alchemy/alchemy.datepicker.js +18 -18
  6. data/app/assets/javascripts/alchemy/alchemy.dirty.js +20 -20
  7. data/app/assets/javascripts/alchemy/alchemy.dragndrop.js +50 -44
  8. data/app/assets/javascripts/alchemy/alchemy.element_editor_selector.js +15 -12
  9. data/app/assets/javascripts/alchemy/alchemy.elements_window.js +47 -43
  10. data/app/assets/javascripts/alchemy/alchemy.file_progress.js +27 -17
  11. data/app/assets/javascripts/alchemy/alchemy.growler.js +19 -15
  12. data/app/assets/javascripts/alchemy/alchemy.html5.js +1 -2
  13. data/app/assets/javascripts/alchemy/alchemy.image_cropper.js +10 -11
  14. data/app/assets/javascripts/alchemy/alchemy.jquery_loader.js +6 -6
  15. data/app/assets/javascripts/alchemy/alchemy.js_extensions.js +4 -6
  16. data/app/assets/javascripts/alchemy/alchemy.menubar.js +16 -20
  17. data/app/assets/javascripts/alchemy/alchemy.page_sorter.js +18 -16
  18. data/app/assets/javascripts/alchemy/alchemy.preview.js +30 -30
  19. data/app/assets/javascripts/alchemy/alchemy.preview_window.js +50 -42
  20. data/app/assets/javascripts/alchemy/alchemy.routes.js.erb +11 -11
  21. data/app/assets/javascripts/alchemy/alchemy.swf_upload.js +83 -86
  22. data/app/assets/javascripts/alchemy/alchemy.uploader.js +106 -112
  23. data/app/assets/javascripts/alchemy/alchemy.windows.js +158 -130
  24. data/app/assets/stylesheets/alchemy/base.css.scss +7 -1
  25. data/app/assets/stylesheets/alchemy/buttons.css.scss +31 -25
  26. data/app/assets/stylesheets/alchemy/elements.css.scss +4 -0
  27. data/app/controllers/alchemy/admin/base_controller.rb +5 -1
  28. data/app/helpers/alchemy/admin/base_helper.rb +21 -13
  29. data/app/helpers/alchemy/admin/contents_helper.rb +52 -11
  30. data/app/helpers/alchemy/admin/elements_helper.rb +0 -1
  31. data/app/helpers/alchemy/admin/essences_helper.rb +5 -5
  32. data/app/helpers/alchemy/essences_helper.rb +1 -0
  33. data/app/models/alchemy/content.rb +102 -91
  34. data/app/models/alchemy/essence_boolean.rb +8 -0
  35. data/app/models/alchemy/essence_select.rb +7 -0
  36. data/app/sweepers/alchemy/content_sweeper.rb +2 -4
  37. data/app/views/alchemy/admin/clipboard/clear.js.erb +3 -2
  38. data/app/views/alchemy/admin/clipboard/index.html.erb +2 -2
  39. data/app/views/alchemy/admin/contents/create.js.erb +2 -0
  40. data/app/views/alchemy/admin/contents/destroy.js.coffee +4 -0
  41. data/app/views/alchemy/admin/contents/new.html.erb +1 -1
  42. data/app/views/alchemy/admin/elements/_element_foot.html.erb +3 -2
  43. data/app/views/alchemy/admin/elements/create.js.coffee +31 -0
  44. data/app/views/alchemy/admin/elements/fold.js.coffee +37 -0
  45. data/app/views/alchemy/admin/essence_pictures/assign.js.coffee +15 -0
  46. data/app/views/alchemy/admin/essence_pictures/destroy.js.coffee +19 -0
  47. data/app/views/alchemy/admin/essence_pictures/edit.html.erb +12 -2
  48. data/app/views/alchemy/admin/layoutpages/_layoutpage.html.erb +1 -1
  49. data/app/views/alchemy/admin/pages/_page.html.erb +1 -1
  50. data/app/views/alchemy/admin/pages/destroy.js.coffee +19 -0
  51. data/app/views/alchemy/admin/pages/edit.html.erb +5 -5
  52. data/app/views/alchemy/admin/pages/update.js.coffee +36 -0
  53. data/app/views/alchemy/admin/resources/_form.html.erb +12 -1
  54. data/app/views/alchemy/admin/resources/_resource.html.erb +6 -3
  55. data/app/views/alchemy/admin/resources/_table.html.erb +1 -1
  56. data/app/views/alchemy/admin/trash/clear.js.coffee +4 -0
  57. data/app/views/alchemy/admin/trash/index.html.erb +4 -4
  58. data/app/views/alchemy/elements/_article_editor.html.erb +4 -2
  59. data/app/views/alchemy/elements/_article_view.html.erb +7 -7
  60. data/app/views/alchemy/elements/_download_editor.html.erb +4 -1
  61. data/app/views/alchemy/elements/_download_view.html.erb +7 -3
  62. data/app/views/alchemy/elements/_image_mosaic_editor.html.erb +1 -0
  63. data/app/views/alchemy/elements/_image_mosaic_view.html.erb +11 -9
  64. data/app/views/alchemy/essences/_essence_boolean_editor.html.erb +14 -0
  65. data/app/views/alchemy/essences/_essence_boolean_view.html.erb +1 -0
  66. data/app/views/alchemy/essences/_essence_date_editor.html.erb +1 -1
  67. data/app/views/alchemy/essences/_essence_file_editor.html.erb +1 -0
  68. data/app/views/alchemy/essences/_essence_html_editor.html.erb +1 -1
  69. data/app/views/alchemy/essences/_essence_richtext_editor.html.erb +1 -1
  70. data/app/views/alchemy/essences/_essence_select_editor.html.erb +35 -0
  71. data/app/views/alchemy/essences/_essence_select_view.html.erb +1 -0
  72. data/app/views/alchemy/essences/_essence_text_editor.html.erb +29 -77
  73. data/app/views/alchemy/essences/_essence_text_view.html.erb +2 -2
  74. data/config/alchemy/elements.yml +72 -44
  75. data/config/locales/alchemy.de.yml +46 -45
  76. data/config/locales/alchemy.en.yml +90 -89
  77. data/db/migrate/20120608085509_create_alchemy_essence_selects.rb +11 -0
  78. data/db/migrate/20120611221734_create_alchemy_essence_booleans.rb +11 -0
  79. data/lib/alchemy/authentication_helpers.rb +3 -7
  80. data/lib/alchemy/engine.rb +3 -4
  81. data/lib/alchemy/essence.rb +24 -16
  82. data/lib/alchemy/resource.rb +22 -3
  83. data/lib/alchemy/resources_helper.rb +8 -0
  84. data/lib/alchemy/seeder.rb +26 -1
  85. data/lib/alchemy/upgrader.rb +70 -1
  86. data/lib/alchemy/version.rb +1 -1
  87. data/lib/alchemy_cms.rb +1 -0
  88. data/spec/controllers/admin/clipboard_controller_spec.rb +16 -4
  89. data/spec/controllers/admin/contents_controller_spec.rb +21 -4
  90. data/spec/dummy/app/models/event.rb +1 -1
  91. data/spec/dummy/db/schema.rb +18 -1
  92. data/spec/helpers/admin/contents_helper_spec.rb +3 -2
  93. data/spec/models/clipboard_spec.rb +14 -3
  94. data/spec/models/essence_boolean_spec.rb +15 -0
  95. data/spec/models/essence_select_spec.rb +15 -0
  96. data/spec/models/resource_spec.rb +113 -0
  97. metadata +40 -12
  98. data/app/views/alchemy/admin/contents/destroy.js.erb +0 -7
  99. data/app/views/alchemy/admin/elements/create.js.erb +0 -36
  100. data/app/views/alchemy/admin/elements/fold.js.erb +0 -41
  101. data/app/views/alchemy/admin/essence_pictures/assign.js.erb +0 -16
  102. data/app/views/alchemy/admin/essence_pictures/destroy.js.erb +0 -20
  103. data/app/views/alchemy/admin/pages/destroy.js.erb +0 -12
  104. data/app/views/alchemy/admin/pages/update.js.erb +0 -40
  105. data/app/views/alchemy/admin/trash/clear.js.erb +0 -3
  106. data/spec/dummy/app/models/.gitkeep +0 -0
@@ -0,0 +1,11 @@
1
+ class CreateAlchemyEssenceSelects < ActiveRecord::Migration
2
+ def change
3
+ create_table :alchemy_essence_selects do |t|
4
+ t.string :value
5
+
6
+ t.timestamps
7
+ t.userstamps
8
+ end
9
+ add_index :alchemy_essence_selects, :value
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class CreateAlchemyEssenceBooleans < ActiveRecord::Migration
2
+ def change
3
+ create_table :alchemy_essence_booleans do |t|
4
+ t.boolean :value
5
+
6
+ t.timestamps
7
+ t.userstamps
8
+ end
9
+ add_index :alchemy_essence_booleans, :value
10
+ end
11
+ end
@@ -2,8 +2,8 @@ module Alchemy
2
2
  module AuthenticationHelpers
3
3
 
4
4
  def self.included(base)
5
- base.send :helper_method, :current_user
6
5
  base.send :alias_method, :current_alchemy_user, :current_user
6
+ base.send :helper_method, :current_user
7
7
  end
8
8
 
9
9
  def current_user
@@ -11,16 +11,12 @@ module Alchemy
11
11
  @current_user = current_user_session && current_user_session.record
12
12
  end
13
13
 
14
+ private
15
+
14
16
  def current_user_session
15
17
  return @current_user_session if defined?(@current_user_session)
16
18
  @current_user_session = UserSession.find
17
19
  end
18
20
 
19
- def logged_in?
20
- !current_user.blank?
21
- end
22
-
23
21
  end
24
22
  end
25
-
26
- ApplicationController.send :include, Alchemy::AuthenticationHelpers
@@ -1,12 +1,11 @@
1
1
  require File.join(File.dirname(__FILE__), '../middleware/flash_session_cookie')
2
+ require File.join(File.dirname(__FILE__), 'authentication_helpers')
2
3
 
3
4
  module Alchemy
4
5
  class Engine < Rails::Engine
5
6
 
6
7
  isolate_namespace Alchemy
7
-
8
8
  engine_name 'alchemy'
9
-
10
9
  config.mount_at = '/'
11
10
 
12
11
  # Enabling assets precompiling
@@ -41,8 +40,8 @@ module Alchemy
41
40
  Alchemy::AuthEngine.get_instance.load(File.join(File.dirname(__FILE__), '../..', 'config/authorization_rules.rb'))
42
41
  end
43
42
 
44
- initializer 'alchemy.include_authentication_helpers' do
45
- require File.join(File.dirname(__FILE__), 'authentication_helpers')
43
+ config.to_prepare do
44
+ ApplicationController.send :include, Alchemy::AuthenticationHelpers
46
45
  end
47
46
 
48
47
  end
@@ -15,9 +15,9 @@ module Alchemy #:nodoc:
15
15
  # Configuration options are:
16
16
  #
17
17
  # * +ingredient_column+ - specifies the column name you use for storing the content in the database (default: +body+)
18
- # * +validate_column+ - which column should be validated. Takes the ingredient column if not present
18
+ # * +validate_column+ - which column should be validated. (default: ingredient_column)
19
19
  # * +preview_text_column+ - specifies the column for the preview_text method. (default: ingredient_column)
20
- # * +preview_text_method+ - a method called on ingredient to get the preview text
20
+ # * +preview_text_method+ - a method called on ingredient to get the preview text. (default: ingredient_column)
21
21
  def acts_as_essence(options={})
22
22
  configuration = {}
23
23
  configuration.update(options) if options.is_a?(Hash)
@@ -31,31 +31,31 @@ module Alchemy #:nodoc:
31
31
  stampable(:stamper_class_name => 'Alchemy::User')
32
32
  validate :essence_validations, :on => :update
33
33
  has_many :contents, :as => :essence
34
-
34
+
35
35
  def acts_as_essence_class
36
36
  #{self.name}
37
37
  end
38
-
38
+
39
39
  def validation_column
40
40
  '#{validate_column}'
41
41
  end
42
-
42
+
43
43
  def ingredient_column
44
44
  '#{ingredient_column}'
45
45
  end
46
-
46
+
47
47
  def ingredient
48
48
  send('#{ingredient_column}')
49
49
  end
50
-
50
+
51
51
  def preview_text_column
52
52
  '#{preview_text_column}'
53
53
  end
54
-
54
+
55
55
  def preview_text_method
56
56
  '#{configuration[:preview_text_method]}'
57
57
  end
58
-
58
+
59
59
  EOV
60
60
  end
61
61
 
@@ -64,24 +64,24 @@ module Alchemy #:nodoc:
64
64
  module InstanceMethods
65
65
 
66
66
  # Essence Validations:
67
- #
67
+ #
68
68
  # Essence validations can be set inside the config/elements.yml file.
69
69
  # Currently supported validations are:
70
70
  # * presence
71
71
  # * format
72
72
  # * uniqueness
73
- #
73
+ #
74
74
  # If you want to validate the format you must additionally pass validate_format_as or validate_format_with:
75
- #
75
+ #
76
76
  # * validate_format_with has to be regex
77
77
  # * validate_format_as can be one of:
78
78
  # ** url
79
79
  # ** email
80
- #
80
+ #
81
81
  # Example:
82
- #
82
+ #
83
83
  # - name: person
84
- # contents:
84
+ # contents:
85
85
  # - name: name
86
86
  # type: EssenceText
87
87
  # validate: [presence]
@@ -93,7 +93,7 @@ module Alchemy #:nodoc:
93
93
  # type: EssenceText
94
94
  # validate: [format]
95
95
  # validate_format_with: '^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$'
96
- #
96
+ #
97
97
  def essence_validations
98
98
  self.validation_errors ||= []
99
99
  return true if description.blank? || description['validate'].blank?
@@ -170,6 +170,14 @@ module Alchemy #:nodoc:
170
170
  self.class.name.split('::').last.underscore
171
171
  end
172
172
 
173
+ def acts_as_essence?
174
+ !acts_as_essence_class.blank?
175
+ end
176
+
177
+ def to_partial_path
178
+ "alchemy/essences/#{partial_name}_view"
179
+ end
180
+
173
181
  end
174
182
 
175
183
  end
@@ -43,9 +43,8 @@ module Alchemy
43
43
  end
44
44
 
45
45
  def attributes
46
- #@_attributes ||=
47
46
  self.model.columns.collect do |col|
48
- {:name => col.name, :type => col.type} unless self.skip_attributes.include?(col.name)
47
+ {:name => (resource_relation_name(col.name) || col.name), :type => (resource_relation_type(col.name) || col.type)} unless self.skip_attributes.include?(col.name)
49
48
  end.compact
50
49
  end
51
50
 
@@ -68,7 +67,7 @@ module Alchemy
68
67
  @module_definition and @module_definition['engine_name']
69
68
  end
70
69
 
71
- protected
70
+ protected
72
71
 
73
72
  def controller_path_array
74
73
  @controller_path.split('/')
@@ -78,5 +77,25 @@ module Alchemy
78
77
  controller_path_array - model_array
79
78
  end
80
79
 
80
+ def resource_relation_name(column_name)
81
+ resource_relation(column_name)['attr_method'].to_s if resource_relation(column_name).present?
82
+ end
83
+
84
+ def resource_relation_type(column_name)
85
+ resource_relation(column_name)['attr_type'].to_sym if resource_relation(column_name).present?
86
+ end
87
+
88
+ def self.resource_relations
89
+ Config.get(:resource_relations)
90
+ end
91
+
92
+ def resource_relations
93
+ self.class.resource_relations[model_name.to_s] if self.class.resource_relations
94
+ end
95
+
96
+ def resource_relation(column_name)
97
+ resource_relations[column_name.to_s] if resource_relations
98
+ end
99
+
81
100
  end
82
101
  end
@@ -52,5 +52,13 @@ module Alchemy
52
52
  def resource_model
53
53
  resource_handler.model
54
54
  end
55
+
56
+ def render_attribute(obj, attribute)
57
+ attr_array = attribute.split('.')
58
+ attr_array.each do |attr|
59
+ obj = obj.send(attr) if obj
60
+ end
61
+ obj
62
+ end
55
63
  end
56
64
  end
@@ -59,7 +59,7 @@ module Alchemy
59
59
  end
60
60
  end
61
61
 
62
- private
62
+ private
63
63
 
64
64
  def color(name)
65
65
  case name
@@ -84,6 +84,8 @@ module Alchemy
84
84
  puts "#{color(:yellow)}== Skipping! #{message}#{color(:clear)}"
85
85
  when :error
86
86
  puts "#{color(:red)}!! ERROR: #{message}#{color(:clear)}"
87
+ when :message
88
+ puts "#{color(:clear)}#{message}"
87
89
  else
88
90
  puts "#{color(:green)}== #{message}#{color(:clear)}"
89
91
  end
@@ -94,6 +96,29 @@ module Alchemy
94
96
  puts "#{'-' * message.length}\n"
95
97
  end
96
98
 
99
+ def todo(todo)
100
+ add_todo todo
101
+ end
102
+
103
+ def add_todo(todo)
104
+ todos << todo
105
+ end
106
+
107
+ def todos
108
+ @@todos ||= []
109
+ end
110
+
111
+ def display_todos
112
+ if todos.length > 0
113
+ log "\nTODOS:", :message
114
+ log "------\n", :message
115
+ todos.each_with_index do |todo, i|
116
+ log "\n#{i+1}. ", :message
117
+ log todo, :message
118
+ end
119
+ end
120
+ end
121
+
97
122
  end
98
123
 
99
124
  end
@@ -12,9 +12,13 @@ module Alchemy
12
12
  upgrade_layoutpages
13
13
  upgrade_essence_link_target_default
14
14
  upgrade_to_namespaced_essence_type
15
+ convert_essence_texts_displayed_as_select_into_essence_selects
16
+ convert_essence_texts_displayed_as_checkbox_into_essence_booleans
17
+
18
+ display_todos
15
19
  end
16
20
 
17
- private
21
+ private
18
22
 
19
23
  # Creates Language model if it does not exist (Alchemy CMS prior v1.5)
20
24
  # Also creates missing associations between pages and languages
@@ -101,12 +105,77 @@ module Alchemy
101
105
  else
102
106
  log "No essence_type columns to be namespaced found.", :skip
103
107
  end
108
+ todo "Test mich nicht"
104
109
  end
105
110
 
106
111
  def strip_alchemy_from_schema_version_table
112
+ desc "Strip -alchemy suffix from schema_version table."
107
113
  database_yml = YAML.load_file(Rails.root.join("config", "database.yml"))
108
114
  connection = Mysql2::Client.new(database_yml.fetch(Rails.env.to_s).symbolize_keys)
109
115
  connection.query "UPDATE schema_migrations SET `schema_migrations`.`version` = REPLACE(`schema_migrations`.`version`,'-alchemy','')"
116
+ todo "Teste mich"
117
+ end
118
+
119
+ def convert_essence_texts_displayed_as_select_into_essence_selects
120
+ desc "Converting EssenceTexts displayed as select into EssenceSelects"
121
+ contents_found = 0
122
+ elements = Alchemy::Element.descriptions.select { |e| e['contents'].present? && !e['contents'].detect { |c| c['settings'].present? && c['settings']['display_as'] == 'select' }.nil? }
123
+ contents = elements.collect { |el| el['contents'] }.flatten.select { |c| c['settings'] && c['settings']['display_as'] == 'select' }.flatten
124
+ content_names = contents.collect { |c| c['name'] }
125
+ Alchemy::Content.essence_texts.where(
126
+ :name => content_names,
127
+ :alchemy_elements => {:name => elements.collect { |e| e['name'] }}
128
+ ).joins(:element).each do |content|
129
+ new_content = Alchemy::Content.new(:name => content.name, :element_id => content.element.id)
130
+ if new_content.create_essence!('name' => content.name, 'type' => 'EssenceSelect')
131
+ new_content.essence.value = content.ingredient
132
+ if new_content.essence.save
133
+ contents_found += 1
134
+ log "Converted #{content.name}'s essence_type into EssenceSelect"
135
+ content.destroy
136
+ else
137
+ log "Could not save essence: #{new_content.essence.errors.full_messages.join(', ')}", :error
138
+ end
139
+ else
140
+ log "Could not create content: #{new_content.errors.full_messages.join(', ')}", :error
141
+ end
142
+ end
143
+ if contents_found > 0
144
+ todo "Please open your elements.yml file and change all type values from these contents:\n\n#{content_names.join(', ')}\n\ninto EssenceSelect."
145
+ else
146
+ log "No EssenceTexts with display_as select setting found.", :skip
147
+ end
148
+ end
149
+
150
+ def convert_essence_texts_displayed_as_checkbox_into_essence_booleans
151
+ desc "Converting EssenceTexts displayed as checkbox into EssenceBooleans"
152
+ contents_found = 0
153
+ elements = Alchemy::Element.descriptions.select { |e| e['contents'].present? && !e['contents'].detect { |c| c['settings'].present? && c['settings']['display_as'] == 'checkbox' }.nil? }
154
+ contents = elements.collect { |el| el['contents'] }.flatten.select { |c| c['settings'] && c['settings']['display_as'] == 'checkbox' }.flatten
155
+ content_names = contents.collect { |c| c['name'] }
156
+ Alchemy::Content.essence_texts.where(
157
+ :name => content_names,
158
+ :alchemy_elements => {:name => elements.collect { |e| e['name'] }}
159
+ ).joins(:element).each do |content|
160
+ new_content = Alchemy::Content.new(:name => content.name, :element_id => content.element.id)
161
+ if new_content.create_essence!('name' => content.name, 'type' => 'EssenceBoolean')
162
+ new_content.essence.value = content.ingredient
163
+ if new_content.essence.save
164
+ contents_found += 1
165
+ log "Converted #{content.name}'s essence_type into EssenceBoolean"
166
+ content.destroy
167
+ else
168
+ log "Could not save essence: #{new_content.essence.errors.full_messages.join(', ')}", :error
169
+ end
170
+ else
171
+ log "Could not create content: #{new_content.errors.full_messages.join(', ')}", :error
172
+ end
173
+ end
174
+ if contents_found > 0
175
+ todo "Please open your elements.yml file and change all type values from these contents:\n\n#{content_names.join(', ')}\n\ninto EssenceBoolean."
176
+ else
177
+ log "No EssenceTexts with display_as checkbox setting found.", :skip
178
+ end
110
179
  end
111
180
 
112
181
  end
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
2
 
3
- VERSION = "2.2.rc13"
3
+ VERSION = "2.2.rc14"
4
4
 
5
5
  end
@@ -10,6 +10,7 @@ if defined?(Rails) && Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR == 2
10
10
  require 'userstamp'
11
11
  require 'yaml'
12
12
  require 'sass-rails'
13
+ require 'coffee-rails'
13
14
  require 'declarative_authorization'
14
15
  require 'extensions/hash'
15
16
  require 'extensions/array'
@@ -38,11 +38,23 @@ module Alchemy
38
38
  end
39
39
 
40
40
  describe "#clear" do
41
- it "should be clearable" do
42
- session[:clipboard][:elements] = {:id => element.id}
43
- delete(:clear, :format => :js)
44
- session[:clipboard].should be_empty
41
+
42
+ context "with elements as remarkable_type" do
43
+ it "should clear the elements clipboard" do
44
+ session[:clipboard][:elements] = {:id => element.id}
45
+ delete(:clear, {:remarkable_type => :elements, :format => :js})
46
+ session[:clipboard].should be_empty
47
+ end
48
+ end
49
+
50
+ context "with pages as remarkable_type" do
51
+ it "should clear the pages clipboard" do
52
+ session[:clipboard][:pages] = {:id => page.id}
53
+ delete(:clear, {:remarkable_type => :pages, :format => :js})
54
+ session[:clipboard].should be_empty
55
+ end
45
56
  end
57
+
46
58
  end
47
59
 
48
60
  end
@@ -7,10 +7,27 @@ describe Alchemy::Admin::ContentsController do
7
7
  Alchemy::UserSession.create FactoryGirl.create(:admin_user)
8
8
  end
9
9
 
10
- it "should update a content via ajax" do
11
- @element = FactoryGirl.create(:element)
12
- post :update, {:id => @element.contents.find_by_name('intro').id, :content => {:body => 'Peters Petshop'}, :format => :js}
13
- @element.ingredient('intro').should == "Peters Petshop"
10
+ describe '#create' do
11
+
12
+ let(:element) { FactoryGirl.create(:element, :name => 'headline') }
13
+
14
+ it "should create a content via ajax post" do
15
+ length_before = element.contents.length
16
+ post :create, {:content => {:element_id => element.id, :name => 'headline'}, :format => :js}
17
+ element.contents.reload
18
+ element.contents.length.should == length_before + 1
19
+ end
20
+
21
+ end
22
+
23
+ describe '#update' do
24
+
25
+ it "should update a content via ajax" do
26
+ @element = FactoryGirl.create(:element)
27
+ post :update, {:id => @element.contents.find_by_name('intro').id, :content => {:body => 'Peters Petshop'}, :format => :js}
28
+ @element.ingredient('intro').should == "Peters Petshop"
29
+ end
30
+
14
31
  end
15
32
 
16
33
  describe "#order" do