alchemy_cms 2.1.beta6 → 2.1.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. data/.gitignore +3 -1
  2. data/Gemfile +10 -2
  3. data/Guardfile +16 -0
  4. data/README.md +3 -3
  5. data/Rakefile +0 -5
  6. data/alchemy_cms.gemspec +1 -9
  7. data/app/assets/javascripts/alchemy/alchemy.base.js +5 -4
  8. data/app/assets/javascripts/alchemy/{alchemy.dragndrop.js.erb → alchemy.dragndrop.js} +0 -0
  9. data/app/assets/javascripts/alchemy/alchemy.elements_window.js +96 -0
  10. data/app/assets/javascripts/alchemy/alchemy.image_cropper.js +48 -50
  11. data/app/assets/javascripts/alchemy/alchemy.jquery_loader.js +41 -0
  12. data/app/assets/javascripts/alchemy/alchemy.js +2 -0
  13. data/app/assets/javascripts/alchemy/alchemy.menubar.js +55 -0
  14. data/app/assets/javascripts/alchemy/alchemy.preview.js +94 -139
  15. data/app/assets/javascripts/alchemy/alchemy.preview_window.js +98 -0
  16. data/app/assets/javascripts/alchemy/alchemy.windows.js +1 -174
  17. data/app/assets/javascripts/alchemy/menubar.js +2 -0
  18. data/app/assets/javascripts/alchemy/preview.js +2 -1
  19. data/app/assets/stylesheets/alchemy/_defaults.scss +7 -8
  20. data/app/assets/stylesheets/alchemy/base.css.scss +29 -33
  21. data/app/assets/stylesheets/alchemy/elements.css.scss +4 -4
  22. data/app/assets/stylesheets/alchemy/jquery-ui.alchemy.css.scss +1 -1
  23. data/app/assets/stylesheets/alchemy/jquery.Jcrop.css.scss +1 -1
  24. data/app/assets/stylesheets/alchemy/jquery.sb.css.scss +19 -4
  25. data/app/assets/stylesheets/alchemy/menubar.css.scss +85 -0
  26. data/app/assets/stylesheets/alchemy/standard_set.css +3 -5
  27. data/app/assets/stylesheets/alchemy/tinymce_content.css.scss +1 -1
  28. data/app/assets/stylesheets/alchemy/tinymce_dialog.css.scss +1 -1
  29. data/app/controllers/alchemy/admin/attachments_controller.rb +2 -18
  30. data/app/controllers/alchemy/admin/base_controller.rb +1 -1
  31. data/app/controllers/alchemy/admin/elements_controller.rb +2 -2
  32. data/app/controllers/alchemy/admin/essence_files_controller.rb +4 -2
  33. data/app/controllers/alchemy/admin/pictures_controller.rb +6 -20
  34. data/app/controllers/alchemy/admin/resources_controller.rb +7 -5
  35. data/app/controllers/alchemy/base_controller.rb +14 -4
  36. data/app/controllers/alchemy/messages_controller.rb +4 -4
  37. data/app/controllers/alchemy/pages_controller.rb +51 -32
  38. data/app/controllers/alchemy/pictures_controller.rb +0 -3
  39. data/app/controllers/alchemy/user_sessions_controller.rb +1 -1
  40. data/app/helpers/alchemy/admin/base_helper.rb +6 -4
  41. data/app/helpers/alchemy/base_helper.rb +26 -0
  42. data/app/helpers/alchemy/pages_helper.rb +42 -22
  43. data/app/models/alchemy/attachment.rb +10 -2
  44. data/app/models/alchemy/cell.rb +1 -0
  45. data/app/models/alchemy/content.rb +8 -6
  46. data/app/models/alchemy/element.rb +1 -1
  47. data/app/models/alchemy/essence_audio.rb +1 -8
  48. data/app/models/alchemy/essence_date.rb +2 -9
  49. data/app/models/alchemy/essence_file.rb +1 -8
  50. data/app/models/alchemy/essence_flash.rb +0 -7
  51. data/app/models/alchemy/essence_html.rb +1 -8
  52. data/app/models/alchemy/essence_picture.rb +0 -11
  53. data/app/models/alchemy/essence_richtext.rb +4 -12
  54. data/app/models/alchemy/essence_text.rb +1 -13
  55. data/app/models/alchemy/essence_video.rb +1 -8
  56. data/app/models/alchemy/page.rb +28 -22
  57. data/app/models/alchemy/picture.rb +19 -0
  58. data/app/sweepers/alchemy/pages_sweeper.rb +17 -6
  59. data/app/sweepers/alchemy/pictures_sweeper.rb +1 -3
  60. data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +2 -2
  61. data/app/views/alchemy/admin/attachments/_attachment.html.erb +1 -1
  62. data/app/views/alchemy/admin/attachments/_file_to_assign.html.erb +2 -2
  63. data/app/views/alchemy/admin/attachments/_files_list.html.erb +13 -11
  64. data/app/views/alchemy/admin/attachments/create.js.erb +1 -1
  65. data/app/views/alchemy/admin/attachments/edit.html.erb +2 -2
  66. data/app/views/alchemy/admin/elements/_new_element_form.html.erb +1 -2
  67. data/app/views/alchemy/admin/elements/new.html.erb +1 -1
  68. data/app/views/alchemy/admin/essence_files/edit.html.erb +32 -32
  69. data/app/views/alchemy/admin/essence_pictures/crop.html.erb +29 -29
  70. data/app/views/alchemy/admin/essence_pictures/update.js.erb +13 -12
  71. data/app/views/alchemy/admin/pages/_create_language_form.html.erb +4 -1
  72. data/app/views/alchemy/admin/pages/_new_page_form.html.erb +1 -1
  73. data/app/views/alchemy/admin/pages/edit.html.erb +8 -8
  74. data/app/views/alchemy/admin/pages/index.html.erb +1 -1
  75. data/app/views/alchemy/admin/pages/new.html.erb +1 -1
  76. data/app/views/alchemy/admin/pages/update.js.erb +19 -12
  77. data/app/views/alchemy/admin/pictures/_picture.html.erb +1 -1
  78. data/app/views/alchemy/admin/pictures/_pictures_list.html.erb +8 -6
  79. data/app/views/alchemy/admin/pictures/show_in_window.html.erb +6 -1
  80. data/app/views/alchemy/admin/resources/_table.html.erb +1 -1
  81. data/app/views/alchemy/admin/users/_table.html.erb +13 -13
  82. data/app/views/alchemy/admin/users/_user.html.erb +1 -1
  83. data/app/views/alchemy/admin/users/index.html.erb +2 -2
  84. data/app/views/alchemy/elements/_contactform_view.html.erb +78 -78
  85. data/app/views/alchemy/elements/_download_editor.html.erb +1 -0
  86. data/app/views/alchemy/elements/_download_view.html.erb +3 -0
  87. data/app/views/alchemy/essences/_essence_date_editor.html.erb +1 -1
  88. data/app/views/alchemy/essences/_essence_file_editor.html.erb +1 -0
  89. data/app/views/alchemy/essences/_essence_file_view.html.erb +6 -2
  90. data/app/views/alchemy/essences/_essence_picture_editor.html.erb +3 -2
  91. data/app/views/alchemy/essences/_essence_picture_view.html.erb +1 -1
  92. data/app/views/alchemy/navigation/_link.html.erb +1 -2
  93. data/app/views/alchemy/notifications/admin_user_created.text.erb +7 -7
  94. data/app/views/alchemy/notifications/registered_user_created.text.erb +5 -5
  95. data/app/views/alchemy/user_sessions/login.html.erb +34 -35
  96. data/app/views/layouts/alchemy/login.html.erb +3 -8
  97. data/app/views/layouts/alchemy/pages.html.erb +1 -0
  98. data/bin/alchemy +43 -75
  99. data/config/alchemy/config.yml +10 -0
  100. data/config/alchemy/elements.yml +5 -0
  101. data/config/alchemy/page_layouts.yml +1 -1
  102. data/config/locales/alchemy.de.yml +21 -8
  103. data/config/locales/alchemy.en.yml +20 -4
  104. data/config/routes.rb +25 -20
  105. data/db/migrate/{20111116125112_namespace_models.rb → 20111116125112_namespace_alchemy_models.rb} +1 -1
  106. data/lib/alchemy/capistrano.rb +4 -17
  107. data/lib/alchemy/engine.rb +2 -0
  108. data/lib/alchemy/essence.rb +29 -41
  109. data/lib/alchemy/i18n.rb +1 -1
  110. data/lib/alchemy/mount_point.rb +10 -0
  111. data/lib/alchemy/page_layout.rb +7 -7
  112. data/lib/alchemy/seeder.rb +85 -47
  113. data/lib/alchemy/upgrader.rb +115 -0
  114. data/lib/alchemy/version.rb +1 -1
  115. data/lib/alchemy_cms.rb +4 -3
  116. data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +6 -2
  117. data/lib/tasks/ferret.rake +12 -0
  118. data/lib/tasks/install.rake +16 -105
  119. data/lib/tasks/routes.rake +29 -0
  120. data/lib/tasks/upgrade.rake +5 -67
  121. data/spec/controllers/admin/pages_controller_spec.rb +1 -1
  122. data/spec/controllers/pages_controller_spec.rb +31 -0
  123. data/spec/factories.rb +24 -15
  124. data/spec/helpers/admin/base_helper_spec.rb +0 -7
  125. data/spec/helpers/pages_helper_spec.rb +54 -29
  126. data/spec/helpers/url_helpers_spec.rb +40 -0
  127. data/spec/integration/admin/pages_controller_spec.rb +3 -3
  128. data/spec/integration/pages_controller_spec.rb +80 -6
  129. data/spec/integration/security_spec.rb +2 -2
  130. data/spec/models/content_spec.rb +24 -0
  131. data/spec/models/page_spec.rb +174 -47
  132. data/spec/models/picture_spec.rb +54 -0
  133. data/spec/page_layout_spec.rb +2 -2
  134. data/spec/routing_spec.rb +205 -1
  135. data/spec/spec_helper.rb +53 -32
  136. metadata +51 -46
  137. data/lib/alchemy/file_utilz.rb +0 -73
