Commit 876a8cee authored by jplang's avatar jplang

Misc tests.

git-svn-id: https://svn.redmine.org/redmine/trunk@13731 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 5b6acf44
......@@ -101,6 +101,17 @@ class QueryTest < ActiveSupport::TestCase
assert !project_ids.include?("2") #private project user cannot see
end
def test_available_filters_should_not_include_fields_disabled_on_all_trackers
Tracker.all.each do |tracker|
tracker.core_fields = Tracker::CORE_FIELDS - ['start_date']
tracker.save!
end
query = IssueQuery.new(:name => '_')
assert_include 'due_date', query.available_filters
assert_not_include 'start_date', query.available_filters
end
def find_issues_with_query(query)
Issue.joins(:status, :tracker, :project, :priority).where(
query.statement
......@@ -556,16 +567,22 @@ class QueryTest < ActiveSupport::TestCase
issues.each {|issue| assert_equal Date.today, issue.due_date}
end
def test_operator_this_week_on_date
query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('due_date', 'w', [''])
find_issues_with_query(query)
def test_operator_date_periods
%w(t ld w lw l2w m lm y).each do |operator|
query = IssueQuery.new(:name => '_')
query.add_filter('due_date', operator, [''])
assert query.valid?
assert query.issues
end
end
def test_operator_this_week_on_datetime
query = IssueQuery.new(:project => Project.find(1), :name => '_')
query.add_filter('created_on', 'w', [''])
find_issues_with_query(query)
def test_operator_datetime_periods
%w(t ld w lw l2w m lm y).each do |operator|
query = IssueQuery.new(:name => '_')
query.add_filter('created_on', operator, [''])
assert query.valid?
assert query.issues
end
end
def test_operator_contains
......@@ -642,6 +659,12 @@ class QueryTest < ActiveSupport::TestCase
assert_equal issue1, result.first
end
def test_filter_on_me_by_anonymous_user
User.current = nil
query = IssueQuery.new(:name => '_', :filters => { 'assigned_to_id' => {:operator => '=', :values => ['me']}})
assert_equal [], query.issues
end
def test_filter_my_projects
User.current = User.find(2)
query = IssueQuery.new(:name => '_')
......
......@@ -459,4 +459,10 @@ class RepositoryTest < ActiveSupport::TestCase
expected = {"Dave Lopper"=>{:commits_count=>11, :changes_count=>3}}
assert_equal expected, repository.stats_by_author
end
def test_fetch_changesets
# 2 repositories in fixtures
Repository::Subversion.any_instance.expects(:fetch_changesets).twice.returns(true)
Repository.fetch_changesets
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment