Skip to content

Commit bcf4680

Browse files
authored
Merge pull request #11895 from mfo/US/fix-token-creation
correctif: ETQ administrateur, j'aimerais pouvoir créer un token
2 parents 8620da3 + 7bc9a6b commit bcf4680

File tree

4 files changed

+43
-9
lines changed

4 files changed

+43
-9
lines changed

app/views/administrateurs/api_tokens/securite.html.haml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
= f.hidden_field :name, value: params[:name]
9292
= f.hidden_field :access, value: params[:access]
9393
= f.hidden_field :target, value: params[:target]
94-
- params[:targets]&.each do |target|
94+
- params[:"[targets]"]&.each do |target|
9595
= f.hidden_field 'targets[]', value: target
9696
9797
%ul.fr-btns-group.fr-btns-group--inline
@@ -100,6 +100,6 @@
100100
class: "fr-btn fr-btn--primary",
101101
disabled: true,
102102
'data-api-token-securite-target': 'continueButton' do
103-
créer le jeton
103+
Créer le jeton
104104
%li
105-
= link_to 'retour', autorisations_admin_api_tokens_path(name: params[:name], access: params[:access], target: params[:target], targets: params[:targets]), class: "fr-btn fr-btn--secondary"
105+
= link_to 'Retour', autorisations_admin_api_tokens_path(name: params[:name], access: params[:access], target: params[:target], targets: params[:targets]), class: "fr-btn fr-btn--secondary"

spec/support/system_helpers.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ def wait_for_autosave
157157
expect(page).to have_css('.debounced-empty') # no more debounce
158158
expect(page).to have_css('.autosave-state-idle') # no more in flight promise
159159
end
160+
161+
# find input (radio), center it in the screen, then click on label (otherwise element out of scope)
162+
def custom_check(field_id)
163+
scroll_to(find_field(field_id), align: :center)
164+
find("label[for=#{field_id}]").click
165+
end
160166
end
161167

162168
RSpec.configure do |config|

spec/system/administrateurs/api_referentiel_spec.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,4 @@
208208
end
209209
end
210210
end
211-
212-
# find input, center it in the screen, then click on label (otherwise element out of scope)
213-
def custom_check(field_id)
214-
scroll_to(find_field(field_id), align: :center)
215-
find("label[for=#{field_id}]").click
216-
end
217211
end
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# frozen_string_literal: true
2+
3+
describe 'As an administrateur I create an API token', js: true do
4+
include SystemHelpers
5+
let(:administrateur) { procedure.administrateurs.first }
6+
let(:procedure) { create(:procedure) }
7+
8+
before do
9+
login_as administrateur.user, scope: :user
10+
end
11+
scenario 'token creation' do
12+
visit profil_path
13+
expect(page).to have_content('Profil')
14+
15+
click_on 'Créer un nouveau jeton'
16+
expect(page).to have_content("Création d'un nouveau jeton")
17+
18+
fill_in 'Nom du jeton', with: 'mon jeton'
19+
click_on 'Continuer'
20+
expect(page).to have_content("Privilèges du jeton « mon jeton »")
21+
22+
custom_check "target_custom"
23+
select "#{procedure.id} - #{procedure.libelle}"
24+
click_on 'Ajouter'
25+
custom_check 'access_read_write'
26+
click_on 'Continuer'
27+
expect(page).to have_content("Sécurité")
28+
29+
custom_check 'networkFiltering_none'
30+
custom_check 'lifetime_oneweek'
31+
click_on('Créer le jeton')
32+
expect(page).to have_content("Votre jeton est prêt")
33+
end
34+
end

0 commit comments

Comments
 (0)