alchemy_cms 2.2.rc8 → 2.2.rc11

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 (55) hide show
  1. data/README.md +1 -1
  2. data/app/assets/javascripts/alchemy/alchemy.page_sorter.js +1 -1
  3. data/app/assets/stylesheets/alchemy/sitemap.css.scss +14 -13
  4. data/app/assets/stylesheets/alchemy/standard_set.css +9 -10
  5. data/app/controllers/alchemy/admin/pages_controller.rb +1 -0
  6. data/app/controllers/alchemy/base_controller.rb +2 -1
  7. data/app/helpers/alchemy/admin/essences_helper.rb +1 -0
  8. data/app/helpers/alchemy/elements_helper.rb +2 -10
  9. data/app/helpers/alchemy/essences_helper.rb +1 -0
  10. data/app/helpers/alchemy/pages_helper.rb +31 -13
  11. data/app/models/alchemy/attachment.rb +1 -1
  12. data/app/models/alchemy/content.rb +8 -8
  13. data/app/models/alchemy/element.rb +14 -10
  14. data/app/models/alchemy/essence_file.rb +1 -1
  15. data/app/models/alchemy/message.rb +9 -9
  16. data/app/models/alchemy/page.rb +4 -3
  17. data/app/models/alchemy/picture.rb +1 -1
  18. data/app/models/alchemy/user.rb +1 -1
  19. data/app/sweepers/alchemy/content_sweeper.rb +29 -6
  20. data/app/views/alchemy/admin/attachments/new.html.erb +1 -1
  21. data/app/views/alchemy/admin/pages/index.html.erb +7 -7
  22. data/app/views/alchemy/admin/pages/sort.js.erb +2 -1
  23. data/app/views/alchemy/admin/partials/_upload_form.html.erb +2 -2
  24. data/app/views/alchemy/admin/pictures/new.html.erb +1 -1
  25. data/app/views/alchemy/essences/_essence_picture_tools.html.erb +2 -2
  26. data/app/views/alchemy/essences/_essence_text_editor.html.erb +11 -11
  27. data/app/views/alchemy/navigation/_link.html.erb +20 -20
  28. data/app/views/alchemy/navigation/_renderer.html.erb +37 -23
  29. data/config/alchemy/config.yml +107 -65
  30. data/config/alchemy/elements.yml +12 -1
  31. data/config/locales/alchemy.de.yml +1 -0
  32. data/config/locales/alchemy.en.yml +1 -0
  33. data/lib/alchemy/essence.rb +1 -1
  34. data/lib/alchemy/page_layout.rb +3 -9
  35. data/lib/alchemy/resource.rb +5 -5
  36. data/lib/alchemy/version.rb +1 -1
  37. data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +2 -2
  38. data/lib/rails/generators/alchemy/scaffold/{files/page_layouts.yml → templates/page_layouts.yml.tt} +4 -0
  39. data/spec/config_spec.rb +1 -1
  40. data/spec/dummy/db/schema.rb +1 -1
  41. data/spec/helpers/admin/contents_helper_spec.rb +4 -3
  42. data/spec/helpers/admin/essences_helper_spec.rb +4 -8
  43. data/spec/helpers/essences_helper_spec.rb +0 -4
  44. data/spec/helpers/pages_helper_spec.rb +10 -1
  45. data/spec/integration/admin/modules_integration_spec.rb +25 -21
  46. data/spec/integration/admin/pages_controller_spec.rb +16 -19
  47. data/spec/integration/admin/resources_integration_spec.rb +58 -64
  48. data/spec/integration/pages_controller_spec.rb +24 -3
  49. data/spec/integration/security_spec.rb +12 -12
  50. data/spec/libraries/resource_spec.rb +16 -18
  51. data/spec/models/page_spec.rb +352 -326
  52. data/spec/page_layout_spec.rb +2 -2
  53. data/spec/support/alchemy/specs_helpers.rb +16 -1
  54. metadata +116 -38
  55. data/spec/support/integration_spec_helper.rb +0 -24
@@ -39,9 +39,20 @@
39
39
  #
40
40
  # After finishing the setup of your element layouts, you need to generate the files for the elements before using them in Alchemy.
