Skip to content

Commit

Permalink
Misc tests.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.redmine.org/redmine/trunk@13731 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
jplang committed Dec 7, 2014
1 parent b66e68d commit ee173b6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 8 deletions.
39 changes: 31 additions & 8 deletions test/unit/query_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ def test_project_filter_in_global_queries
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
Expand Down Expand Up @@ -556,16 +567,22 @@ def test_operator_today
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
Expand Down Expand Up @@ -642,6 +659,12 @@ def test_user_custom_field_filtered_on_me
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 => '_')
Expand Down
6 changes: 6 additions & 0 deletions test/unit/repository_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -459,4 +459,10 @@ def test_stats_by_author_merge_correctly
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

0 comments on commit ee173b6

Please sign in to comment.