mirror of
https://github.com/anteo/redmine_custom_workflows.git
synced 2026-01-25 15:54:19 +00:00
Redmine 5.1
This commit is contained in:
parent
bf87b60215
commit
0b4ab8302d
@ -65,8 +65,6 @@ class CustomWorkflowsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def edit; end
|
||||
|
||||
def new
|
||||
@workflow = CustomWorkflow.new
|
||||
@workflow.author = cookies[:custom_workflows_author]
|
||||
@ -75,6 +73,8 @@ class CustomWorkflowsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def edit; end
|
||||
|
||||
def import
|
||||
xml = params[:file].read
|
||||
begin
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
# 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
|
||||
# You should have received a copy of the GN73U 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.
|
||||
|
||||
@ -70,7 +70,7 @@ class CustomWorkflow < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.log_message(str, object)
|
||||
Rails.logger.info "#{str} for #{object.class} (\##{object.id}) \"#{object}\""
|
||||
Rails.logger.info "#{str} for #{object.class} (##{object.id}) \"#{object}\""
|
||||
end
|
||||
|
||||
def self.run_shared_code(object)
|
||||
|
||||
@ -25,7 +25,7 @@ class CreateCustomWorkflows < ActiveRecord::Migration[4.2]
|
||||
create_table :custom_workflows, force: true do |t|
|
||||
t.references :project
|
||||
t.text :script, null: true, default: nil
|
||||
t.boolean :is_enabled
|
||||
t.boolean :is_enabled, null: false, default: false
|
||||
t.timestamps
|
||||
t.index :project_id, unique: true
|
||||
end
|
||||
|
||||
@ -34,7 +34,7 @@ class AlterCustomWorkflows < ActiveRecord::Migration[4.2]
|
||||
def down
|
||||
change_table(:custom_workflows, bulk: true) do |t|
|
||||
t.references :project
|
||||
t.boolean :is_enabled
|
||||
t.boolean :is_enabled, null: false, default: false
|
||||
t.remove :name
|
||||
t.remove :description
|
||||
t.remove :position
|
||||
|
||||
@ -52,7 +52,7 @@ module RedmineCustomWorkflows
|
||||
next if o&.custom_workflow_messages&.empty?
|
||||
|
||||
o.custom_workflow_messages.each do |key, value|
|
||||
if value&.present?
|
||||
if value.present?
|
||||
flash[key] = value
|
||||
else
|
||||
flash.delete key
|
||||
|
||||
@ -52,7 +52,7 @@ module RedmineCustomWorkflows
|
||||
next if o&.custom_workflow_messages&.empty?
|
||||
|
||||
o.custom_workflow_messages.each do |key, value|
|
||||
if value&.present?
|
||||
if value.present?
|
||||
flash[key] = value
|
||||
else
|
||||
flash.delete key
|
||||
|
||||
@ -52,7 +52,7 @@ module RedmineCustomWorkflows
|
||||
next if o&.custom_workflow_messages&.empty?
|
||||
|
||||
o.custom_workflow_messages.each do |key, value|
|
||||
if value&.present?
|
||||
if value.present?
|
||||
flash[key] = value
|
||||
else
|
||||
flash.delete key
|
||||
|
||||
@ -52,7 +52,7 @@ module RedmineCustomWorkflows
|
||||
next if o&.custom_workflow_messages&.empty?
|
||||
|
||||
o.custom_workflow_messages.each do |key, value|
|
||||
if value&.present?
|
||||
if value.present?
|
||||
flash[key] = value
|
||||
else
|
||||
flash.delete key
|
||||
|
||||
@ -52,7 +52,7 @@ module RedmineCustomWorkflows
|
||||
next if o&.custom_workflow_messages&.empty?
|
||||
|
||||
o.custom_workflow_messages.each do |key, value|
|
||||
if value&.present?
|
||||
if value.present?
|
||||
flash[key] = value
|
||||
else
|
||||
flash.delete key
|
||||
|
||||
@ -52,7 +52,7 @@ module RedmineCustomWorkflows
|
||||
next if o&.custom_workflow_messages&.empty?
|
||||
|
||||
o.custom_workflow_messages.each do |key, value|
|
||||
if value&.present?
|
||||
if value.present?
|
||||
flash[key] = value
|
||||
else
|
||||
flash.delete key
|
||||
|
||||
@ -52,7 +52,7 @@ module RedmineCustomWorkflows
|
||||
next if o&.custom_workflow_messages&.empty?
|
||||
|
||||
o.custom_workflow_messages.each do |key, value|
|
||||
if value&.present?
|
||||
if value.present?
|
||||
flash[key] = value
|
||||
else
|
||||
flash.delete key
|
||||
|
||||
@ -52,7 +52,7 @@ module RedmineCustomWorkflows
|
||||
next if o&.custom_workflow_messages&.empty?
|
||||
|
||||
o.custom_workflow_messages.each do |key, value|
|
||||
if value&.present?
|
||||
if value.present?
|
||||
flash[key] = value
|
||||
else
|
||||
flash.delete key
|
||||
|
||||
@ -52,7 +52,7 @@ module RedmineCustomWorkflows
|
||||
next if o&.custom_workflow_messages&.empty?
|
||||
|
||||
o.custom_workflow_messages.each do |key, value|
|
||||
if value&.present?
|
||||
if value.present?
|
||||
flash[key] = value
|
||||
else
|
||||
flash.delete key
|
||||
|
||||
@ -52,7 +52,7 @@ module RedmineCustomWorkflows
|
||||
next if o&.custom_workflow_messages&.empty?
|
||||
|
||||
o.custom_workflow_messages.each do |key, value|
|
||||
if value&.present?
|
||||
if value.present?
|
||||
flash[key] = value
|
||||
else
|
||||
flash.delete key
|
||||
|
||||
@ -28,18 +28,18 @@ class AttachmentsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||
def setup
|
||||
super
|
||||
@attachment8 = Attachment.find 8
|
||||
@request.session[:user_id] = @jsmith.id
|
||||
post '/login', params: { username: 'jsmith', password: 'jsmith' }
|
||||
@controller = AttachmentsController.new
|
||||
end
|
||||
|
||||
def test_delete_with_cw
|
||||
delete :destroy, params: { id: @attachment8.id }
|
||||
delete "/attachments/#{@attachment8.id}"
|
||||
assert_response :redirect
|
||||
assert_equal 'Custom workflow', @controller.flash[:notice]
|
||||
end
|
||||
|
||||
def test_cw_env
|
||||
delete :destroy, params: { id: @attachment8.id }
|
||||
delete "/attachments/#{@attachment8.id}"
|
||||
assert_response :redirect
|
||||
assert_equal request.remote_ip, @controller.flash[:warning]
|
||||
end
|
||||
|
||||
@ -28,8 +28,6 @@ class CustomWorkflowsControllerTest < RedmineCustomWorkflows::Test::TestCase
|
||||
def setup
|
||||
super
|
||||
@cw1 = CustomWorkflow.find 1
|
||||
User.current = nil
|
||||
@request.session[:user_id] = @admin.id
|
||||
end
|
||||
|
||||
def test_truth
|
||||
@ -37,13 +35,14 @@ class CustomWorkflowsControllerTest < RedmineCustomWorkflows::Test::TestCase
|
||||
end
|
||||
|
||||
def test_index_admin
|
||||
get :index
|
||||
post '/login', params: { username: 'admin', password: 'admin' }
|
||||
get '/custom_workflows'
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_index_non_admin
|
||||
@request.session[:user_id] = @jsmith.id
|
||||
get :index
|
||||
post '/login', params: { username: 'jsmith', password: 'jsmith' }
|
||||
get '/custom_workflows'
|
||||
assert_response :forbidden
|
||||
end
|
||||
end
|
||||
|
||||
@ -28,22 +28,22 @@ class GroupControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||
def setup
|
||||
super
|
||||
@group10 = Group.find 10
|
||||
@request.session[:user_id] = @admin.id
|
||||
post '/login', params: { username: 'admin', password: 'admin' }
|
||||
@controller = GroupsController.new
|
||||
default_url_options[:host] = 'test.host'
|
||||
default_url_options[:host] = 'www.example.com'
|
||||
end
|
||||
|
||||
def test_update_with_cw
|
||||
@request.headers['Referer'] = edit_group_path(id: @group10.id)
|
||||
put :update, params: { id: @group10.id, group: { name: 'Updated name' } }
|
||||
assert_redirected_to edit_group_path(id: @group10.id)
|
||||
put "/groups/#{@group10.id}", params: { group: { name: 'Updated name' } }
|
||||
assert_redirected_to groups_path
|
||||
assert_equal 'Custom workflow', @controller.flash[:notice]
|
||||
end
|
||||
|
||||
def test_cw_env
|
||||
@request.headers['Referer'] = edit_group_path(id: @group10.id)
|
||||
put :update, params: { id: @group10.id, group: { name: 'Updated name' } }
|
||||
assert_redirected_to edit_group_path(id: @group10.id)
|
||||
put "/groups/#{@group10.id}/", params: { group: { name: 'Updated name' } }
|
||||
assert_redirected_to groups_path
|
||||
assert_equal request.remote_ip, @controller.flash[:warning]
|
||||
end
|
||||
end
|
||||
|
||||
@ -29,18 +29,18 @@ class IssueRelationsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||
def setup
|
||||
super
|
||||
@ir1 = IssueRelation.find 1
|
||||
@request.session[:user_id] = @jsmith.id
|
||||
post '/login', params: { username: 'jsmith', password: 'jsmith' }
|
||||
@controller = AttachmentsController.new
|
||||
end
|
||||
|
||||
def test_delete_with_cw
|
||||
delete :destroy, params: { id: @ir1 }
|
||||
delete "/relations/#{@ir1.id}"
|
||||
assert_response :redirect
|
||||
assert_equal 'Custom workflow', @controller.flash[:notice]
|
||||
end
|
||||
|
||||
def test_cw_env
|
||||
delete :destroy, params: { id: @ir1 }
|
||||
delete "/relations/#{@ir1.id}"
|
||||
assert_response :redirect
|
||||
assert_equal request.remote_ip, @controller.flash[:warning]
|
||||
end
|
||||
|
||||
@ -29,26 +29,26 @@ class IssuesControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||
def setup
|
||||
super
|
||||
@issue1 = Issue.find 1
|
||||
@request.session[:user_id] = @jsmith.id
|
||||
post '/login', params: { username: 'jsmith', password: 'jsmith' }
|
||||
@controller = IssuesController.new
|
||||
end
|
||||
|
||||
def test_update_with_cw
|
||||
put :update, params: { id: @issue1.id, issue: { subject: 'Updated subject' } }
|
||||
assert_redirected_to action: 'show', id: @issue1.id
|
||||
put "/issues/#{@issue1.id}", params: { issue: { subject: 'Updated subject' } }
|
||||
assert_redirected_to issue_path(@issue1)
|
||||
assert_equal 'Custom workflow', @controller.flash[:notice]
|
||||
end
|
||||
|
||||
def test_delete_with_cw
|
||||
delete :destroy, params: { id: @issue1.id, todo: 'destroy' }
|
||||
delete "/issues/#{@issue1.id}", params: { todo: 'destroy' }
|
||||
assert_response :redirect
|
||||
assert_equal 'Issue cannot be deleted', @controller.flash[:error]
|
||||
assert Issue.find_by(id: @issue1.id)
|
||||
end
|
||||
|
||||
def test_cw_env
|
||||
put :update, params: { id: @issue1.id, issue: { subject: 'Updated subject' } }
|
||||
assert_redirected_to action: 'show', id: @issue1.id
|
||||
put "/issues/#{@issue1.id}", params: { issue: { subject: 'Updated subject' } }
|
||||
assert_redirected_to issue_path(@issue1)
|
||||
assert_equal request.remote_ip, @controller.flash[:warning]
|
||||
end
|
||||
end
|
||||
|
||||
@ -27,18 +27,18 @@ class MembersControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||
def setup
|
||||
super
|
||||
@member1 = Member.find 1
|
||||
@request.session[:user_id] = @jsmith.id
|
||||
post '/login', params: { username: 'jsmith', password: 'jsmith' }
|
||||
@controller = MembersController.new
|
||||
end
|
||||
|
||||
def test_delete_with_cw
|
||||
delete :destroy, params: { id: @member1 }
|
||||
delete "/memberships/#{@member1.id}"
|
||||
assert_response :redirect
|
||||
assert_equal 'Custom workflow', @controller.flash[:notice]
|
||||
end
|
||||
|
||||
def test_cw_env
|
||||
delete :destroy, params: { id: @member1 }
|
||||
delete "/memberships/#{@member1.id}"
|
||||
assert_response :redirect
|
||||
assert_equal request.remote_ip, @controller.flash[:warning]
|
||||
end
|
||||
|
||||
@ -27,18 +27,18 @@ class ProjectsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||
|
||||
def setup
|
||||
super
|
||||
@request.session[:user_id] = @jsmith.id
|
||||
post '/login', params: { username: 'jsmith', password: 'jsmith' }
|
||||
@controller = ProjectsController.new
|
||||
end
|
||||
|
||||
def test_update_with_cw
|
||||
post :update, params: { id: @project1.id, project: { name: 'Updated name' } }
|
||||
patch "/projects/#{@project1.id}", params: { project: { name: 'Updated name' } }
|
||||
assert_redirected_to settings_project_path(@project1)
|
||||
assert_equal 'Custom workflow', @controller.flash[:notice]
|
||||
end
|
||||
|
||||
def test_cw_env
|
||||
post :update, params: { id: @project1.id, project: { name: 'Updated name' } }
|
||||
patch "/projects/#{@project1.id}", params: { project: { name: 'Updated name' } }
|
||||
assert_redirected_to settings_project_path(@project1)
|
||||
assert_equal request.remote_ip, @controller.flash[:warning]
|
||||
end
|
||||
|
||||
@ -29,18 +29,18 @@ class TimelogControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||
def setup
|
||||
super
|
||||
@te1 = TimeEntry.find 1
|
||||
@request.session[:user_id] = @jsmith.id
|
||||
post '/login', params: { username: 'jsmith', password: 'jsmith' }
|
||||
@controller = TimelogController.new
|
||||
end
|
||||
|
||||
def test_delete_with_cw
|
||||
delete :destroy, params: { id: @te1 }
|
||||
delete "/time_entries/#{@te1.id}"
|
||||
assert_response :redirect
|
||||
assert_equal 'Custom workflow', @controller.flash[:notice]
|
||||
end
|
||||
|
||||
def test_cw_env
|
||||
delete :destroy, params: { id: @te1 }
|
||||
delete "/time_entries/#{@te1.id}"
|
||||
assert_response :redirect
|
||||
assert_equal request.remote_ip, @controller.flash[:warning]
|
||||
end
|
||||
|
||||
@ -26,19 +26,19 @@ class UsersControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||
|
||||
def setup
|
||||
super
|
||||
@request.session[:user_id] = @admin.id
|
||||
post '/login', params: { username: 'admin', password: 'admin' }
|
||||
@controller = UsersController.new
|
||||
end
|
||||
|
||||
def test_update_with_cw
|
||||
put :update, params: { id: @jsmith.id, user: { lastname: 'updated_lastname' } }
|
||||
assert_redirected_to edit_user_path(id: @jsmith.id)
|
||||
put "/users/#{@jsmith.id}", params: { user: { lastname: 'updated_lastname' } }
|
||||
assert_redirected_to edit_user_path(@jsmith)
|
||||
assert_equal 'Custom workflow', @controller.flash[:notice]
|
||||
end
|
||||
|
||||
def test_cw_env
|
||||
put :update, params: { id: @jsmith.id, user: { lastname: 'updated_lastname' } }
|
||||
assert_redirected_to edit_user_path(id: @jsmith.id)
|
||||
put "/users/#{@jsmith.id}", params: { user: { lastname: 'updated_lastname' } }
|
||||
assert_redirected_to edit_user_path(@jsmith)
|
||||
assert_equal request.remote_ip, @controller.flash[:warning]
|
||||
end
|
||||
end
|
||||
|
||||
@ -27,18 +27,18 @@ class VersionsControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||
def setup
|
||||
super
|
||||
@version1 = Version.find 1
|
||||
@request.session[:user_id] = @jsmith.id
|
||||
post '/login', params: { username: 'jsmith', password: 'jsmith' }
|
||||
@controller = VersionsController.new
|
||||
end
|
||||
|
||||
def test_update_with_cw
|
||||
put :update, params: { id: @version1.id, version: { name: 'Updated version' } }
|
||||
put "/versions/#{@version1.id}", params: { version: { name: 'Updated version' } }
|
||||
assert_redirected_to settings_project_path(id: @project1, tab: 'versions')
|
||||
assert_equal 'Custom workflow', @controller.flash[:notice]
|
||||
end
|
||||
|
||||
def test_cw_env
|
||||
put :update, params: { id: @version1.id, version: { name: 'Updated version' } }
|
||||
put "/versions/#{@version1.id}", params: { version: { name: 'Updated version' } }
|
||||
assert_redirected_to settings_project_path(id: @project1, tab: 'versions')
|
||||
assert_equal request.remote_ip, @controller.flash[:warning]
|
||||
end
|
||||
|
||||
@ -29,15 +29,13 @@ class WikiControllerPatchTest < RedmineCustomWorkflows::Test::TestCase
|
||||
def setup
|
||||
super
|
||||
@wp1 = WikiPage.find 1
|
||||
@request.session[:user_id] = @jsmith.id
|
||||
post '/login', params: { username: 'jsmith', password: 'jsmith' }
|
||||
@controller = WikiController.new
|
||||
end
|
||||
|
||||
def test_update_with_cw
|
||||
put :update,
|
||||
put "/projects/#{@projects1.id}/wiki/Another_page",
|
||||
params: {
|
||||
project_id: @project1.id,
|
||||
id: 'Another_page',
|
||||
content: { comments: 'my comments', text: 'edited', version: 1 }
|
||||
}
|
||||
assert_response :redirect
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
module RedmineCustomWorkflows
|
||||
module Test
|
||||
# Test case base class
|
||||
class TestCase < ActionController::TestCase
|
||||
class TestCase < ActionDispatch::IntegrationTest
|
||||
fixtures :users, :email_addresses, :projects
|
||||
|
||||
# Allow us to override the fixtures method to implement fixtures for our plugin.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user