41
41
  # For creating these files, use the following command in your terminal:
42
+ #
43
+ #
42
44
  #
43
- # rails generate elements
45
+ # rails generate alchemy:elements
46
+ #
47
+ #
48
+ # or:
49
+ #
50
+ # rails g alchemy:elements --skip
51
+ #
52
+ #
53
+ # to skip existing elements
44
54
  #
55
+ #
45
56
  # All new elements will be created as two different partials in Rails.root/app/views/elements.
46
57
  # For each element there is an editor-view wich will be rendered when editing them in Alchemy and another view for the website´s frontend.
47
58
  #
@@ -497,6 +497,7 @@ de:
497
497
  successfully_added_element: "Element wurde hinzugefügt."
498
498
  successfully_saved_element_position: "Die Elementposition wurde gespeichert."
499
499
  swap_image: "Bild tauschen"
500
+ insert_image: "Bild einfügen"
500
501
  swfupload:
501
502
  cancel_uploads: "Hochladen abbrechen"
502
503
  title: "Titel"
@@ -339,6 +339,7 @@ en:
339
339
  successfully_added_element: "Succesfully added new element."
340
340
  successfully_saved_element_position: "Element position updated succesfully."
341
341
  swap_image: "Change image"
342
+ insert_image: "Insert image"
342
343
  swfupload:
343
344
  cancel_uploads: "Cancel uploads"
344
345
  title: "Title"
@@ -28,7 +28,7 @@ module Alchemy #:nodoc:
28
28
  class_eval <<-EOV
29
29
  attr_accessor :validation_errors
30
30
  include Alchemy::Essence::InstanceMethods
31
- stampable
31
+ stampable(:stamper_class_name => 'Alchemy::User')
32
32
  validate :essence_validations, :on => :update
33
33
  has_many :contents, :as => :essence
34
34
 
@@ -88,20 +88,14 @@ module Alchemy
88
88
  end
89
89
 
90
90
  # Reads the layout definitions from +config/alchemy/page_layouts.yml+.
91
- # If this can not be found, it takes the default one from Alchemys standard set.
92
91
  def self.read_layouts_file
93
92
  if File.exists? "#{Rails.root}/config/alchemy/page_layouts.yml"
94
93
  layouts = YAML.load_file "#{Rails.root}/config/alchemy/page_layouts.yml"
95
- end
96
- if !layouts
97
- if File.exists? File.join(File.dirname(__FILE__), "../../config/alchemy/page_layouts.yml")
98
- layouts = YAML.load_file File.join(File.dirname(__FILE__), "../../config/alchemy/page_layouts.yml")
99
- end
100
- end
101
- if !layouts
94
+ else
102
95
  raise LoadError, "Could not find page_layouts.yml file! Please run: rails generate alchemy:scaffold"
103
96
  end
104
- layouts
97
+ # Since YAML returns false for an empty file, we have to normalize it here.
98
+ layouts || []
105
99
  end
106
100
 
107
101
  end
@@ -3,11 +3,14 @@ require 'active_support/inflector'
3
3
  module Alchemy
4
4
  class Resource
5
5
 
6
- SKIP_ATTRIBUTES = %W[id updated_at created_at creator_id updater_id]
6
+ attr_accessor :skip_attributes
7
+
8
+ DEFAULT_SKIPPED_ATTRIBUTES = %W[id updated_at created_at creator_id updater_id]
7
9
 
8
10
  def initialize(controller_path, module_definition=nil)
9
11
  @controller_path = controller_path
10
12
  @module_definition = module_definition
13
+ self.skip_attributes = DEFAULT_SKIPPED_ATTRIBUTES
11
14
  end
12
15
 
13
16
  def model_array
@@ -42,10 +45,7 @@ module Alchemy
42
45
  def attributes
43
46
  #@_attributes ||=
44
47
  self.model.columns.collect do |col|
45
- skip_attributes = defined?(self.model::SKIP_ATTRIBUTES) ? self.model::SKIP_ATTRIBUTES : SKIP_ATTRIBUTES
46
- unless skip_attributes.include?(col.name)
47
- {:name => col.name, :type => col.type}
48
- end
48
+ {:name => col.name, :type => col.type} unless self.skip_attributes.include?(col.name)
49
49
  end.compact
