Sha256: c010cf8876c7af949ac57e41164a7dc421e0d1b223d1cae366629b1c6e9dd875

Contents?: true

Size: 1.33 KB

Versions: 32

Compression:

Stored size: 1.33 KB

Contents

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

ActiveRecord::Base.connection.instance_eval do
  drop_table(:publishables) if table_exists?(:publishables)
  create_table(:publishables) do |t| 
    t.string :name
    t.boolean :published, :default => false
  end
  drop_table(:unpublishables) if table_exists?(:unpublishables)
  create_table(:unpublishables) do |t| 
    t.string :name
  end
end

class Publishable < ActiveRecord::Base
  is_publishable
end

class Unpublishable < ActiveRecord::Base
end

class PublishableTestCase < ActiveSupport::TestCase
  def test_publishable
    @object = Publishable.new(:name => "New Record")
    assert @object.publishable?
  end
  
  def test_save
    @object = Publishable.new(:name => "New Record")
    assert @object.save
    assert !@object.published?
  end

  def test_publish_on_save
    @object = Publishable.new(:name => "New Record")
    @object.publish_on_save = true
    assert @object.save
    log_table_without_stamps Publishable
    assert @object.reload.published?
  end

  def test_unpublishable
    @object = Unpublishable.new(:name => "New Record")
    assert !@object.publishable?
    assert @object.save
    assert !@object.publishable?
  end
  
  def test_not_publishable_if_connect_to_page_id_is_blank
    assert HtmlBlock.new(:connect_to_page_id => "").publishable?
  end
  
end

Version data entries

32 entries across 32 versions & 10 rubygems

Version Path
SFEley-browsercms-3.0.2 test/unit/behaviors/publishable_test.rb
buzzware-browsercms-3.0.2 test/unit/behaviors/publishable_test.rb
coredumplings-browsercms-3.0.0 test/unit/behaviors/publishable_test.rb
we5-browsercms-3.0.1.1 test/unit/behaviors/publishable_test.rb
webficient-browsercms-3.0.1 test/unit/behaviors/publishable_test.rb
webficient-browsercms-3.0.2 test/unit/behaviors/publishable_test.rb
webficient-browsercms-3.0.3 test/unit/behaviors/publishable_test.rb
webficient-browsercms-3.0.4 test/unit/behaviors/publishable_test.rb
browsercms-3.1.4 test/unit/behaviors/publishable_test.rb
browsercms-3.1.3 test/unit/behaviors/publishable_test.rb
bf4-browsercms-3.1.0 test/unit/behaviors/publishable_test.rb
drujensen-browsercms-3.2.0 test/unit/behaviors/publishable_test.rb
browsercmsi-3.1.2 test/unit/behaviors/publishable_test.rb
browsercms-3.1.2 test/unit/behaviors/publishable_test.rb
browsercms-3.1.1 test/unit/behaviors/publishable_test.rb
browsercmsi-3.1.1 test/unit/behaviors/publishable_test.rb
browsercmsi-3.1.0 test/unit/behaviors/publishable_test.rb
browsercms-3.1.0 test/unit/behaviors/publishable_test.rb
we5-browsercms-3.1.0 test/unit/behaviors/publishable_test.rb
browsercms-3.0.6 test/unit/behaviors/publishable_test.rb