Skip to content

Commit

Permalink
Redmine 5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
picman committed Nov 10, 2023
1 parent bf87b60 commit 0b4ab83
Show file tree
Hide file tree
Showing 26 changed files with 58 additions and 61 deletions.
4 changes: 2 additions & 2 deletions app/controllers/custom_workflows_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ def show
end
end

def edit; end

def new
@workflow = CustomWorkflow.new
@workflow.author = cookies[:custom_workflows_author]
Expand All @@ -75,6 +73,8 @@ def new
end
end

def edit; end

def import
xml = params[:file].read
begin
Expand Down
4 changes: 2 additions & 2 deletions app/models/custom_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -70,7 +70,7 @@ def self.import_from_xml(xml)
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)
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20110915084858_create_custom_workflows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def change
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
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20120601054047_alter_custom_workflows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def up
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def display_custom_workflow_messages
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def display_custom_workflow_messages
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def display_custom_workflow_messages
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def display_custom_workflow_messages
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def display_custom_workflow_messages
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def display_custom_workflow_messages
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def display_custom_workflow_messages
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def display_custom_workflow_messages
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def display_custom_workflow_messages
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def display_custom_workflow_messages
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
Expand Down
6 changes: 3 additions & 3 deletions test/functional/attachments_controller_patch_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions test/functional/custom_workflows_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,21 @@ 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
assert_kind_of CustomWorkflow, @cw1
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
12 changes: 6 additions & 6 deletions test/functional/groups_controller_patch_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions test/functional/issue_relations_controller_patch_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions test/functional/issues_controller_patch_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions test/functional/members_controller_patch_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/functional/projects_controller_patch_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/functional/timelog_controller_patch_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions test/functional/users_controller_patch_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions test/functional/versions_controller_patch_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 0b4ab83

Please sign in to comment.