50
50
  end
51
51
 
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
2
 
3
- VERSION = "2.2.rc8"
3
+ VERSION = "2.2.rc11"
4
4
 
5
5
  end
@@ -35,8 +35,8 @@ module Alchemy
35
35
  directory "#{page_layouts_path}/", "#{Rails.root}/app/views/alchemy/page_layouts/"
36
36
  else
37
37
  copy_file "#{File.dirname(__FILE__)}/files/elements.yml", "#{Rails.root}/config/alchemy/elements.yml"
38
- copy_file "#{File.dirname(__FILE__)}/files/page_layouts.yml", "#{Rails.root}/config/alchemy/page_layouts.yml"
39
- copy_file "#{File.dirname(__FILE__)}/files/pages.html.erb", "#{Rails.root}/app/views/layouts/alchemy/pages.html.erb"
38
+ template "page_layouts.yml.tt", "#{Rails.root}/config/alchemy/page_layouts.yml"
39
+ copy_file "#{File.dirname(__FILE__)}/files/pages.html.erb", "#{Rails.root}/app/views/layouts/application.html.erb"
40
40
  end
41
41
  end
42
42
 
@@ -27,3 +27,7 @@
27
27
  # contact: Kontakt
28
28
  # search: Suche
29
29
  #
30
+
31
+ - name: <%= Alchemy::Config.get(:default_language)['page_layout'] %>
32
+ unique: true
33
+ elements: []
@@ -2,6 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  describe Alchemy::Config do
4
4
  it "should have an array of fields for mailer" do
5
- Alchemy::Config.get(:mailer)[:fields].should be_a(Array)
5
+ Alchemy::Config.get(:mailer)['fields'].should be_a(Array)
6
6
  end
7
7
  end
@@ -273,7 +273,7 @@ ActiveRecord::Schema.define(:version => 20120302040145) do
273
273
  t.datetime "starts_at"
274
274
  t.datetime "ends_at"
275
275
  t.text "description"
276
- t.decimal "entrance_fee"
276
+ t.decimal "entrance_fee", :precision => 6, :scale => 2
277
277
  t.boolean "published"
278
278
  t.datetime "created_at", :null => false
279
279
  t.datetime "updated_at", :null => false
@@ -3,18 +3,19 @@ require 'spec_helper'
3
3
  describe Alchemy::Admin::ContentsHelper do
4
4
 
5
5
  before(:each) do
6
- @element = FactoryGirl.create(:element)
6
+ @element = FactoryGirl.create(:element, :name => 'article')
7
7
  end
8
8
 
9
9
  it "should render a dom id" do
10
- helper.content_dom_id(@element.contents.first).should match(/essence_text_\d{1,}/)
10
+ helper.content_dom_id(@element.content_by_type('EssenceText')).should match(/essence_text_\d{1,}/)
11
11
  end
12
12
 
13
13
  it "should render the content name" do
14
- helper.render_content_name(@element.contents.first).should == "Intro"
14
+ helper.render_content_name(@element.content_by_type('EssenceText')).should == "Intro"
15
15
  end
16
16
 
17
17
  it "should render a link to add new content to element" do