@@ -0,0 +1,29 @@
1
+ desc 'Print out all defined routes in match order, with names. Target specific controller with CONTROLLER=x.'
2
+ task :routes => :environment do
3
+ Rails.application.reload_routes!
4
+ all_routes = Alchemy::Engine.routes.routes
5
+
6
+ if ENV['CONTROLLER']
7
+ all_routes = all_routes.select{ |route| route.defaults[:controller] == ENV['CONTROLLER'] }
8
+ end
9
+
10
+ routes = all_routes.collect do |route|
11
+
12
+ reqs = route.requirements.dup
13
+ reqs[:to] = route.app unless route.app.class.name.to_s =~ /^ActionDispatch::Routing/
14
+ reqs = reqs.empty? ? "" : reqs.inspect
15
+
16
+ {:name => route.name.to_s, :verb => route.verb.to_s, :path => route.path, :reqs => reqs}
17
+ end
18
+
19
+ # Skip the route if it's internal info route
20
+ routes.reject! { |r| r[:path] =~ %r{/rails/info/properties|^/assets} }
21
+
22
+ name_width = routes.map{ |r| r[:name].length }.max
23
+ verb_width = routes.map{ |r| r[:verb].length }.max
24
+ path_width = routes.map{ |r| r[:path].length }.max
25
+
26
+ routes.each do |r|
27
+ puts "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:path].ljust(path_width)} #{r[:reqs]}"
28
+ end
29
+ end
@@ -1,72 +1,10 @@
1
+ require File.join(File.dirname(__FILE__), '../alchemy/upgrader.rb')
2
+
1
3
  namespace :alchemy do
