Sha256: 92d5bd7232b15070cac05d29cdc4d892e3de70bb4adc9106083d050b098b69cc

Contents?: true

Size: 890 Bytes

Versions: 2

Compression:

Stored size: 890 Bytes

Contents

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

class DraftTest < ActiveSupport::TestCase
  def test_restore
    issue = Issue.new(subject: 'some subject', description: 'some description')

    issue.save_draft(current_user)
    restored_issue = YeshuaCrm::ActsAsDraftable::Draft.find(issue.draft_id).restore

    assert_equal issue.subject, restored_issue.subject
    assert_equal issue.description, restored_issue.description
  end

  def test_restore_all
    first_issue = Issue.new(subject: 'first subject')
    first_issue.save_draft(current_user)
    second_issue = Issue.new(subject: 'second subject')
    second_issue.save_draft(current_user)

    restored_issues = YeshuaCrm::ActsAsDraftable::Draft.restore_all
    assert_equal [first_issue.subject, second_issue.subject], restored_issues.map(&:subject).sort
  end

  private

  def current_user
    users(:sam)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yeshua_crm-1.0.1 test/acts_as_draftable/draft_test.rb
yeshua_crm-1.0.0 test/acts_as_draftable/draft_test.rb