Nuevo plugin Redmine Checklist 3.1.10 light

This commit is contained in:
Manuel Cillero 2018-02-04 19:51:03 +01:00
parent 294bc87e76
commit ef5521e0a2
65 changed files with 3544 additions and 0 deletions

View file

@ -0,0 +1,16 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
one:
id: 1
is_done: false
subject: First todo
issue_id: 1
two:
id: 2
is_done: true
subject: Second todo
issue_id: 1
three:
id: 3
is_done: true
subject: Third todo
issue_id: 2

View file

@ -0,0 +1,92 @@
# encoding: utf-8
#
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists 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 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists 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 redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
require File.expand_path('../../test_helper', __FILE__)
class ChecklistsControllerTest < ActionController::TestCase
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
RedmineChecklists::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_checklists).directory + '/test/fixtures/',
[:checklists])
def setup
RedmineChecklists::TestCase.prepare
Setting.default_language = 'en'
Project.find(1).enable_module!(:checklists)
User.current = nil
@project_1 = Project.find(1)
@issue_1 = Issue.find(1)
@checklist_1 = Checklist.find(1)
end
test "should post done" do
# log_user('admin', 'admin')
@request.session[:user_id] = 1
xhr :put, :done, :is_done => 'true', :id => '1'
assert_response :success, 'Post done not working'
assert_equal true, Checklist.find(1).is_done, 'Post done not working'
end
test "should not post done by deny user" do
# log_user('admin', 'admin')
@request.session[:user_id] = 5
xhr :put, :done, :is_done => true, :id => "1"
assert_response 403, "Post done accessible for all"
end
test "should view issue with checklist" do
# log_user('admin', 'admin')
@request.session[:user_id] = 1
@controller = IssuesController.new
get :show, :id => @issue_1.id
assert_select 'ul#checklist_items li#checklist_item_1', @checklist_1.subject, "Issue won't view for admin"
end
test "should not view issue with checklist if deny" do
# log_user('anonymous', '')
@request.session[:user_id] = 5
@controller = IssuesController.new
get :show, :id => @issue_1.id
assert_select 'ul#checklist_items', false, "Issue view for anonymous"
end
end

View file