2
-
4
+
3
5
  desc "Upgrades database to Alchemy CMS v#{Alchemy::VERSION}."
4
6
  task :upgrade => :environment do
5
-
6
- # invoke seed task
7
- Rake::Task['db:seed'].invoke
8
-
9
- # Creates Language model if it does not exist (Alchemy CMS prior v1.5)
10
- # Also creates missing associations between pages and languages
11
- Alchemy::Page.all.each do |page|
12
- if !page.language_code.blank? && page.language.nil?
13
- root = page.get_language_root
14
- lang = Alchemy::Language.find_or_create_by_code(
15
- :name => page.language_code.capitalize,
16
- :code => page.language_code,
17
- :frontpage_name => root.name,
18
- :page_layout => root.page_layout,
19
- :public => true
20
- )
21
- page.language = lang
22
- if page.save(:validate => false)
23
- puts "== Set language for page #{page.name} to #{lang.name}"
24
- end
25
- else
26
- puts "== Skipping! Language for page #{page.name} already set."
27
- end
28
- end
29
- default_language = Alchemy::Language.get_default
30
- Alchemy::Page.layoutpages.each do |page|
31
- if page.language.class == String || page.language.nil?
32
- page.language = default_language
33
- if page.save(:validate => false)
34
- puts "== Set language for page #{page.name} to #{default_language.name}"
35
- end
36
- else
37
- puts "== Skipping! Language for page #{page.name} already set."
38
- end
39
- end
40
- (Alchemy::EssencePicture.all + Alchemy::EssenceText.all).each do |essence|
41
- case essence.link_target
42
- when '1'
43
- if essence.update_attribute(:link_target, 'blank')
44
- puts "== Updated #{essence.preview_text} link target to #{essence.link_target}."
45
- end
46
- when '0'
47
- essence.update_attribute(:link_target, nil)
48
- puts "== Updated #{essence.preview_text} link target to #{essence.link_target.inspect}."
49
- end
50
- end
51
-
52
- # Updates all essence_type of Content if not already namespaced.
53
- depricated_contents = Alchemy::Content.where("essence_type LIKE ?", "Essence%")
54
- if depricated_contents.any?
55
- success = 0
56
- errors = []
57
- depricated_contents.each do |c|
58
- if c.update_attribute(:essence_type, c.essence_type.gsub(/^Essence/, 'Alchemy::Essence'))
59
- success += 1
60
- else
61
- errors << c.errors.full_messages
62
- end
63
- end
64
- puts "== Namespaced #{success} Essence-Types." if success > 0
65
- puts "!! #{errors.count} errors while namespacing Essence-Types.\n#{errors.join('\n')}" if errors.count > 0
66
- else
67
- puts "== Skipping! Already namespaced Essence-Types"
68
- end
69
-
7
+ Alchemy::Upgrader.run!
70
8
  end
