kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
151 lines
4.9 KiB
151 lines
4.9 KiB
13 years ago
|
#-- encoding: UTF-8
|
||
14 years ago
|
#-- copyright
|
||
12 years ago
|
# OpenProject is a project management system.
|
||
10 years ago
|
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||
14 years ago
|
#
|
||
17 years ago
|
# This program is free software; you can redistribute it and/or
|
||
12 years ago
|
# modify it under the terms of the GNU General Public License version 3.
|
||
14 years ago
|
#
|
||
11 years ago
|
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||
|
# Copyright (C) 2010-2013 the ChiliProject Team
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License
|
||
|
# as published by the Free Software Foundation; either version 2
|
||
|
# of the License, or (at your option) any later version.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program; if not, write to the Free Software
|
||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
#
|
||
14 years ago
|
# See doc/COPYRIGHT.rdoc for more details.
|
||
|
#++
|
||
10 years ago
|
require 'legacy_spec_helper'
|
||
17 years ago
|
|
||
11 years ago
|
describe 'Search' do # FIXME: naming (RSpec-port)
|
||
12 years ago
|
fixtures :all
|
||
17 years ago
|
|
||
11 years ago
|
before do
|
||
17 years ago
|
@project = Project.find(1)
|
||
17 years ago
|
@issue_keyword = '%unable to print recipes%'
|
||
11 years ago
|
@issue = WorkPackage.find(1)
|
||
17 years ago
|
@changeset_keyword = '%very first commit%'
|
||
|
@changeset = Changeset.find(100)
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should search_by_anonymous' do
|
||
17 years ago
|
User.current = nil
|
||
14 years ago
|
|
||
11 years ago
|
r = WorkPackage.search(@issue_keyword).first
|
||
17 years ago
|
assert r.include?(@issue)
|
||
17 years ago
|
r = Changeset.search(@changeset_keyword).first
|
||
17 years ago
|
assert r.include?(@changeset)
|
||
14 years ago
|
|
||
17 years ago
|
# Removes the :view_changesets permission from Anonymous role
|
||
|
remove_permission Role.anonymous, :view_changesets
|
||
14 years ago
|
|
||
11 years ago
|
r = WorkPackage.search(@issue_keyword).first
|
||
17 years ago
|
assert r.include?(@issue)
|
||
17 years ago
|
r = Changeset.search(@changeset_keyword).first
|
||
17 years ago
|
assert !r.include?(@changeset)
|
||
14 years ago
|
|
||
17 years ago
|
# Make the project private
|
||
|
@project.update_attribute :is_public, false
|
||
11 years ago
|
r = WorkPackage.search(@issue_keyword).first
|
||
17 years ago
|
assert !r.include?(@issue)
|
||
17 years ago
|
r = Changeset.search(@changeset_keyword).first
|
||
17 years ago
|
assert !r.include?(@changeset)
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should search_by_user' do
|
||
17 years ago
|
User.current = User.find_by_login('rhill')
|
||
|
assert User.current.memberships.empty?
|
||
14 years ago
|
|
||
11 years ago
|
r = WorkPackage.search(@issue_keyword).first
|
||
17 years ago
|
assert r.include?(@issue)
|
||
17 years ago
|
r = Changeset.search(@changeset_keyword).first
|
||
17 years ago
|
assert r.include?(@changeset)
|
||
14 years ago
|
|
||
17 years ago
|
# Removes the :view_changesets permission from Non member role
|
||
|
remove_permission Role.non_member, :view_changesets
|
||
14 years ago
|
|
||
11 years ago
|
r = WorkPackage.search(@issue_keyword).first
|
||
17 years ago
|
assert r.include?(@issue)
|
||
17 years ago
|
r = Changeset.search(@changeset_keyword).first
|
||
17 years ago
|
assert !r.include?(@changeset)
|
||
14 years ago
|
|
||
17 years ago
|
# Make the project private
|
||
|
@project.update_attribute :is_public, false
|
||
11 years ago
|
r = WorkPackage.search(@issue_keyword).first
|
||
17 years ago
|
assert !r.include?(@issue)
|
||
17 years ago
|
r = Changeset.search(@changeset_keyword).first
|
||
17 years ago
|
assert !r.include?(@changeset)
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should search_by_allowed_member' do
|
||
17 years ago
|
User.current = User.find_by_login('jsmith')
|
||
|
assert User.current.projects.include?(@project)
|
||
14 years ago
|
|
||
11 years ago
|
r = WorkPackage.search(@issue_keyword).first
|
||
17 years ago
|
assert r.include?(@issue)
|
||
17 years ago
|
r = Changeset.search(@changeset_keyword).first
|
||
17 years ago
|
assert r.include?(@changeset)
|
||
|
|
||
|
# Make the project private
|
||
|
@project.update_attribute :is_public, false
|
||
11 years ago
|
r = WorkPackage.search(@issue_keyword).first
|
||
17 years ago
|
assert r.include?(@issue)
|
||
17 years ago
|
r = Changeset.search(@changeset_keyword).first
|
||
17 years ago
|
assert r.include?(@changeset)
|
||
|
end
|
||
|
|
||
11 years ago
|
it 'should search_by_unallowed_member' do
|
||
17 years ago
|
# Removes the :view_changesets permission from user's and non member role
|
||
|
remove_permission Role.find(1), :view_changesets
|
||
|
remove_permission Role.non_member, :view_changesets
|
||
14 years ago
|
|
||
17 years ago
|
User.current = User.find_by_login('jsmith')
|
||
|
assert User.current.projects.include?(@project)
|
||
14 years ago
|
|
||
11 years ago
|
r = WorkPackage.search(@issue_keyword).first
|
||
17 years ago
|
assert r.include?(@issue)
|
||
17 years ago
|
r = Changeset.search(@changeset_keyword).first
|
||
17 years ago
|
assert !r.include?(@changeset)
|
||
|
|
||
|
# Make the project private
|
||
|
@project.update_attribute :is_public, false
|
||
11 years ago
|
r = WorkPackage.search(@issue_keyword).first
|
||
17 years ago
|
assert r.include?(@issue)
|
||
17 years ago
|
r = Changeset.search(@changeset_keyword).first
|
||
17 years ago
|
assert !r.include?(@changeset)
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should search_issue_with_multiple_hits_in_journals' do
|
||
11 years ago
|
i = WorkPackage.find(1)
|
||
11 years ago
|
Journal.delete_all journable_id: i.id
|
||
10 years ago
|
i.add_journal User.current, 'Journal notes'
|
||
11 years ago
|
i.save!
|
||
10 years ago
|
i.add_journal User.current, 'Some notes with Redmine links: #2, r2.'
|
||
11 years ago
|
i.save!
|
||
|
|
||
10 years ago
|
assert_equal 2, i.journals.count(:all, conditions: "notes LIKE '%notes%'")
|
||
14 years ago
|
|
||
11 years ago
|
r = WorkPackage.search('%notes%').first
|
||
17 years ago
|
assert_equal 1, r.size
|
||
|
assert_equal i, r.first
|
||
|
end
|
||
14 years ago
|
|
||
17 years ago
|
private
|
||
14 years ago
|
|
||
17 years ago
|
def remove_permission(role, permission)
|
||
10 years ago
|
role.permissions = role.permissions - [permission]
|
||
17 years ago
|
role.save
|
||
|
end
|
||
|
end
|