Sha256: 1b55b14ac0560ab08b6561cdc175bea8f36fcd95b61c493b3b90343aac383174

Contents?: true

Size: 958 Bytes

Versions: 3

Compression:

Stored size: 958 Bytes

Contents

require 'test_helper'

class ContentTest < ActiveSupport::TestCase

  def setup
    @a = Content.create(:app_id => 1, :position => 1, :title => 'a', :tipe => 'test')
    @b = Content.create(:app_id => 1, :position => 2, :title => 'b', :tipe => 'test')
    @c = Content.create(:app_id => 1, :position => 3, :title => 'c', :tipe => 'test')
  end

  test "content should fix position of other content with similar tipe on save" do
    @c.position = 1
    @c.save

    assert(@c.reload.position == 1)
    assert(@a.reload.position == 2)
    assert(@b.reload.position == 3)
  end

  test "saving multiple pieces of content things kind of escalate out of control ... " do
    @a.position = 3
    @a.save
    assert(3 == @a.reload.position)
    assert(2 == @b.reload.position)
    assert(4 == @c.reload.position)
    @b.position = 3
    @b.save
    assert(3 == @b.reload.position)
    assert(5 == @c.reload.position)
    assert(4 == @a.reload.position)

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
contentment-0.8.4 lib/generators/contentment/templates/content_test.rb
contentment-0.8.3 lib/generators/contentment/templates/content_test.rb
contentment-0.7.1 lib/generators/contentment/templates/content_test.rb