71
9
 
72
- end
10
+ end
@@ -7,7 +7,7 @@ describe Alchemy::Admin::PagesController do
7
7
  Alchemy::UserSession.create Factory(:admin_user)
8
8
  end
9
9
 
10
- describe "#flush", :focus => true do
10
+ describe "#flush" do
11
11
 
12
12
  it "should remove the cache of all pages" do
13
13
  post :flush, {:format => :js}
@@ -99,4 +99,35 @@ describe Alchemy::PagesController do
99
99
 
100
100
  end
101
101
 
102
+ describe "url nesting" do
103
+
104
+ before(:each) do
105
+ @catalog = Factory(:public_page, :name => "Catalog", :parent_id => @default_language_root.id, :language => @default_language)
106
+ @products = Factory(:public_page, :name => "Products", :parent_id => @catalog.id, :language => @default_language)
107
+ @product = Factory(:public_page, :name => "Screwdriver", :parent_id => @products.id, :language => @default_language)
108
+ @product.elements.find_by_name('article').contents.essence_texts.first.essence.update_attribute(:body, 'screwdriver')
109
+ controller.stub!(:configuration) { |arg| arg == :url_nesting ? true : false }
110
+ end
111
+
112
+ context "with correct levelnames in params" do
113
+
114
+ it "should show the requested page" do
115
+ get :show, {:level1 => 'catalog', :level2 => 'products', :urlname => 'screwdriver'}
116
+ response.status.should == 200
117
+ response.body.should have_content("screwdriver")
118
+ end
119
+
120
+ end
121
+
122
+ context "with incorrect levelnames in params" do
123
+
124
+ it "should show 404 page" do
125
+ get :show, {:level1 => 'catalog', :level2 => 'faqs', :urlname => 'screwdriver'}
126
+ response.status.should == 404
127
+ end
128
+
129
+ end
130
+
131
+ end
132
+
102
133
  end
@@ -34,33 +34,42 @@ FactoryGirl.define do
34
34
  end
35
35
 
36
36
  factory :page, :class => 'Alchemy::Page' do
37
+
37
38
  language { Alchemy::Language.find_by_code('kl') || Factory(:language) }
38
39
  name "A Page"
39
40
  parent_id { Factory(:language_root_page).id }
40
41
  page_layout "standard"
41
42
 
42
- factory :language_root_page do
43
- name 'Klingonian'
44
- page_layout 'intro'
45
- language_root true
46
- public true
47
- parent_id { Alchemy::Page.root.id }
48
- end
43
+ factory :language_root_page do
44
+ name 'Klingonian'
45
+ page_layout 'intro'
46
+ language_root true
47
+ public true
48
+ parent_id { Alchemy::Page.root.id }
49
+ end
49
50
 
