spree_essential_cms 0.3.0.rc1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/.travis.yml +15 -0
- data/Gemfile +2 -0
- data/LICENSE +1 -1
- data/README.md +64 -5
- data/Versionfile +8 -0
- data/app/controllers/spree/admin/contents_controller.rb +4 -4
- data/app/controllers/spree/admin/pages_controller.rb +6 -12
- data/app/controllers/spree/base_controller_decorator.rb +15 -0
- data/app/controllers/spree/home_controller_decorator.rb +23 -0
- data/app/controllers/spree/pages_controller.rb +2 -11
- data/app/models/spree/content.rb +40 -39
- data/app/models/spree/page.rb +21 -10
- data/app/models/spree/page_image.rb +10 -15
- data/app/views/spree/admin/contents/_form.html.erb +9 -4
- data/app/views/spree/admin/contents/edit.html.erb +0 -2
- data/app/views/spree/admin/contents/index.html.erb +22 -23
- data/app/views/spree/admin/contents/new.html.erb +0 -2
- data/app/views/spree/admin/contents/show.html.erb +0 -1
- data/app/views/spree/admin/page_images/edit.html.erb +1 -3
- data/app/views/spree/admin/page_images/index.html.erb +25 -25
- data/app/views/spree/admin/page_images/new.html.erb +3 -1
- data/app/views/spree/admin/pages/edit.html.erb +0 -2
- data/app/views/spree/admin/pages/index.html.erb +26 -26
- data/app/views/spree/admin/pages/new.html.erb +1 -1
- data/app/views/spree/admin/pages/show.html.erb +0 -2
- data/app/views/spree/pages/home.html.erb +10 -0
- data/app/views/spree/shared/_main_menu.html.erb +3 -7
- data/app/views/spree/shared/_main_menu_items.html.erb +6 -0
- data/config/locales/en.yml +1 -0
- data/config/locales/it.yml +63 -0
- data/config/routes.rb +10 -12
- data/{lib/generators/templates/db/migrate/create_pages.rb → db/migrate/20120306185628_create_pages.rb} +0 -0
- data/{lib/generators/templates/db/migrate/create_contents.rb → db/migrate/20120306185638_create_contents.rb} +0 -0
- data/{lib/generators/templates/db/migrate/add_spree_namespace.rb → db/migrate/20120306185648_add_spree_namespace.rb} +0 -0
- data/lib/generators/spree_essentials/cms_generator.rb +3 -8
- data/lib/spree_essential_cms.rb +5 -19
- data/lib/spree_essential_cms/engine.rb +16 -0
- data/lib/spree_essential_cms/version.rb +1 -1
- data/lib/tasks/sample.rake +9 -13
- data/spree_essential_cms.gemspec +34 -0
- data/test/dummy_hooks/after_app_generator.rb +17 -0
- data/test/dummy_hooks/after_migrate.rb.sample +1 -0
- data/test/dummy_hooks/before_migrate.rb +11 -0
- data/test/dummy_hooks/templates/assets/javascripts/admin/all.js +1 -0
- data/test/dummy_hooks/templates/assets/javascripts/store/all.js +1 -0
- data/test/dummy_hooks/templates/assets/stylesheets/admin/all.css +3 -0
- data/test/dummy_hooks/templates/assets/stylesheets/store/all.css +3 -0
- data/test/dummy_hooks/templates/assets/stylesheets/store/screen.css +749 -0
- data/test/dummy_hooks/templates/initializers/spree_user_error_fix.rb +3 -0
- data/test/dummy_hooks/templates/overrides/main_menu.rb +6 -0
- data/test/integration/spree/admin/contents_integration_test.rb +116 -0
- data/test/integration/spree/admin/page_images_integration_test.rb +94 -0
- data/test/integration/spree/admin/pages_integration_test.rb +131 -0
- data/test/integration/spree/home_integration_test.rb +54 -0
- data/test/integration/spree/pages_integration_test.rb +122 -0
- data/test/support/factories.rb +21 -0
- data/test/support/files/1.jpg +0 -0
- data/test/support/files/2.jpg +0 -0
- data/test/support/helpers.rb +13 -0
- data/test/test_helper.rb +19 -0
- data/test/unit/spree/content_test.rb +39 -0
- data/test/unit/spree/essential_test.rb +9 -0
- data/test/unit/spree/page_image_test.rb +47 -0
- data/test/unit/spree/page_test.rb +53 -0
- metadata +117 -48
- data/app/assets/stylesheets/essentials/cms.css +0 -39
- data/app/controllers/spree/page_controller.rb +0 -20
- data/app/controllers/spree/spree_base_controller_decorator.rb +0 -12
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Spree::Admin::ContentsIntegrationTest < SpreeEssentials::IntegrationCase
|
4
|
+
|
5
|
+
setup do
|
6
|
+
Spree::Content.destroy_all
|
7
|
+
@page = Spree::Page.first || Factory.create(:spree_page)
|
8
|
+
end
|
9
|
+
|
10
|
+
should "have a link to new content" do
|
11
|
+
visit spree.admin_page_contents_path(@page)
|
12
|
+
btn = find(".actions a.button").native
|
13
|
+
assert_match /#{spree.new_admin_page_content_path(@page)}$/, btn.attribute('href')
|
14
|
+
assert_equal "New Content", btn.text
|
15
|
+
end
|
16
|
+
|
17
|
+
should "get new content" do
|
18
|
+
visit spree.new_admin_page_content_path(@page)
|
19
|
+
assert has_content?("New Content")
|
20
|
+
within "#new_content" do
|
21
|
+
assert has_field?("Title")
|
22
|
+
assert has_field?("Page")
|
23
|
+
assert has_field?("Body")
|
24
|
+
assert has_field?("Context")
|
25
|
+
assert has_field?("Attachment")
|
26
|
+
assert has_field?("Link URL")
|
27
|
+
assert has_field?("Link Text")
|
28
|
+
assert has_field?("Hide Title")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
should "validate content" do
|
33
|
+
visit spree.new_admin_page_content_path(@page)
|
34
|
+
click_button "Create"
|
35
|
+
within "#errorExplanation" do
|
36
|
+
assert_seen "1 error prohibited this record from being saved:"
|
37
|
+
assert_seen "Title can't be blank"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
should "create some content" do
|
42
|
+
visit spree.new_admin_page_content_path(@page)
|
43
|
+
within "#new_content" do
|
44
|
+
fill_in "Title", :with => "Just some content"
|
45
|
+
select @page.title, :from => "Page"
|
46
|
+
fill_in "Body", :with => "Just some words in the content..."
|
47
|
+
end
|
48
|
+
click_button "Create"
|
49
|
+
assert_equal spree.admin_page_contents_path(@page), current_path
|
50
|
+
assert_flash :notice, "Content has been successfully created!"
|
51
|
+
end
|
52
|
+
|
53
|
+
context "existing content" do
|
54
|
+
setup do
|
55
|
+
@content = Factory.create(:spree_content, :page => @page)
|
56
|
+
end
|
57
|
+
|
58
|
+
should "edit and update" do
|
59
|
+
visit spree.edit_admin_page_content_path(@page, @content)
|
60
|
+
within "#edit_content_#{@content.id}" do
|
61
|
+
fill_in "Title", :with => "Just some content"
|
62
|
+
select @page.title, :from => "Page"
|
63
|
+
fill_in "Body", :with => "Just some words in the content..."
|
64
|
+
end
|
65
|
+
click_button "Update"
|
66
|
+
assert_equal spree.admin_page_contents_path(@page.reload), current_path
|
67
|
+
assert_flash :notice, "Content has been successfully updated!"
|
68
|
+
end
|
69
|
+
|
70
|
+
should "not delete current attachment unless checkbox is checked" do
|
71
|
+
@content.update_attribute(:attachment, sample_image)
|
72
|
+
visit spree.edit_admin_page_content_path(@page, @content)
|
73
|
+
click_button "Update"
|
74
|
+
assert !@content.reload.attachment_file_name.blank?
|
75
|
+
end
|
76
|
+
|
77
|
+
should "delete current attachment" do
|
78
|
+
@content.update_attribute(:attachment, sample_image)
|
79
|
+
visit spree.edit_admin_page_content_path(@page, @content)
|
80
|
+
click_link "Optional Fields"
|
81
|
+
check "Delete current attachment"
|
82
|
+
click_button "Update"
|
83
|
+
assert @content.reload.attachment_file_name.blank?
|
84
|
+
end
|
85
|
+
|
86
|
+
should "get destroyed" do
|
87
|
+
visit spree.admin_page_contents_path(@page)
|
88
|
+
within "table.index" do
|
89
|
+
find("a[href='#']").click
|
90
|
+
end
|
91
|
+
assert find_by_id("popup_ok").click
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
context "several contents" do
|
97
|
+
|
98
|
+
setup do
|
99
|
+
setup_action_controller_behaviour(Spree::Admin::ContentsController)
|
100
|
+
@contents = Array.new(2) {|i| Factory(:spree_content, :title => "Content ##{i + 1}", :page => @page, :position => i) }
|
101
|
+
end
|
102
|
+
|
103
|
+
should "update positions" do
|
104
|
+
positions = Hash[@contents.map{|i| [i.id, 2 - i.position ]}]
|
105
|
+
visit spree.admin_page_contents_path(@page)
|
106
|
+
assert_seen "Content #1", :within => "tbody tr:first"
|
107
|
+
assert_seen "Content #2", :within => "tbody tr:last"
|
108
|
+
xhr :post, :update_positions, { :page_id => @page.to_param, :positions => positions }
|
109
|
+
visit spree.admin_page_contents_path(@page)
|
110
|
+
assert_seen "Content #2", :within => "tbody tr:first"
|
111
|
+
assert_seen "Content #1", :within => "tbody tr:last"
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Spree::Admin::PageImagesIntegrationTest < SpreeEssentials::IntegrationCase
|
4
|
+
|
5
|
+
setup do
|
6
|
+
Spree::PageImage.destroy_all
|
7
|
+
@page = Spree::Page.first || Factory.create(:spree_page)
|
8
|
+
end
|
9
|
+
|
10
|
+
should "have a link to new page image" do
|
11
|
+
visit spree.admin_page_images_path(@page)
|
12
|
+
btn = find("#new_image_link").native
|
13
|
+
assert_match /#{spree.new_admin_page_image_path(@page)}$/, btn.attribute('href')
|
14
|
+
assert_equal "New Image", btn.text
|
15
|
+
end
|
16
|
+
|
17
|
+
should "get new page image" do
|
18
|
+
visit spree.new_admin_page_image_path(@page)
|
19
|
+
assert_seen "New Image"
|
20
|
+
within "#new_page_image" do
|
21
|
+
assert has_field?("Attachment")
|
22
|
+
assert has_field?("Alt")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
should "validate page image" do
|
27
|
+
visit spree.new_admin_page_image_path(@page)
|
28
|
+
click_button "Create"
|
29
|
+
within "#errorExplanation" do
|
30
|
+
assert_seen "2 errors prohibited this record from being saved:"
|
31
|
+
assert_seen "Attachment can't be empty"
|
32
|
+
assert_seen "Attachment file name can't be empty"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
should "create page image" do
|
37
|
+
visit spree.admin_page_images_path(@page)
|
38
|
+
click_link "New Image"
|
39
|
+
within "#new_page_image" do
|
40
|
+
attach_file "Attachment", sample_image_path
|
41
|
+
fill_in "Alt", :with => "alt text!"
|
42
|
+
end
|
43
|
+
click_button "Create"
|
44
|
+
assert_equal spree.admin_page_images_path(@page), current_path
|
45
|
+
assert_flash :notice, "Page image has been successfully created!"
|
46
|
+
end
|
47
|
+
|
48
|
+
context "existing page image" do
|
49
|
+
setup do
|
50
|
+
@page_image = Factory.create(:spree_page_image, :viewable => @page)
|
51
|
+
end
|
52
|
+
|
53
|
+
should "edit and update" do
|
54
|
+
visit spree.edit_admin_page_image_path(@page, @page_image)
|
55
|
+
within "#edit_page_image_#{@page_image.id}" do
|
56
|
+
attach_file "Attachment", sample_image_path("2.jpg")
|
57
|
+
fill_in "Alt", :with => "omg!"
|
58
|
+
end
|
59
|
+
click_button "Update"
|
60
|
+
assert_equal spree.admin_page_images_path(@page), current_path
|
61
|
+
assert_flash :notice, "Page image has been successfully updated!"
|
62
|
+
end
|
63
|
+
|
64
|
+
should "get destroyed" do
|
65
|
+
visit spree.admin_page_images_path(@page)
|
66
|
+
within "table.index" do
|
67
|
+
find("a[href='#']").click
|
68
|
+
end
|
69
|
+
assert find_by_id("popup_ok").click
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
context "several page images" do
|
75
|
+
|
76
|
+
setup do
|
77
|
+
setup_action_controller_behaviour(Spree::Admin::PageImagesController)
|
78
|
+
@page_images = Array.new(2) {|i| Factory(:spree_page_image, :alt => "Image ##{i + 1}", :viewable => @page, :position => i) }
|
79
|
+
end
|
80
|
+
|
81
|
+
should "update positions" do
|
82
|
+
positions = Hash[@page_images.map{|i| [i.id, 2 - i.position ]}]
|
83
|
+
visit spree.admin_page_images_path(@page)
|
84
|
+
assert_seen "Image #1", :within => "tbody tr:first"
|
85
|
+
assert_seen "Image #2", :within => "tbody tr:last"
|
86
|
+
xhr :post, :update_positions, { :page_id => @page.to_param, :positions => positions }
|
87
|
+
visit spree.admin_page_images_path(@page)
|
88
|
+
assert_seen "Image #2", :within => "tbody tr:first"
|
89
|
+
assert_seen "Image #1", :within => "tbody tr:last"
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Spree::Admin::PagesIntegrationTest < SpreeEssentials::IntegrationCase
|
4
|
+
|
5
|
+
setup do
|
6
|
+
Spree::Page.destroy_all
|
7
|
+
@labels = %(Title, Meta Title, Meta Description, Meta Keywords, Path, Navigation Title).split(', ')
|
8
|
+
@values = %(Just a page, Super Sweet Page Title, #{Faker::Lorem.paragraph}, one keyword, /some-page, Visit Page).split(', ')
|
9
|
+
end
|
10
|
+
|
11
|
+
should "get index and have a link to new page" do
|
12
|
+
visit spree.admin_pages_path
|
13
|
+
btn = find(".actions a.button").native
|
14
|
+
assert_match /#{spree.new_admin_page_path}$/, btn.attribute('href')
|
15
|
+
assert_equal "New Page", btn.text
|
16
|
+
end
|
17
|
+
|
18
|
+
should "get new page" do
|
19
|
+
visit spree.new_admin_page_path
|
20
|
+
assert has_content?("New Page")
|
21
|
+
within "#new_page" do
|
22
|
+
@labels.each do |f|
|
23
|
+
assert has_field?(f)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
should "validate page" do
|
29
|
+
visit spree.new_admin_page_path
|
30
|
+
click_button "Create"
|
31
|
+
within "#errorExplanation" do
|
32
|
+
assert_seen "2 errors prohibited this record from being saved:"
|
33
|
+
assert_seen "Title can't be blank"
|
34
|
+
assert_seen "Path can't be blank"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
should "create a page" do
|
39
|
+
visit spree.new_admin_page_path
|
40
|
+
within "#new_page" do
|
41
|
+
@labels.each_with_index do |label, index|
|
42
|
+
fill_in label, :with => @values[index]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
click_button "Create"
|
46
|
+
@page = Spree::Page.last
|
47
|
+
assert_equal spree.edit_admin_page_content_path(@page, @page.contents.first), current_path
|
48
|
+
assert_flash :notice, %(Page "Just a page" has been successfully created!)
|
49
|
+
end
|
50
|
+
|
51
|
+
context "an existing page" do
|
52
|
+
setup do
|
53
|
+
@page = Factory.create(:spree_page)
|
54
|
+
end
|
55
|
+
|
56
|
+
should "get show" do
|
57
|
+
visit spree.admin_page_path(@page)
|
58
|
+
assert_seen @page.meta_title
|
59
|
+
assert_seen @page.meta_description
|
60
|
+
assert_seen @page.meta_keywords
|
61
|
+
assert has_link?("Edit")
|
62
|
+
within "#sidebar" do
|
63
|
+
assert has_link?("Contents")
|
64
|
+
assert has_link?("Images")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
should "edit and update" do
|
69
|
+
visit spree.edit_admin_page_path(@page)
|
70
|
+
|
71
|
+
within "#edit_page_#{@page.id}" do
|
72
|
+
@labels.each_with_index do |label, index|
|
73
|
+
fill_in label, :with => @values[index].reverse
|
74
|
+
end
|
75
|
+
end
|
76
|
+
click_button "Update"
|
77
|
+
assert_equal spree.admin_page_path(@page.reload), current_path
|
78
|
+
assert_flash :notice, %(Page "egap a tsuJ" has been successfully updated!)
|
79
|
+
end
|
80
|
+
|
81
|
+
should "get destroyed" do
|
82
|
+
visit spree.admin_pages_path
|
83
|
+
find("a[href='#']").click
|
84
|
+
assert find_by_id("popup_ok").click
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
context "The homepage" do
|
90
|
+
|
91
|
+
setup do
|
92
|
+
@page = Spree::Page.create(:title => "Home", :meta_title => "Welcome to our homepage!", :path => "/")
|
93
|
+
end
|
94
|
+
|
95
|
+
should "edit and update" do
|
96
|
+
visit spree.edit_admin_page_path(@page)
|
97
|
+
|
98
|
+
within "#edit_page_#{@page.id}" do
|
99
|
+
@labels.each_with_index do |label, index|
|
100
|
+
next if label == "Path"
|
101
|
+
fill_in label, :with => @values[index]
|
102
|
+
end
|
103
|
+
end
|
104
|
+
click_button "Update"
|
105
|
+
assert_equal spree.admin_page_path(@page.reload), current_path
|
106
|
+
assert_flash :notice, %(Page "Just a page" has been successfully updated!)
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
context "several pages" do
|
112
|
+
|
113
|
+
setup do
|
114
|
+
setup_action_controller_behaviour(Spree::Admin::PagesController)
|
115
|
+
@pages = Array.new(2) {|i| Factory(:spree_page, :title => "Page ##{i + 1}", :position => i) }
|
116
|
+
end
|
117
|
+
|
118
|
+
should "update positions" do
|
119
|
+
positions = Hash[@pages.map{|i| [i.id, 2 - i.position ]}]
|
120
|
+
visit spree.admin_pages_path
|
121
|
+
assert_seen "Page #1", :within => "tbody tr:first"
|
122
|
+
assert_seen "Page #2", :within => "tbody tr:last"
|
123
|
+
xhr :post, :update_positions, { :page_id => @page.to_param, :positions => positions }
|
124
|
+
visit spree.admin_pages_path
|
125
|
+
assert_seen "Page #2", :within => "tbody tr:first"
|
126
|
+
assert_seen "Page #1", :within => "tbody tr:last"
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Spree::HomeIntegrationTest < SpreeEssentials::IntegrationCase
|
4
|
+
|
5
|
+
setup do
|
6
|
+
Spree::Page.destroy_all
|
7
|
+
@images = Dir[File.expand_path("../../../../lib/tasks/sample", __FILE__) + "/*.jpg"]
|
8
|
+
end
|
9
|
+
|
10
|
+
should "redirect to products when no homepage is present" do
|
11
|
+
visit "/"
|
12
|
+
assert_equal spree.products_path, current_path
|
13
|
+
end
|
14
|
+
|
15
|
+
context "an existing homepage" do
|
16
|
+
|
17
|
+
setup do
|
18
|
+
@home = Spree::Page.create(:title => "Home", :meta_title => "Welcome to our homepage!", :path => "/")
|
19
|
+
@home.contents.first.update_attributes(:body => "This is a test", :context => "main")
|
20
|
+
@home.contents.create(:title => "Some might say...", :body => "This is another test", :context => "intro")
|
21
|
+
@images.each { |image|
|
22
|
+
image = File.open(image)
|
23
|
+
@home.images.create(:attachment => image, :alt => "Sailing", :viewable => @home)
|
24
|
+
image.close
|
25
|
+
}
|
26
|
+
visit "/"
|
27
|
+
end
|
28
|
+
|
29
|
+
should "have proper page title" do
|
30
|
+
assert_title "Spree Demo Site - Welcome to our homepage!"
|
31
|
+
end
|
32
|
+
|
33
|
+
should "have proper contents" do
|
34
|
+
within ".left .content-main" do
|
35
|
+
assert_seen "Home", :within => "h1.title"
|
36
|
+
assert_seen "This is a test", :within => "p"
|
37
|
+
end
|
38
|
+
within ".intro .content-main" do
|
39
|
+
assert_seen "Some might say...", :within => "h1.title"
|
40
|
+
assert_seen "This is another test", :within => "p"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
should "have a images in slideshow" do
|
45
|
+
within "#content .slideshow" do
|
46
|
+
@home.images.each do |img|
|
47
|
+
assert has_xpath?("//img[@src='#{img.attachment.url(:slide)}']")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Spree::PagesIntegrationTest < SpreeEssentials::IntegrationCase
|
4
|
+
|
5
|
+
setup do
|
6
|
+
Spree::Page.destroy_all
|
7
|
+
@images = Dir[File.expand_path("../../../../lib/tasks/sample", __FILE__) + "/*.jpg"]
|
8
|
+
end
|
9
|
+
|
10
|
+
context "any other page" do
|
11
|
+
|
12
|
+
setup do
|
13
|
+
@page = Spree::Page.create(:title => "Some Page", :meta_description => "This is the description", :meta_keywords => "just, a, keyword", :path => "/some-page")
|
14
|
+
end
|
15
|
+
|
16
|
+
should "have proper meta tags" do
|
17
|
+
visit @page.path
|
18
|
+
assert_title "Spree Demo Site - Some Page"
|
19
|
+
assert_meta :description, "This is the description"
|
20
|
+
assert_meta :keywords, "just, a, keyword"
|
21
|
+
end
|
22
|
+
|
23
|
+
context "with content that doesn't have an image" do
|
24
|
+
|
25
|
+
setup do
|
26
|
+
@page.contents.first.update_attributes(:body => "OMG it really is a page")
|
27
|
+
end
|
28
|
+
|
29
|
+
should "have proper content" do
|
30
|
+
visit @page.path
|
31
|
+
within ".content-main" do
|
32
|
+
assert_seen "Some Page", :within => "h1.title"
|
33
|
+
assert_seen "OMG it really is a page", :within => "p"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
should "hide title is specified" do
|
38
|
+
@page.contents.first.update_attributes(:hide_title => true)
|
39
|
+
visit @page.path
|
40
|
+
within ".content-main" do
|
41
|
+
assert !has_selector?("h1.title")
|
42
|
+
assert_seen "OMG it really is a page", :within => "p"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
context "with content that has an image" do
|
50
|
+
|
51
|
+
setup do
|
52
|
+
@content = @page.contents.first
|
53
|
+
@content.update_attributes(:body => "OMG it really is a page", :attachment => File.open(@images.first))
|
54
|
+
end
|
55
|
+
|
56
|
+
should "have proper content" do
|
57
|
+
visit @page.path
|
58
|
+
within ".content-left" do
|
59
|
+
assert has_xpath?("//img[@src='#{@content.attachment.url(:medium)}']")
|
60
|
+
end
|
61
|
+
within ".content-right" do
|
62
|
+
assert_seen "Some Page", :within => "h1.title"
|
63
|
+
assert_seen "OMG it really is a page", :within => "p"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
context "with several existing pages" do
|
73
|
+
|
74
|
+
setup do
|
75
|
+
@home_page = Factory.create(:spree_page, :title => "Home", :path => "/", :position => 1)
|
76
|
+
@another_home = Factory.create(:spree_page, :title => "Another Home", :path => "/home", :position => 2)
|
77
|
+
@about_page = Factory.create(:spree_page, :title => "About", :path => "/about-us", :position => 3)
|
78
|
+
@nested_page = Factory.create(:spree_page, :title => "Our Services", :path => "/about-us/services", :position => 4)
|
79
|
+
end
|
80
|
+
|
81
|
+
should "get the homepage" do
|
82
|
+
visit "/"
|
83
|
+
assert_title @home_page.title
|
84
|
+
end
|
85
|
+
|
86
|
+
should "get the page called home" do
|
87
|
+
visit "/home"
|
88
|
+
assert_title @another_home.title
|
89
|
+
end
|
90
|
+
|
91
|
+
should "get the about page" do
|
92
|
+
visit "/about-us"
|
93
|
+
assert_title @about_page.title
|
94
|
+
end
|
95
|
+
|
96
|
+
should "get a nested page" do
|
97
|
+
visit "/about-us/services"
|
98
|
+
assert_title @nested_page.title
|
99
|
+
end
|
100
|
+
|
101
|
+
should "render 404" do
|
102
|
+
visit "/a/page/that/doesnt/exist"
|
103
|
+
assert_seen "Error"
|
104
|
+
end
|
105
|
+
|
106
|
+
should "have a proper main menu" do
|
107
|
+
visit "/"
|
108
|
+
Spree::Page.order(:position).all.each do |page|
|
109
|
+
assert_seen page.nav_title, :within => "#main-nav-bar li:nth-child(#{page.position}) a"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
should "only have pages marked visible in main menu" do
|
114
|
+
@about_page.update_attribute(:visible, false)
|
115
|
+
visit "/"
|
116
|
+
within "#main-nav-bar" do
|
117
|
+
assert !has_content?(@about_page.nav_title)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
end
|