Sha256: d6642bef1e6ad5fd7ca52320152beef7cd947942c8b91799b8e4bfdcd3cd3474

Contents?: true

Size: 1.44 KB

Versions: 5

Compression:

Stored size: 1.44 KB

Contents

require File.expand_path('../test_helper', File.dirname(__FILE__))

class FixturesTest < ActionDispatch::IntegrationTest
  
  def setup
    host! 'example.com'
    cms_sites(:default).update_attribute(:hostname, 'example.com')
  end
  
  def test_fixtures_disabled
    assert_no_difference ['Cms::Layout.count', 'Cms::Page.count', 'Cms::Snippet.count'] do
      get '/'
      assert_response :success
      
      assert_equal 'Default Page', Cms::Page.root.label
      assert_equal 'Default Layout', Cms::Layout.find_by_slug('default').label
      assert_equal 'Default Snippet', Cms::Snippet.find_by_slug('default').label
    end
  end
  
  def test_fixtures_enabled
    ComfortableMexicanSofa.config.enable_fixtures = true
    Cms::Layout.destroy_all
    Cms::Page.destroy_all
    Cms::Snippet.destroy_all
    
    assert_difference 'Cms::Page.count', 2 do
      assert_difference 'Cms::Layout.count', 2 do
        assert_difference 'Cms::Snippet.count', 1 do
          get '/'
          assert_response :success
          
          assert_equal 'Home Fixture Page', Cms::Page.root.label
          assert_equal 'Default Fixture Layout', Cms::Layout.find_by_slug('default').label
          assert_equal 'Default Fixture Snippet', Cms::Snippet.find_by_slug('default').label
          
          assert_equal "<html>\n  <body>\n    Home Page Fixture Content\nFixture Content for Default Snippet\n  </body>\n</html>", response.body
        end
      end
    end
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.2.2 test/integration/fixtures_test.rb
comfortable_mexican_sofa-1.2.1 test/integration/fixtures_test.rb
comfortable_mexican_sofa-1.2.0 test/integration/fixtures_test.rb
comfortable_mexican_sofa-1.1.2 test/integration/fixtures_test.rb
comfortable_mexican_sofa-1.1.1 test/integration/fixtures_test.rb