Class: ContentPageTest
- Includes:
- Goldberg::TestHelper
- Defined in:
- lib/six-updater-web/vendor/plugins/goldberg/test/unit/content_page_test.rb
Instance Method Summary collapse
- #setup ⇒ Object
- #test_all_fields ⇒ Object
-
#test_content_cached_on_access ⇒ Object
Test that HTML content is generated when it’s accessed.
-
#test_content_cached_on_save ⇒ Object
Test that HTML content is generated when the page is saved.
- #test_minimal_fields ⇒ Object
- #test_no_fields ⇒ Object
-
#test_uniqueness_of ⇒ Object
Test that name is unique.
-
#test_url_generation ⇒ Object
Test that the URL generated for the page equals the name preceded with a slash.
Methods included from Goldberg::TestHelper
#form_login, #form_logout, included, #login_user
Instance Method Details
#setup ⇒ Object
6 7 8 |
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/content_page_test.rb', line 6 def setup @permission = Goldberg::Permission.find :first end |
#test_all_fields ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/content_page_test.rb', line 10 def test_all_fields page = Goldberg::ContentPage.new(:name => 'test', :title => 'A test') page. = @permission page.markup_style = 'Raw HTML' page.content = 'This is a test' assert page.save end |
#test_content_cached_on_access ⇒ Object
Test that HTML content is generated when it’s accessed
19 20 21 22 23 24 25 26 27 |
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/content_page_test.rb', line 19 def test_content_cached_on_access page = new_page() page.content = 'This is a test' # No content yet assert_nil page.content_cache # Calling #content_html triggers HTML generation assert_not_nil page.content_html assert_not_nil page.content_cache end |
#test_content_cached_on_save ⇒ Object
Test that HTML content is generated when the page is saved
30 31 32 33 34 35 36 37 38 |
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/content_page_test.rb', line 30 def test_content_cached_on_save page = new_page() page.content = 'This is a test' # No content yet assert_nil page.content_cache page.save # Saving triggers HTML generation assert_not_nil page.content_cache end |
#test_minimal_fields ⇒ Object
40 41 42 43 44 |
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/content_page_test.rb', line 40 def test_minimal_fields page = Goldberg::ContentPage.new(:name => 'test', :title => 'A test') page. = @permission assert page.save end |
#test_no_fields ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/content_page_test.rb', line 46 def test_no_fields page = Goldberg::ContentPage.new assert !page.valid? # name, title and permission_id are compulsory [:name, :title, :permission_id].each do |attr| assert page.errors.on(attr) end end |
#test_uniqueness_of ⇒ Object
Test that name is unique
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/content_page_test.rb', line 56 def test_uniqueness_of # Create a page named 'test' and save it page1 = new_page() assert page1.save # Duplicate page name won't work page2 = new_page() assert !page2.save assert page2.errors.on(:name) # Fix name and it should work page2.name = 'test2' assert page2.save end |
#test_url_generation ⇒ Object
Test that the URL generated for the page equals the name preceded with a slash
73 74 75 76 |
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/content_page_test.rb', line 73 def test_url_generation page = new_page() assert_equal page.url, '/test' end |