Actualizar plugin Checklists a 3.1.18 light
This commit is contained in:
parent
a26f5567af
commit
24560c8598
55 changed files with 992 additions and 307 deletions
|
@ -3,7 +3,7 @@
|
|||
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
|
||||
# issue checklists management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2011-2017 RedmineUP
|
||||
# Copyright (C) 2011-2020 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_checklists is free software: you can redistribute it and/or modify
|
||||
|
@ -44,8 +44,7 @@ class ChecklistsControllerTest < ActionController::TestCase
|
|||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
RedmineChecklists::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_checklists).directory + '/test/fixtures/',
|
||||
[:checklists])
|
||||
RedmineChecklists::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_checklists).directory + '/test/fixtures/', [:checklists])
|
||||
|
||||
def setup
|
||||
RedmineChecklists::TestCase.prepare
|
||||
|
@ -61,7 +60,7 @@ class ChecklistsControllerTest < ActionController::TestCase
|
|||
# log_user('admin', 'admin')
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
xhr :put, :done, :is_done => 'true', :id => '1'
|
||||
compatible_xhr_request :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
|
||||
|
@ -70,7 +69,7 @@ class ChecklistsControllerTest < ActionController::TestCase
|
|||
# log_user('admin', 'admin')
|
||||
@request.session[:user_id] = 5
|
||||
|
||||
xhr :put, :done, :is_done => true, :id => "1"
|
||||
compatible_xhr_request :put, :done, :is_done => true, :id => "1"
|
||||
assert_response 403, "Post done accessible for all"
|
||||
end
|
||||
|
||||
|
@ -78,7 +77,7 @@ class ChecklistsControllerTest < ActionController::TestCase
|
|||
# log_user('admin', 'admin')
|
||||
@request.session[:user_id] = 1
|
||||
@controller = IssuesController.new
|
||||
get :show, :id => @issue_1.id
|
||||
compatible_request :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
|
||||
|
||||
|
@ -86,7 +85,7 @@ class ChecklistsControllerTest < ActionController::TestCase
|
|||
# log_user('anonymous', '')
|
||||
@request.session[:user_id] = 5
|
||||
@controller = IssuesController.new
|
||||
get :show, :id => @issue_1.id
|
||||
compatible_request :get, :show, :id => @issue_1.id
|
||||
assert_select 'ul#checklist_items', false, "Issue view for anonymous"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
|
||||
# issue checklists management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2011-2017 RedmineUP
|
||||
# Copyright (C) 2011-2020 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_checklists is free software: you can redistribute it and/or modify
|
||||
|
@ -49,71 +49,56 @@ class IssuesControllerTest < ActionController::TestCase
|
|||
:journal_details,
|
||||
:queries
|
||||
|
||||
|
||||
RedmineChecklists::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_checklists).directory + '/test/fixtures/',
|
||||
[:checklists])
|
||||
|
||||
RedmineChecklists::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_checklists).directory + '/test/fixtures/', [:checklists])
|
||||
|
||||
def setup
|
||||
@request.session[:user_id] = 1
|
||||
RedmineChecklists::TestCase.prepare
|
||||
end
|
||||
|
||||
def test_new_issue_without_project
|
||||
get :new
|
||||
compatible_request :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
|
||||
compatible_request(: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_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
|
||||
compatible_request :get, :edit, :id => 1
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_get_copy_issue
|
||||
get :new, :project_id => 1, :copy_from => 1
|
||||
compatible_request :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-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"},
|
||||
"0" => {"is_done"=>"0", "subject"=>"FirstChecklist"},
|
||||
"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
|
||||
compatible_xhr_request :put, :update_form, :issue => parameters, :project_id => issue.project
|
||||
else
|
||||
xhr :put, :new,
|
||||
:issue => parameters,
|
||||
:project_id => issue.project
|
||||
compatible_xhr_request :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
|
||||
assert_match 'FirstChecklist', response.body
|
||||
end
|
||||
|
||||
def test_added_attachment_shows_in_log_once
|
||||
|
@ -125,11 +110,10 @@ class IssuesControllerTest < ActionController::TestCase
|
|||
'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
|
||||
compatible_request :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
|
||||
|
@ -144,7 +128,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||
:old_value => '[ ] TEST',
|
||||
:value => '[x] TEST')
|
||||
|
||||
post :show, :id => issue.id
|
||||
compatible_request :post, :show, :id => issue.id
|
||||
assert_response :success
|
||||
last_journal = issue.journals.last
|
||||
assert_equal last_journal.details.size, 1
|
||||
|
@ -156,7 +140,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||
@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
|
||||
compatible_request :post, :update, :issue => {}, :id => issue.to_param, :project_id => issue.project
|
||||
assert_response :redirect
|
||||
assert_equal journals_before, issue.reload.journals.count
|
||||
end
|
||||
|
@ -164,11 +148,11 @@ class IssuesControllerTest < ActionController::TestCase
|
|||
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'
|
||||
}
|
||||
compatible_request :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
|
||||
|
||||
|
@ -176,18 +160,36 @@ class IssuesControllerTest < ActionController::TestCase
|
|||
assert_not_nil issue
|
||||
end
|
||||
|
||||
def test_create_issue_with_checklists
|
||||
@request.session[:user_id] = 1
|
||||
assert_difference 'Issue.count' do
|
||||
compatible_request :post, :create, :project_id => 1, :issue => { :tracker_id => 3,
|
||||
:status_id => 2,
|
||||
:subject => 'NEW issue with checklists',
|
||||
:description => 'This is the description',
|
||||
:checklists_attributes => { '0' => { 'is_done' => '0', 'subject' => 'item 001', 'position' => '1' } }
|
||||
}
|
||||
end
|
||||
assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
|
||||
|
||||
issue = Issue.find_by_subject('NEW issue with checklists')
|
||||
assert_equal 1, issue.checklists.count
|
||||
assert_equal 'item 001', issue.checklists.last.subject
|
||||
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
|
||||
compatible_request :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
|
||||
|
||||
|
@ -197,4 +199,28 @@ class IssuesControllerTest < ActionController::TestCase
|
|||
ensure
|
||||
Setting.rest_api_enabled = old_value
|
||||
end
|
||||
|
||||
def test_history_displaying_for_checklist
|
||||
@request.session[:user_id] = 1
|
||||
Setting[:plugin_redmine_checklists] = { save_log: 1, issue_done_ratio: 0 }
|
||||
|
||||
issue = Issue.find(1)
|
||||
journal = issue.journals.create!(user_id: 1)
|
||||
journal.details.create!(:property => 'attr',
|
||||
:prop_key => 'checklist',
|
||||
:old_value => '[ ] TEST',
|
||||
:value => '[x] TEST')
|
||||
|
||||
# With permissions
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :show, id: issue.id
|
||||
assert_response :success
|
||||
assert_include 'changed from [ ] TEST to [x] TEST', response.body
|
||||
|
||||
# Without permissions
|
||||
@request.session[:user_id] = 5
|
||||
compatible_request :get, :show, id: issue.id
|
||||
assert_response :success
|
||||
assert_not_include 'changed from [ ] TEST to [x] TEST', response.body
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue