-
Notifications
You must be signed in to change notification settings - Fork 99
Fixes #39339 - use React component for TaskDetails page rendering #815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1fd94bb
e12bba0
2469697
029de8f
c551a1f
1289c0c
5c9b6cd
de511cf
4074018
acc0470
7721d86
d8340ab
3040958
38c4d16
88c9087
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -12,7 +12,7 @@ | |||||
| end | ||||||
| end | ||||||
|
|
||||||
| resources :tasks, :only => [:show] do | ||||||
| resources :tasks, :only => [] do | ||||||
| collection do | ||||||
| get 'auto_complete_search' | ||||||
| get '/summary/:recent_timeframe', action: 'summary' | ||||||
|
|
@@ -27,14 +27,15 @@ | |||||
| post :cancel_step | ||||||
| end | ||||||
| end | ||||||
| resources :tasks, :only => [:show], constraints: ->(req) { req.format == :csv } do | ||||||
| resources :tasks, :only => [], constraints: ->(req) { req.format == :csv } do | ||||||
| member do | ||||||
| get :sub_tasks | ||||||
| end | ||||||
| end | ||||||
| resources :tasks, :only => [:index], constraints: ->(req) { req.format == :csv } | ||||||
|
|
||||||
| match '/tasks', to: '/react#index', via: :get | ||||||
| match '/tasks/:id', to: '/react#index', via: :get, :as => :task | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Constrain the task-details React route to HTML. Line 38 currently matches Suggested fix- match '/tasks/:id', to: '/react#index', via: :get, :as => :task
+ get '/tasks/:id', to: '/react#index', as: :task, constraints: ->(req) { req.format.html? }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| match '/tasks/:id/sub_tasks', to: '/react#index', via: :get | ||||||
|
|
||||||
| namespace :api do | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,15 +82,6 @@ def in_taxonomy_scope(organization, location = nil) | |
| assert_include response.body.lines[1], 'Some action' | ||
| end | ||
|
|
||
| describe 'show' do | ||
| it 'does not allow user without permissions to see task details' do | ||
| setup_user('view', 'foreman_tasks', 'owner.id = current_user') | ||
| get :show, params: { id: FactoryBot.create(:some_task).id }, | ||
| session: set_session_user(User.current) | ||
| assert_response :not_found | ||
| end | ||
| end | ||
|
|
||
|
andreilakatos marked this conversation as resolved.
Comment on lines
-85
to
-93
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than dropping it, it would be nice to convert it to a integration/capybara test
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are those tests written inside foreman core? I can't find any capybara / integration tests in this repo.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, directly in the plugin.
It is possible we just don't have any yet. You could draw inspiration from webhooks for example https://github.com/theforeman/foreman_webhooks/blob/master/test/integration/webhooks_test.rb
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, thanks for the link 😀 |
||
| describe 'index' do | ||
| it 'shows duration column' do | ||
| task = ForemanTasks::Task.select_duration.find(FactoryBot.create(:some_task).id) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require_relative '../test_plugin_helper' | ||
| require 'integration_test_helper' | ||
|
|
||
| class TasksIntegrationTest < IntegrationTestWithJavascript | ||
| test 'does not allow user without permissions to see task details' do | ||
| setup_user('view', 'foreman_tasks', 'owner.id = current_user') | ||
| task = FactoryBot.create(:some_task) | ||
| set_request_user(User.current) | ||
|
|
||
| visit "/foreman_tasks/tasks/#{task.id}" | ||
|
|
||
| assert_selector 'h5', text: /Unable to load task/i | ||
| assert_no_selector '#task-details-tabs' | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| # This calls the main test_helper in Foreman-core | ||
| require 'test_helper' | ||
|
|
||
| # Add plugin to FactoryBot's paths | ||
| FactoryBot.definition_file_paths << File.join(File.dirname(__FILE__), 'factories') | ||
| FactoryBot.reload |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| export const FOREMAN_TASK_DETAILS = 'FOREMAN_TASK_DETAILS'; | ||
| export const FOREMAN_TASK_DETAILS_SUCCESS = 'FOREMAN_TASK_DETAILS_SUCCESS'; | ||
|
|
||
| export const TASKS_PATH = '/foreman_tasks/tasks'; | ||
| export const TASK_STEP_CANCEL = 'TASK_STEP_CANCEL'; | ||
| export const VIEW_FOREMAN_TASKS = 'view_foreman_tasks'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't found any usage of this, can someone else confirm it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which part is
this?sub_tasksorshow?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pulling
.csvfiles forsub_tasks, originally there was:only => [:show]. I didn't found any usage of it in UI. Only theExport Allbutton on/taskspage