18
+ helper.stub!(:render_icon).and_return('')
18
19
  helper.render_new_content_link(@element).should match(/Alchemy.openWindow.+\/admin\/elements\/#{@element.id}\/contents\/new/m)
19
20
  end
20
21
 
@@ -3,25 +3,21 @@ require 'spec_helper'
3
3
  describe Alchemy::Admin::EssencesHelper do
4
4
 
5
5
  before(:each) do
6
- @element = FactoryGirl.create(:element)
6
+ @element = FactoryGirl.create(:element, :name => 'article')
7
7
  @element.content_by_name('intro').essence.update_attributes(:body => 'hello!')
8
8
  end
9
9
 
10
10
  it "should render an essence editor" do
11
11
  content = @element.content_by_name('intro')
12
- render_essence_editor(content).should match(/input.+type="text".+value="hello!/)
12
+ helper.render_essence_editor(content).should match(/input.+type="text".+value="hello!/)
13
13
  end
14
14
 
15
15
  it "should render an essence editor by name" do
16
- render_essence_editor_by_name(@element, 'intro').should match(/input.+type="text".+value="hello!/)
16
+ helper.render_essence_editor_by_name(@element, 'intro').should match(/input.+type="text".+value="hello!/)
17
17
  end
18
18
 
19
19
  it "should render an essence editor by type" do
20
- render_essence_editor_by_type(@element, 'EssenceText').should match(/input.+type="text".+value="hello!/)
21
- end
22
-
23
- it "should render an essence editor by position" do
24
- render_essence_editor_by_position(@element, 1).should match(/input.+type="text".+value="hello!/)
20
+ helper.render_essence_editor_by_type(@element, 'EssenceText').should match(/input.+type="text".+value="hello!/)
25
21
  end
26
22
 
27
23
  end
@@ -25,8 +25,4 @@ describe Alchemy::EssencesHelper do
25
25
  render_essence_view_by_type(@element, 'EssenceText').should match(/hello!/)
26
26
  end
27
27
 
28
- it "should render an essence view by position" do
29
- render_essence_view_by_position(@element, 1).should match(/hello!/)
30
- end
31
-
32
28
  end
@@ -28,7 +28,7 @@ describe Alchemy::PagesHelper do
28
28
  end
29
29
 
30
30
  it "should render the page navigation" do
31
- helper.render_navigation.should have_selector("ul.navigation_level_1 li.#{@page.urlname}.active.last a.active[href=\"/alchemy/#{@page.urlname}\"]")
31
+ helper.render_navigation.should have_selector("ul.navigation.level_1 li.#{@page.urlname}.active.last a.active[href=\"/alchemy/#{@page.urlname}\"]")
32
32
  end
33
33
 
34
34
  context "with enabled url nesting" do
@@ -47,6 +47,15 @@ describe Alchemy::PagesHelper do
47
47
 
48
48
  end
49
49
 
50
+ context "with id and class in the html options" do
51
+ it "should append id to the generated ul tag" do
52
+ helper.render_navigation({}, {:id => 'foobar_id'}).should have_selector("ul[id='foobar_id']")
53
+ end
54
+ it "should replace the default css class from the generated ul tag" do
55
+ helper.render_navigation({}, {:class => 'foobar_class'}).should have_selector("ul[class='foobar_class']")
56
+ end
57
+ end
58
+
50
59
  end
51
60
 
52
61
  describe '#render_subnavigation' do
@@ -1,30 +1,34 @@
1
- require 'spec_helper'
2
- require 'support/integration_spec_helper'
1
+ # Skipping on Travis-CI, because capybara-webkit does not install on travis.
2
+ unless ENV["CI"]
3
+ require 'spec_helper'
3
4
 
4
- describe "Modules" do
5
+ describe "Modules" do
5
6
 
6
- before(:all) do
7
- FactoryGirl.build(:admin_user).save_without_session_maintenance
8
- end
9
- describe "a custom module with a main-apps controller" do
10
- it "should have a button in main_navigation, pointing to the configured controller" do
11
- Alchemy::Modules.register_module(
12
- {
13
- :name => 'events',
14
- :navigation => {
15
- :icon => 'icon events',
16
- :name => 'Events',
17
- :controller => '/admin/events',
18
- :action => 'index'
19
- }
20
- })
21
- login_into_alchemy
22
- without_access_control do
7
+ context "A custom module with a main-apps controller" do
8
+
9
+ before(:each) do
10
+ load_authorization_rules
11
+ create_admin_user
12
+ login_into_alchemy
13
+ end
14
+
15
+ it "should have a button in main_navigation, pointing to the configured controller" do
16
+ Alchemy::Modules.register_module(
17
+ {
18
+ :name => 'events',
19
+ :navigation => {
20
+ :icon => 'icon events',
21
+ :name => 'Events',
22
+ :controller => '/admin/events',
23
+ :action => 'index'
24
+ }
25
+ })
23
26
  visit '/alchemy/admin'
24
27
  click_on 'Events'
25
28
  page.should_not have_content('Upps!')
26
29
  end
30
+
27
31
  end
28
- end
29
32
 
33
+ end
30
34
  end
@@ -5,26 +5,34 @@ unless ENV["CI"]
5
5
 
6
6
  describe Alchemy::Admin::PagesController, :js => true do
7
7
 
8
+ before(:all) do
9
+ create_admin_user
10
+ end
11
+
12
+ before(:each) do
13
+ login_into_alchemy
14
+ end
15
+
8
16
  describe "language tree switching" do
9
17
 
18
+ before(:all) do
19
+ @language = FactoryGirl.create(:language)
20
+ end
21
+
10
22
  context "in a multilangual environment" do
11
23
 
12
24
  before(:all) do
13
- FactoryGirl.build(:admin_user).save_without_session_maintenance
14
- @language = FactoryGirl.create(:language)
15
25
  @german_root = FactoryGirl.create(:language_root_page, :language => Alchemy::Language.get_default, :name => 'Deutsch')
16
26
  @klingonian_root = FactoryGirl.create(:language_root_page, :name => 'Klingonian')
17
27
  end
18
28
 
19
29
  it "one should be able to switch the language tree" do
20
- login_into_alchemy
21
30
  visit('/alchemy/admin/pages')
22
31
  page.select 'Klingonian', :from => 'language'
23
32
  page.should have_selector('#sitemap .sitemap_pagename_link', :text => 'Klingonian')
24
33
  end
25
34
 
26
35
  after(:all) {
27
- @language.destroy
28
36
  @klingonian_root.delete
29
37
  @german_root.delete
30
38
  }
@@ -33,34 +41,23 @@ unless ENV["CI"]
33
41
 
34
42
  context "with no language root page" do
35
43
 
36
- before(:all) do
37
- FactoryGirl.build(:admin_user).save_without_session_maintenance
38
- @language = FactoryGirl.create(:language)
39
- end
40
-
41
44
  it "it should display the form for creating language root" do
42
- login_into_alchemy
43
45
  visit('/alchemy/admin/pages')
44
46
  page.select 'Klingonian', :from => 'language'
45
47
  page.should have_content('This language tree does not exist')
46
48
  end
47
49
 
48
- after(:all) {
49
- @language.destroy
50
- }
51
-
52
50
  end
53
51
 
52
+ after(:all) {
53
+ @language.destroy
54
+ }
55
+
54
56
  end
55
57
 
56
58
  describe "flush complete page cache" do
57
59
 
58
- before(:all) do
59
- FactoryGirl.build(:admin_user).save_without_session_maintenance
60
- end
61
-
62
60
  it "should remove the cache of all pages" do
63
- login_into_alchemy
64
61
  visit '/alchemy/admin/pages'
65
62
  click_link 'Flush page cache'
66
63
  page.should have_content('Page cache flushed')
@@ -1,100 +1,94 @@
1
- require 'spec_helper'
2
- require 'support/integration_spec_helper'
3
-
4
- describe "Resources" do
5
-
6
- before(:all) do
7
- Event.create!(:name => 'My Event',
8
- :hidden_name => 'not shown',
9
- :starts_at => DateTime.new(2012, 03, 02, 8, 15),
10
- :ends_at => DateTime.new(2012, 03, 02, 19, 30),
11
- :description => "something\nfancy",
12
- :published => false,
13
- :entrance_fee => 12.32)
14
- end
1
+ # Skipping on Travis-CI, because capybara-webkit does not install on travis.
2
+ unless ENV["CI"]
3
+ require 'spec_helper'
15
4
 
16
- describe "index view" do
5
+ describe "Resources" do
17
6
 
18
- it "should have a button for creating a new resource items" do
19
- without_access_control { visit '/admin/events' }
20
- page.should have_selector('#toolbar div.button_with_label a.icon_button span.icon.create')
7
+ before(:all) do
8
+ create_admin_user
9
+ load_authorization_rules
10
+ Event.create!(:name => 'My Event',
11
+ :hidden_name => 'not shown',
12
+ :starts_at => DateTime.new(2012, 03, 02, 8, 15),
13
+ :ends_at => DateTime.new(2012, 03, 02, 19, 30),
14
+ :description => "something\nfancy",
15
+ :published => false,
16
+ :entrance_fee => 12.32)
17
+ Event.create!(:name => 'My second Event',
18
+ :starts_at => DateTime.new(2012, 03, 02, 8, 15),
19
+ :ends_at => DateTime.new(2012, 03, 02, 19, 30),
20
+ :description => "something\nfancy",
21
+ :published => false,
22
+ :entrance_fee => 12.32)
21
23
  end
22
24
 
23
- it "should list existing items" do
24
- without_access_control {
25
+ before(:each) {
26
+ login_into_alchemy
27
+ }
28
+
29
+ describe "index view" do
30
+
31
+ it "should have a button for creating a new resource items" do
32
+ visit '/admin/events'
33
+ page.should have_selector('#toolbar div.button_with_label a.icon_button span.icon.create')
34
+ end
35
+
36
+ it "should list existing items" do
25
37
  visit '/admin/events'
26
38
  page.should have_content("My Event")
27
39
  page.should have_content("something fancy")
28
40
  page.should have_content("12.32")
29
- }
30
- end
41
+ end
31
42
 
32
- it "should list existing resource-items nicely formatted"
43
+ it "should list existing resource-items nicely formatted"
33
44
 
34
- end
45
+ end
35
46
 
36
- describe "form for creating and updating items" do
37
- it "renders an input field according to the attribute's type"
38
- end
47
+ describe "form for creating and updating items" do
48
+ it "renders an input field according to the attribute's type"
49
+ end
39
50
 
40
- describe "create resource item" do
51
+ describe "create resource item" do
41
52
 
42
- context "when form filled with valid data" do
43
- it "lists the new item" do
44
- without_access_control {
45
- create_admin_user
46
- login_with_admin_user
53
+ context "when form filled with valid data" do
54
+ it "lists the new item" do
47
55
  visit '/admin/events/new'
48
56
  fill_in 'event_name', :with => 'My second event'
49
57
  fill_in 'event_starts_at', :with => DateTime.new(2012, 03, 03, 20, 00)
50
58
  click_on 'Save'
51
59
  page.should have_content "My second event"
52
60
  page.should have_content "2012-03-03"
53
- }
61
+ end
54
62
  end
55
- end
56
63
 
57
- context "when form filled with invalid data" do
58
- it "shows the form again" do
59
- without_access_control {
60
- create_admin_user
61
- login_with_admin_user
64
+ context "when form filled with invalid data" do
65
+ it "shows the form again" do
62
66
  visit '/admin/events/new'
63
67
  fill_in 'event_name', :with => '' #invalid!
64
68
  click_on 'Save'
65
69
  page.should have_selector "input#event_name"
66
- }
70
+ end
71
+ it "lists invalid fields"
67
72
  end
68
- it "lists invalid fields"
69
- end
70
73
 
71
- end
74
+ end
72
75
 
73
- describe "updating an item" do
74
- it "shows the updated value"
75
- end
76
+ describe "updating an item" do
77
+ it "shows the updated value"
78
+ end
76
79
 
77
- describe "destroying an item" do
78
- it "should'n be on the list anymore", :js => true do
79
- pending "Needs js, but doesn't work, neither with selenium nor webkit.
80
- When trying to create an user inside the 'without-access-control'-block
81
- it's saved but not found anymore when trying to login"
80
+ describe "destroying an item" do
82
81
 
83
- Event.create!(:name => 'My second Event',
84
- :starts_at => DateTime.new(2012, 03, 02, 8, 15),
85
- :ends_at => DateTime.new(2012, 03, 02, 19, 30),
86
- :description => "something\nfancy",
87
- :published => false,
88
- :entrance_fee => 12.32)
89
-
90
- without_access_control {
91
- create_admin_user
82
+ it "should'n be on the list anymore", :js => true do
92
83
  visit '/admin/events'
93
- click_link 'Delete'
84
+ within('tr', :text => 'My second Event') do
85
+ click_on 'Delete'
86
+ end
87
+ click_on 'Yes'
94
88
  page.should have_content "My Event"
95
89
  page.should_not have_content "My second Event"
96
- }
90
+ end
97
91
  end
98
- end
99
92
 
93
+ end
100
94
  end