50
51
  factory :public_page do
51
- name "A Public Page"
52
- public true
53
- end
52
+ name "A Public Page"
53
+ public true
54
+ end
55
+
56
+ factory :systempage do
57
+ name "Systempage"
58
+ parent_id { Alchemy::Page.root.id }
59
+ language_root false
60
+ page_layout nil
61
+ language nil
62
+ end
54
63
 
55
64
  end
56
-
65
+
57
66
  factory :cell, :class => 'Alchemy::Cell' do
58
67
  page { Alchemy::Page.find_by_language_root(true) || Factory(:language_root_page) }
59
68
  name "A Cell"
60
69
  end
61
-
70
+
62
71
  factory :element, :class => 'Alchemy::Element' do
63
- name 'article'
64
- end
65
-
72
+ name 'article'
73
+ end
74
+
66
75
  end
@@ -38,11 +38,4 @@ describe Alchemy::Admin::BaseHelper do
38
38
 
39
39
  end
40
40
 
41
- context "modules" do
42
- it "should render main navi entries for all core modules" do
43
- pending 'Do not know how to test helpers defined as helper_method in controller'
44
- helper.admin_main_navigation.should have_selector('a.main_navi_entry')
45
- end
46
- end
47
-
48
41
  end
@@ -3,30 +3,61 @@ require 'spec_helper'
3
3
  include Alchemy::BaseHelper
4
4
 
5
5
  describe Alchemy::PagesHelper do
6
-
6
+
7
+ before(:each) do
8
+ helper.stub(:configuration).and_return(false)
9
+ end
10
+
7
11
  it "should render the current page layout" do
8
12
  @page = Factory(:public_page)
9
- helper.stub(:configuration).and_return(true)
10
13
  render_page_layout.should have_selector('div#content')
11
14
  end
12
15
 
13
16
  describe "#render_navigation" do
14
- it "should render the page navigation" do
17
+
18
+ before(:each) do
15
19
  @language = Alchemy::Language.get_default
16
20
  @root_page = Factory(:language_root_page, :language => @language, :name => 'Home')
17
21
  @page = Factory(:public_page, :language => @language, :parent_id => @root_page.id, :visible => true)
18
- helper.stub(:multi_language?).and_return(false)
19
- helper.render_navigation.should have_selector('ul.navigation_level_1 li.a-public-page.active.last a.active[href="/alchemy/a-public-page"]')
20
22
  end
23
+
24
+ context "not in multi_language mode" do
25
+
26
+ before(:each) do
27
+ helper.stub(:multi_language?).and_return(false)
28
+ end
29
+
30
+ it "should render the page navigation" do
31
+ helper.render_navigation.should have_selector('ul.navigation_level_1 li.a-public-page.active.last a.active[href="/alchemy/a-public-page"]')
32
+ end
33
+
34
+ context "with enabled url nesting" do
35
+
36
+ before(:each) do
37
+ helper.stub!(:configuration).and_return(true)
38
+ @level2 = Factory(:public_page, :parent_id => @page.id, :language => @language, :name => 'Level 2', :visible => true)
39
+ @page = Factory(:public_page, :parent_id => @level2.id, :language => @language, :name => 'Nested Page', :visible => true)
40
+ end
41
+
42
+ it "should render nested page links" do
43
+ helper.render_navigation(:all_sub_menues => true).should have_selector('ul li a[href="/alchemy/a-public-page/level-2/nested-page"]')
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+
21
50
  end
22
51
 
23
52
  describe "#render_breadcrumb" do
24
53
 
25
54
  before(:each) do
26
55
  helper.stub(:multi_language?).and_return(false)
56
+ @root = mock_model('Page', :urlname => 'root', :name => 'Root', :title => 'Root', :visible? => false, :public? => false, :restricted? => false)
27
57
  @language_root = mock_model('Page', :urlname => 'language_root', :name => 'Language Root', :title => 'Language Root', :visible? => true, :public? => true, :restricted? => false)
28
58
  @page = mock_model('Page', :urlname => 'a-public-page', :name => 'A Public Page', :title => 'A Public Page', :visible? => true, :public? => true, :restricted? => false)
