Sha256: 59355cafe73c53b7985b0746ca649120d5b936f976d1f8d2ec3140b928eef006

Contents?: true

Size: 892 Bytes

Versions: 2

Compression:

Stored size: 892 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 = RedmineCrm::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 = RedmineCrm::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
redmine_crm-0.0.38 test/acts_as_draftable/draft_test.rb
redmine_crm-0.0.37 test/acts_as_draftable/draft_test.rb