@ -0,0 +1,200 @@
# encoding: utf-8
#
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists 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 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists 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 redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
require File.expand_path('../../test_helper', __FILE__)
# Re-raise errors caught by the controller.
# class HelpdeskMailerController; def rescue_action(e) raise e end; end
class IssuesControllerTest < ActionController::TestCase
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
RedmineChecklists::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_checklists).directory + '/test/fixtures/',
[:checklists])
def setup
@request.session[:user_id] = 1
end
def test_new_issue_without_project
get :new
assert_response :success
end if Redmine::VERSION.to_s > '3.0'
def test_get_show_issue
issue = Issue.find(1)
assert_not_nil issue.checklists.first
get :show, :id => 1
assert_response :success
assert_select "ul#checklist_items li#checklist_item_1", /First todo/
assert_select "ul#checklist_items li#checklist_item_1 input[checked=?]", "checked", {:count => 0}
assert_select "ul#checklist_items li#checklist_item_2 input[checked=?]", "checked"
end
def test_get_edit_issue
get :edit, :id => 1
assert_response :success
end
def test_get_copy_issue
get :new, :project_id => 1, :copy_from => 1
assert_response :success
assert_select "span#checklist_form_items span.checklist-subject", {:count => 3}
assert_select "span#checklist_form_items span.checklist-edit input[value=?]", "First todo"
end
def test_put_update_form
parameters = {:tracker_id => 2,
:checklists_attributes => {
"0" => {"is_done"=>"0", "subject"=>"First"},
"1" => {"is_done"=>"0", "subject"=>"Second"}}}
@request.session[:user_id] = 1
issue = Issue.find(1)
if Redmine::VERSION.to_s > '2.3' && Redmine::VERSION.to_s < '3.0'
xhr :put, :update_form,
:issue => parameters,
:project_id => issue.project
else
xhr :put, :new,
:issue => parameters,
:project_id => issue.project
end
assert_response :success
assert_equal 'text/javascript', response.content_type
if Redmine::VERSION.to_s < '3.0'
assert_template 'update_form'
else
assert_template 'new'
end
issue = assigns(:issue)
assert_kind_of Issue, issue
assert_match 'First', issue.checklists.map(&:subject).join
end
def test_added_attachment_shows_in_log_once
Setting[:plugin_redmine_checklists] = { :save_log => 1, :issue_done_ratio => 0 }
set_tmp_attachments_directory
parameters = { :tracker_id => 2,
:checklists_attributes => {
'0' => { 'is_done' => '0', 'subject' => 'First' },
'1' => { 'is_done' => '0', 'subject' => 'Second' } } }
@request.session[:user_id] = 1
issue = Issue.find(1)
post :update,
:issue => parameters,
:attachments => { '1' => { 'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file' } },
:project_id => issue.project,
:id => issue.to_param
assert_response :redirect
assert_equal 1, Journal.last.details.where(:property => 'attachment').count
end
def test_history_dont_show_old_format_checklists
Setting[:plugin_redmine_checklists] = { :save_log => 1, :issue_done_ratio => 0 }
@request.session[:user_id] = 1
issue = Issue.find(1)
issue.journals.create!(:user_id => 1)
issue.journals.last.details.create!(:property => 'attr',
:prop_key => 'checklist',
:old_value => '[ ] TEST',
:value => '[x] TEST')
post :show, :id => issue.id
assert_response :success
last_journal = issue.journals.last
assert_equal last_journal.details.size, 1
assert_equal last_journal.details.first.prop_key, 'checklist'
assert_select "#change-#{last_journal.id} .details li", 'Checklist item changed from [ ] TEST to [x] TEST'
end
def test_empty_update_dont_write_to_journal
@request.session[:user_id] = 1
issue = Issue.find(1)
journals_before = issue.journals.count
post :update, :issue => {}, :id => issue.to_param, :project_id => issue.project
assert_response :redirect
assert_equal journals_before, issue.reload.journals.count
end
def test_create_issue_without_checklists
@request.session[:user_id] = 1
assert_difference 'Issue.count' do
post :create, :project_id => 1, :issue => { :tracker_id => 3,
:status_id => 2,
:subject => 'NEW issue without checklists',
:description => 'This is the description'
}
end
assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
issue = Issue.find_by_subject('NEW issue without checklists')
assert_not_nil issue
end
def test_create_issue_using_json
old_value = Setting.rest_api_enabled
Setting.rest_api_enabled = '1'
@request.session[:user_id] = 1
assert_difference 'Issue.count' do
post :create, :format => :json, :project_id => 1, :issue => { :tracker_id => 3,
:status_id => 2,
:subject => 'NEW JSON issue',
:description => 'This is the description',
:checklists_attributes => [{:is_done => 0, :subject => 'JSON checklist'}]
},
:key => User.find(1).api_key
end
assert_response :created
issue = Issue.find_by_subject('NEW JSON issue')
assert_not_nil issue
assert_equal 1, issue.checklists.count
ensure
Setting.rest_api_enabled = old_value
end
end

View file

@ -0,0 +1,115 @@
# encoding: utf-8
#
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists 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 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists 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 redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
require File.dirname(__FILE__) + '/../../test_helper'
class Redmine::ApiTest::ChecklistsTest < Redmine::ApiTest::Base
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
RedmineChecklists::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_checklists).directory + '/test/fixtures/',
[:checklists])
def setup
Setting.rest_api_enabled = '1'
end
def test_get_checklists_xml
get '/issues/1/checklists.xml', {}, credentials('admin')
assert_select 'checklists[type=array]' do
assert_select 'checklist' do
assert_select 'id', :text => "1"
assert_select 'subject', :text => "First todo"
end
end
end
def test_get_checklists_1_xml
get '/checklists/1.xml', {}, credentials('admin')
assert_select 'checklist' do
assert_select 'id', :text => '1'
assert_select 'subject', :text => 'First todo'
end
end
def test_post_checklists_xml
parameters = {:checklist => {:issue_id => 1,
:subject => 'api_test_001',
:is_done => true}}
assert_difference('Checklist.count') do
post '/issues/1/checklists.xml', parameters, credentials('admin')
end
checklist = Checklist.order('id DESC').first
assert_equal parameters[:checklist][:subject], checklist.subject
assert_response :created
assert_equal 'application/xml', @response.content_type
assert_select 'checklist id', :text => checklist.id.to_s
end
def test_put_checklists_1_xml
parameters = {:checklist => {:subject => 'Item_UPDATED'}}
assert_no_difference('Checklist.count') do
put '/checklists/1.xml', parameters, credentials('admin')
end
checklist = Checklist.find(1)
assert_equal parameters[:checklist][:subject], checklist.subject
end
def test_delete_1_xml
assert_difference 'Checklist.count', -1 do
delete '/checklists/1.xml', {}, credentials('admin')
end
assert_response :ok
assert_equal '', @response.body
assert_nil Checklist.find_by_id(1)
end
end

View file