29
- @language_root.should_receive(:parent).and_return(nil)
59
+ @root.should_receive(:parent).and_return(nil)
60
+ @language_root.should_receive(:parent).and_return(@root)
30
61
  @page.should_receive(:parent).and_return(@language_root)
31
62
  end
32
63
 
@@ -227,12 +258,11 @@ describe Alchemy::PagesHelper do
227
258
  @default_language = Alchemy::Language.get_default
228
259
  @klingonian = Factory(:language)
229
260
  # simulates link_to_public_child = true
230
- helper.stub(:configuration).and_return(true)
231
261
  helper.stub(:multi_language?).and_return(true)
262
+ helper.stub(:configuration) { |arg| arg == :redirect_to_public_child ? true : false }
232
263
  end
233
264
 
234
265
  it "should return nil when having only one public language" do
235
- helper.stub(:configuration).and_return(true)
236
266
  helper.language_switcher.should be nil
237
267
  end
238
268
 
@@ -242,37 +272,32 @@ describe Alchemy::PagesHelper do
242
272
  @default_language_root = Factory(:language_root_page, :language => @default_language, :name => 'Default Language Root')
243
273
  @klingonian_language_root = Factory(:language_root_page)
244
274
  end
245
-
275
+
246
276
  context "and config redirect_to_public_child is set to TRUE" do
247
-
248
- before :each do
249
- # simulates link_to_public_child = true
250
- helper.stub(:configuration).and_return(true)
251
- end
252
-
277
+
253
278
  it "should return nil if only one language_root is public and both do not have children" do
254
279
  @klingonian_language_root.update_attributes(:public => false)
255
280
  helper.language_switcher.should == nil
256
281
  end
257
-
282
+
258
283
  it "should return nil if only one language_root is public and both have none public children" do
259
284
  @klingonian_language_root.update_attributes(:public => false)
260
285
  @default_first_public_child = Factory(:page, :language => @default_language, :parent_id => @default_language_root.id, :public => false, :name => "child1")
261
286
  @klingonian_first_public_child = Factory(:page, :language => @klingonian, :parent_id => @klingonian_language_root.id, :public => false, :name => "child1")
262
287
  helper.language_switcher.should == nil
263
288
  end
264
-
289
+
265
290
  it "should render two links when having two public language_root pages" do
266
291
  helper.language_switcher.should have_selector('a', :count => 2)
267
292
  end
268
-
293
+
269
294
  it "should render two links when having just one public language_root but a public children in both language_roots" do
270
295
  @klingonian_language_root.update_attributes(:public => false)
271
296
  @default_first_public_child = Factory(:page, :language => @default_language, :parent_id => @default_language_root.id, :public => true, :name => "child1")
272
297
  @klingonian_first_public_child = Factory(:page, :language => @klingonian, :parent_id => @klingonian_language_root.id, :public => true, :name => "child1")
273
298
  helper.language_switcher.should have_selector('a', :count => 2)
274
299
  end
275
-
300
+
276
301
  it "should render two links when having two not public language_roots but a public children in both" do
277
302
  @default_language_root.update_attributes(:public => false)
278
303
  @klingonian_language_root.update_attributes(:public => false)
@@ -280,7 +305,7 @@ describe Alchemy::PagesHelper do
280
305
  @klingonian_first_public_child = Factory(:page, :language => @klingonian, :parent_id => @klingonian_language_root.id, :public => true, :name => "child1")
281
306
  helper.language_switcher.should have_selector('a', :count => 2)
282
307
  end
283
-
308
+
284
309
  it "should return nil when having two not public language_roots and a public children in only one of them" do
285
310
  @default_language_root.update_attributes(:public => false)
286
311
  @klingonian_language_root.update_attributes(:public => false)
@@ -288,27 +313,27 @@ describe Alchemy::PagesHelper do
288
313
  @klingonian_first_public_child = Factory(:page, :language => @klingonian, :parent_id => @klingonian_language_root.id, :public => true, :name => "child1")
289
314
  helper.language_switcher.should == nil
290
315
  end
291
-
316
+
292
317
  end
293
-
318
+
294
319
  context "and config redirect_to_public_child is set to FALSE" do
295
-
320
+
296
321
  before :each do
297
322
  # simulates link_to_public_child = false
298
323
  helper.stub(:configuration).and_return(false)
