Skip to content

Commit

Permalink
Refacto
Browse files Browse the repository at this point in the history
  -  method start_authorization_request_form(form) to pass option to disabled button
  - cucumber test to make it generiq
  • Loading branch information
Isalafont committed Apr 23, 2024
1 parent 173fd93 commit 555b060
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
10 changes: 2 additions & 8 deletions app/helpers/authorization_requests_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
module AuthorizationRequestsHelpers
def start_authorization_request_form(form)
def start_authorization_request_form(form, disabled: false)
authorization_request_form_tag(form.authorization_request_class.new(form_uid: form.uid)) do |f|
f.button t('start_authorization_request_form.cta', authorization_name: form.authorization_definition.name), type: :submit, name: :start, id: dom_id(form, :start_authorization_request), class: %w[fr-btn fr-icon-save-line fr-btn--icon-left]
end
end

def disabled_start_authorization_request_form(form)
authorization_request_form_tag(form.authorization_request_class.new(form_uid: form.uid)) do |f|
f.button t('start_authorization_request_form.cta', authorization_name: form.authorization_definition.name), type: :submit, name: :start, id: dom_id(form, :start_authorization_request), class: %w[fr-btn fr-icon-save-line fr-btn--icon-left], disabled: true
f.button t('start_authorization_request_form.cta', authorization_name: form.authorization_definition.name), type: :submit, name: :start, id: dom_id(form, :start_authorization_request), class: %w[fr-btn fr-icon-save-line fr-btn--icon-left], disabled:
end
end

Expand Down
3 changes: 2 additions & 1 deletion app/views/authorization_requests/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
<%= t('.single_form.description') %>

<br/>
<%= disabled_start_authorization_request_form(authorization_request_form) %>

<%= start_authorization_request_form(authorization_request_form, disabled: true) %>
</p>
<% else %>
<p>
Expand Down
4 changes: 2 additions & 2 deletions features/step_definitions/authorization_requests_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,6 @@
end
end

Et(/je peux voir le bouton "Débuter mon habilitation pour Portail HubEE - Démarche CertDC" grisé et désactivé/) do
expect(page).to have_css('button#start_authorization_request_authorization_request_form_portail-hubee-demarche-certdc.fr-btn.fr-icon-save-line.fr-btn--icon-left[disabled]', text: 'Débuter mon habilitation pour Portail HubEE - Démarche CertDC')
Et('je peux voir le bouton {string} grisé et désactivé') do |string|
expect(page).to have_css('button[disabled]', text: string)
end

0 comments on commit 555b060

Please sign in to comment.