Sha256: 684046f17969a1c7adfa4dbcf6cc1512b370fd187d4882acc013f950ebbc934e

Contents?: true

Size: 854 Bytes

Versions: 2

Compression:

Stored size: 854 Bytes

Contents

require_relative "test_helper"

class PluginTest < Minitest::Test
  def setup
    LogBook::Event.destroy_all
    User.destroy_all
    Item.destroy_all

    @user = User.create!(:name => "User Name")
    @item = Item.create!(:title => "Item Title")
  end

  def test_event_on_create
    item = Item.new(:log_book_historian => @user)
    LogBook.expects(:created).with(@user, item)
    item.save!
  end

  def test_event_on_update
    @item.log_book_historian = @user
    LogBook.expects(:updated).with(@user, @item)
    @item.update!(:title => "Other Title")
  end

  def test_event_on_destroy
    @item.log_book_historian = @user
    LogBook.expects(:destroyed).with(@user, @item)
    @item.destroy
  end

  def test_event_on_touch
    @item.log_book_historian = @user
    LogBook.expects(:updated).with(@user, @item)
    @item.touch(:open_at)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
log_book-0.8.5 test/plugin_test.rb
log_book-0.8.3 test/plugin_test.rb