@ -0,0 +1,66 @@
# encoding: utf-8
#
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists 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 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists 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 redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
require File.expand_path('../../test_helper', __FILE__)
class CommonIssueTest < RedmineChecklists::IntegrationTest
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
RedmineChecklists::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_checklists).directory + '/test/fixtures/',
[:checklists])
def setup
RedmineChecklists::TestCase.prepare
Setting.default_language = 'en'
@project_1 = Project.find(1)
@issue_1 = Issue.find(1)
@checklist_1 = Checklist.find(1)
@request = ActionController::TestRequest.new
end
test "Global search with checklist" do
# log_user('admin', 'admin')
@request.session[:user_id] = 1
get "/search?q=First"
assert_response :success
end
end

View file

@ -0,0 +1,59 @@
# encoding: utf-8
#
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists 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 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists 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 redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')
if ActiveRecord::VERSION::MAJOR >= 4
class RedmineChecklists::IntegrationTest < Redmine::IntegrationTest; end
else
class RedmineChecklists::IntegrationTest < ActionController::IntegrationTest; end
end
class RedmineChecklists::TestCase
def self.create_fixtures(fixtures_directory, table_names, class_names = {})
if ActiveRecord::VERSION::MAJOR >= 4
ActiveRecord::FixtureSet.create_fixtures(fixtures_directory, table_names, class_names = {})
else
ActiveRecord::Fixtures.create_fixtures(fixtures_directory, table_names, class_names = {})
end
end
def self.prepare
Role.find(1, 2, 3, 4).each do |r|
r.permissions << :edit_checklists
r.save
end
Role.find(3, 4).each do |r|
r.permissions << :done_checklists
r.save
end
Role.find([2]).each do |r|
r.permissions << :manage_checklist_templates
r.save
end
end
end

View file

@ -0,0 +1,93 @@
# encoding: utf-8
#
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists 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 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists 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 redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
require File.expand_path('../../test_helper', __FILE__)
class ChecklistTest < ActiveSupport::TestCase
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
RedmineChecklists::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_checklists).directory + '/test/fixtures/',
[:checklists])
def setup
RedmineChecklists::TestCase.prepare
Setting.default_language = 'en'
@project_1 = Project.find(1)
@issue_1 = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 1,
:status_id => 1, :priority => IssuePriority.first,
:subject => 'Invoice Issue 1')
@checklist_1 = Checklist.create(:subject => 'TEST1', :position => 1, :issue => @issue_1)
end
test "should save checklist" do
assert @checklist_1.save, "Checklist save error"
end
test "should not save checklist without subject" do
@checklist_1.subject = nil
assert !@checklist_1.save, "Checklist save with nil subject"
end
test "should not save checklist without position" do
@checklist_1.position = nil
assert !@checklist_1.save, "Checklist save with nil position"
end
test "should not save checklist with non integer position" do
@checklist_1.position = "string"
assert !@checklist_1.save, "Checklist save with non ingeger position"
end
test "should return project info" do
assert_equal @project_1, @checklist_1.project, "Helper project broken"
end
test "should return info about checklist" do
assert_equal "[ ] #{@checklist_1.subject}", @checklist_1.info, "Helper info broken"
@checklist_1.is_done = 1
assert_equal "[x] #{@checklist_1.subject}", @checklist_1.info, "Helper info broken"
end
end

View file

@ -0,0 +1,73 @@
# encoding: utf-8
#
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists 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 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists 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 redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
require File.expand_path('../../test_helper', __FILE__)
class ProjectTest < ActiveSupport::TestCase
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
RedmineChecklists::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_checklists).directory + '/test/fixtures/',
[:checklists])
def setup
RedmineChecklists::TestCase.prepare
Setting.default_language = 'en'
@project_1 = Project.find(1)
@issue_1 = Issue.create(:project => @project_1, :tracker_id => 1, :author_id => 1,
:status_id => 1, :priority => IssuePriority.first,
:subject => 'TestIssue')
@checklist_1 = Checklist.create(:subject => 'TEST1', :position => 1, :issue => @issue_1)
@checklist_1 = Checklist.create(:subject => 'TEST2', :position => 2, :issue => @issue_1, :is_done => true)
end
test 'should copy checklists' do
project_copy = Project.copy_from(Project.find(1))
project_copy.name = 'Test name'
project_copy.identifier = Project.next_identifier
project_copy.copy(Project.find(1))
checklists_copies = project_copy.issues.where(:subject => 'TestIssue').first.checklists
assert_equal(checklists_copies.count, 2)
assert_equal(checklists_copies.where(:subject => 'TEST1').first.is_done, false)
assert_equal(checklists_copies.where(:subject => 'TEST2').first.is_done, true)
end
end