299
324
  end
300
-
325
+
301
326
  it "should render two links when having two public language_root pages" do
302
327
  helper.language_switcher.should have_selector('a', :count => 2)
303
328
  end
304
-
329
+
305
330
  it "should render nil when having just one public language_root but a public children in both language_roots" do
306
331
  @klingonian_language_root.update_attributes(:public => false)
307
332
  @default_first_public_child = Factory(:page, :language => @default_language, :parent_id => @default_language_root.id, :public => true, :name => "child1")
308
333
  @klingonian_first_public_child = Factory(:page, :language => @klingonian, :parent_id => @klingonian_language_root.id, :public => true, :name => "child1")
309
334
  helper.language_switcher.should == nil
310
335
  end
311
-
336
+
312
337
  it "should render nil when having two not public language_roots but a public children in both" do
313
338
  @default_language_root.update_attributes(:public => false)
314
339
  @klingonian_language_root.update_attributes(:public => false)
@@ -316,11 +341,11 @@ describe Alchemy::PagesHelper do
316
341
  @klingonian_first_public_child = Factory(:page, :language => @klingonian, :parent_id => @klingonian_language_root.id, :public => true, :name => "child1")
317
342
  helper.language_switcher.should == nil
318
343
  end
319
-
344
+
320
345
  end
321
-
346
+
322
347
  end
323
-
348
+
324
349
  end
325
350
 
326
351
  end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe "URL generating" do
4
+
5
+ it "should generate a url string for cropped picture" do
6
+ p = show_picture_path(:id => 3, :crop => "crop", :size => "100x33", :name => "kitten", :format => "jpg")
7
+ p.should == "/alchemy/pictures/3/show/100x33/crop/kitten.jpg"
8
+ end
9
+
10
+ it "should generate a url string for cropped and masked picture" do
11
+ p = show_picture_path(:id => 3, :crop => "crop", :crop_from => "0x0", :crop_size => "900x300", :size => "100x33", :name => "kitten", :format => :jpg)
12
+ p.should == "/alchemy/pictures/3/show/100x33/crop/0x0/900x300/kitten.jpg"
13
+ end
14
+
15
+ it "should generate a url string for picture with default format" do
16
+ p = show_picture_path(:id => 3, :size => "100x33", :name => 'kitten')
17
+ p.should == "/alchemy/pictures/3/show/100x33/kitten.#{Alchemy::Config.get(:image_output_format)}"
18
+ end
19
+
20
+ it "should generate a url string for cropped thumbnail" do
21
+ p = thumbnail_path(:id => 3, :crop => "crop", :size => "100x33", :name => "kitten", :format => :jpg)
22
+ p.should == "/alchemy/pictures/3/thumbnails/100x33/crop/kitten.jpg"
23
+ end
24
+
25
+ it "should generate a url string for thumbnail with default name and format" do
26
+ p = thumbnail_path(:id => 3, :size => "100x33")
27
+ p.should == "/alchemy/pictures/3/thumbnails/100x33/thumbnail.png"
28
+ end
29
+
30
+ it "should generate a url string for cropped and masked thumbnail" do
31
+ p = thumbnail_path(:id => 3, :crop_from => "0x0", :crop_size => "900x300", :size => "100x33", :name => "kitten", :format => :jpg)
32
+ p.should == "/alchemy/pictures/3/thumbnails/100x33/0x0/900x300/kitten.jpg"
33
+ end
34
+
35
+ it "should generate a url string for zoomed image" do
36
+ p = zoom_picture_path(:id => 3, :name => "kitten", :format => :jpg)
37
+ p.should == "/alchemy/pictures/3/zoom/kitten.jpg"
38
+ end
39
+
40
+ end
@@ -77,9 +77,9 @@ end
77
77
  # We need this, because the before blocks losing its session under webkit-capybara (https://github.com/thoughtbot/capybara-webkit/issues/222)
78
78
  def login_to_alchemy
79
79
  visit '/alchemy/admin/login'
80
- fill_in('alchemy_user_session_login', :with => 'jdoe')
81
- fill_in('alchemy_user_session_password', :with => 's3cr3t')
82
- click_on('Login')
80
+ fill_in('Username', :with => 'jdoe')
81
+ fill_in('Password', :with => 's3cr3t')
82
+ click_on('login')
83
83
  end
84
84
 
85
85
  end