Skip to content

Commit

Permalink
Added routes for project workflow executions and associated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
deepsidhu85 committed Jan 9, 2025
1 parent f5d7650 commit 86ca610
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/controllers/projects/workflow_executions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ def workflow_execution
@workflow_execution = WorkflowExecution.find_by!(id: params[:id], submitter: @project.namespace.automation_bot)
end

def workflow_execution_update_params
params.require(:workflow_execution).permit(:name)
end

def load_workflows
authorized_scope(WorkflowExecution, type: :relation, as: :automated, scope_options: { project: @project })
end
Expand Down
2 changes: 1 addition & 1 deletion config/routes/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
if Irida::Pipelines.instance.available_pipelines.any?
resources :automated_workflow_executions

resources :workflow_executions, only: %i[index destroy show] do
resources :workflow_executions, only: %i[index destroy show edit update] do
member do
put :cancel
end
Expand Down
20 changes: 20 additions & 0 deletions test/controllers/projects/workflow_executions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,5 +214,25 @@ class WorkflowExecutionsControllerTest < ActionDispatch::IntegrationTest

assert_redirected_to namespace_project_workflow_executions_path(@namespace, @project)
end

test 'analyst or higher access level can update workflow execution name post launch' do
update_params = { workflow_execution: { name: 'New Name' } }

put namespace_project_workflow_execution_path(@namespace, @project, @workflow_execution, format: :turbo_stream),
params: update_params

Check warning on line 222 in test/controllers/projects/workflow_executions_controller_test.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Align the arguments of a method call if they span more than one line. Raw Output: test/controllers/projects/workflow_executions_controller_test.rb:222:53: C: Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.

assert_response :success
end

test 'access level less than analyst cannot update workflow execution name post launch for an automated workflow' do
sign_in users(:ryan_doe)

update_params = { workflow_execution: { name: 'New Name' } }

put namespace_project_workflow_execution_path(@namespace, @project, @workflow_execution, format: :turbo_stream),
params: update_params

Check warning on line 233 in test/controllers/projects/workflow_executions_controller_test.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Align the arguments of a method call if they span more than one line. Raw Output: test/controllers/projects/workflow_executions_controller_test.rb:233:53: C: Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.

assert_response :unauthorized
end
end
end

0 comments on commit 86ca610

Please sign in to comment.