1
0
Fork 0

Add button to revoke own role

This commit is contained in:
Alex Kotov 2019-02-08 13:35:17 +05:00
parent ec32b8cf54
commit b37b1bc92d
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
6 changed files with 46 additions and 2 deletions

View File

@ -16,7 +16,8 @@
<td>
<% if policy(country_state).show? %>
<%= link_to country_state,
role: :button, class: 'btn btn-light btn-sm' do %>
role: :button,
class: 'btn btn-light btn-sm' do %>
<i class="far fa-eye"></i>
<% end %>
<% end %>

View File

@ -27,7 +27,17 @@
<td scope="row"><%= role.id %></td>
<td><%= role.human_name %></td>
<td><%= role.human_resource %></td>
<td></td>
<td>
<% if policy([:settings, role]).destroy? %>
<%= link_to [:settings, role],
method: :delete,
role: :button,
class: 'btn btn-danger btn-sm' do %>
<i class="fas fa-trash"></i>
<%= translate '.revoke' %>
<% end %>
<% end %>
</td>
</tr>
<% end %>
</tbody>

View File

@ -45,3 +45,7 @@ en:
index:
new_confirmation: New confirmation
already_confirmed: You have already confirmed the passport.
settings:
roles:
index:
revoke: Revoke

View File

@ -46,3 +46,7 @@ ru:
index:
new_confirmation: Новое подтверждение
already_confirmed: Вы уже подтвердили этот паспорт.
settings:
roles:
index:
revoke: Отозвать

View File

@ -0,0 +1,10 @@
Feature: Roles
Background:
Given I am signed in as superuser
Scenario:
When I visit "/settings/roles"
Then I see text "Суперпользователь"
When I click the button "Отозвать"
Then I do not see text "Суперпользователь"

View File

@ -9,6 +9,21 @@ Given 'I am signed in as guest' do
visit root_path guest_token: account.guest_token
end
Given 'I am signed in as superuser' do
account = create :superuser_account
visit '/users/sign_in'
within 'form' do
fill_in 'Email', with: account.user.email
fill_in 'Пароль', with: account.user.password
click_on 'Войти'
end
expect(page).to have_css 'ul > li > a', text: account.user.account.username
end
Given 'I am signed in with email {string}' do |email|
@user = create :user, email: email