Sha256: 35fd317e5db37f67e22b72c3b4085f5bc81313aefc0f0f5c471ba85985dae952

Contents?: true

Size: 1.03 KB

Versions: 40

Compression:

Stored size: 1.03 KB

Contents

require File.dirname(__FILE__) + '/../test_helper'

class RcrmActsAsViewedTest < ActiveSupport::TestCase
  def user
    users(:jonathan)
  end

  def issue
    issues(:first_issue)
  end

  def test_zero_of_view_count
    assert_equal issue.view_count, '0(0)'
  end

  def test_can_view
    issue.view '127.0.0.1', user
    assert_equal issue.view_count, '1(1)'
    # second view change only total count
    issue.view '127.0.0.1', user
    assert_equal issue.view_count, '2(1)'
  end

  def test_viewed_by
    assert !issue.viewed_by?('127.0.0.1', user)
    issue.view '127.0.0.1', user
    assert issue.viewed_by?('127.0.0.1', user)
  end

  def test_twice_view
    issue.view '127.0.0.1', user
    issue.view '127.0.0.1', user
    assert_equal '2(1)', issue.view_count
  end

  def test_viewed?
    assert !issue.viewed?
    issue.view '127.0.0.1', user
    assert issue.viewed?
  end

  def test_find_viewed_by
    assert_equal [], Issue.find_viewed_by(user)
    issue.view '127.0.0.1', user
    assert_equal [issue], Issue.find_viewed_by(user)
  end
end

Version data entries

40 entries across 40 versions & 3 rubygems

Version Path
redmine_crm-0.0.43 test/acts_as_viewed/rcrm_acts_as_viewed_test.rb
redmine_crm-0.0.42 test/acts_as_viewed/rcrm_acts_as_viewed_test.rb
redmine_crm-0.0.41 test/acts_as_viewed/rcrm_acts_as_viewed_test.rb
redmine_crm-0.0.40 test/acts_as_viewed/rcrm_acts_as_viewed_test.rb
redmine_crm-0.0.38 test/acts_as_viewed/rcrm_acts_as_viewed_test.rb
yeshua_crm-1.0.1 test/acts_as_viewed/rcrm_acts_as_viewed_test.rb
yeshua_crm-1.0.0 test/acts_as_viewed/rcrm_acts_as_viewed_test.rb
yeshoua_crm-1.0.0 test/acts_as_viewed/rcrm_acts_as_viewed_test.rb
redmine_crm-0.0.37 test/acts_as_viewed/rcrm_acts_as_viewed_test.rb
redmine_crm-0.0.36 test/acts_as_viewed/rcrm_acts_as_viewed_test.rb
redmine_crm-0.0.35 test/acts_as_viewed/rcrm_acts_as_viewed_test.rb
redmine_crm-0.0.34 test/acts_as_viewed/rcrm_acts_as_viewed_test.rb
redmine_crm-0.0.33 test/acts_as_viewed/rcrm_acts_as_viewed_test.rb
redmine_crm-0.0.32 test/acts_as_viewed/rcrm_acts_as_viewed_test.rb
redmine_crm-0.0.31 test/acts_as_viewed/rcrm_acts_as_viewed_test.rb
redmine_crm-0.0.30 test/acts_as_viewed/rcrm_acts_as_viewed_test.rb
redmine_crm-0.0.28 test/acts_as_viewed/rcrm_acts_as_viewed_test.rb
redmine_crm-0.0.27 test/acts_as_viewed/rcrm_acts_as_viewed_test.rb
redmine_crm-0.0.26 test/acts_as_viewed/rcrm_acts_as_viewed_test.rb
redmine_crm-0.0.25 test/acts_as_viewed/rcrm_acts_as_viewed_test.rb