Merge pull request #3056 from consul/administrator-id
[Backport] Administrator ID
This commit is contained in:
@@ -8,12 +8,16 @@
|
|||||||
|
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
|
<th scope="col" class="text-center"><%= t("admin.administrators.index.id") %></th>
|
||||||
<th scope="col"><%= t("admin.administrators.index.name") %></th>
|
<th scope="col"><%= t("admin.administrators.index.name") %></th>
|
||||||
<th scope="col"><%= t("admin.administrators.index.email") %></th>
|
<th scope="col"><%= t("admin.administrators.index.email") %></th>
|
||||||
<th scope="col" class="small-3"><%= t("admin.shared.actions") %></th>
|
<th scope="col" class="small-3"><%= t("admin.shared.actions") %></th>
|
||||||
</thead>
|
</thead>
|
||||||
<% @administrators.each do |administrator| %>
|
<% @administrators.each do |administrator| %>
|
||||||
<tr>
|
<tr id="<%= dom_id(administrator)%>">
|
||||||
|
<td class="text-center">
|
||||||
|
<%= administrator.id %>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%= administrator.name %>
|
<%= administrator.name %>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -588,6 +588,7 @@ en:
|
|||||||
title: Administrators
|
title: Administrators
|
||||||
name: Name
|
name: Name
|
||||||
email: Email
|
email: Email
|
||||||
|
id: Administrator ID
|
||||||
no_administrators: There are no administrators.
|
no_administrators: There are no administrators.
|
||||||
administrator:
|
administrator:
|
||||||
add: Add
|
add: Add
|
||||||
|
|||||||
@@ -585,6 +585,7 @@ es:
|
|||||||
administrators:
|
administrators:
|
||||||
index:
|
index:
|
||||||
title: Administradores
|
title: Administradores
|
||||||
|
id: ID de Administrador
|
||||||
name: Nombre
|
name: Nombre
|
||||||
email: Email
|
email: Email
|
||||||
no_administrators: No hay administradores.
|
no_administrators: No hay administradores.
|
||||||
|
|||||||
@@ -1,41 +1,48 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
feature 'Admin administrators' do
|
feature 'Admin administrators' do
|
||||||
|
let!(:admin) { create(:administrator) }
|
||||||
|
let!(:user) { create(:user, username: 'Jose Luis Balbin') }
|
||||||
|
let!(:user_administrator) { create(:administrator) }
|
||||||
|
|
||||||
background do
|
background do
|
||||||
@admin = create(:administrator)
|
login_as(admin.user)
|
||||||
@user = create(:user, username: 'Jose Luis Balbin')
|
|
||||||
@administrator = create(:administrator)
|
|
||||||
login_as(@admin.user)
|
|
||||||
visit admin_administrators_path
|
visit admin_administrators_path
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Index' do
|
scenario 'Index' do
|
||||||
expect(page).to have_content @administrator.name
|
expect(page).to have_content user_administrator.id
|
||||||
expect(page).to have_content @administrator.email
|
expect(page).to have_content user_administrator.name
|
||||||
expect(page).not_to have_content @user.name
|
expect(page).to have_content user_administrator.email
|
||||||
|
expect(page).not_to have_content user.name
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Create Administrator', :js do
|
scenario 'Create Administrator', :js do
|
||||||
fill_in 'name_or_email', with: @user.email
|
fill_in 'name_or_email', with: user.email
|
||||||
click_button 'Search'
|
click_button 'Search'
|
||||||
|
|
||||||
expect(page).to have_content @user.name
|
expect(page).to have_content user.name
|
||||||
click_link 'Add'
|
click_link 'Add'
|
||||||
within("#administrators") do
|
within("#administrators") do
|
||||||
expect(page).to have_content @user.name
|
expect(page).to have_content user.name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Delete Administrator' do
|
scenario 'Delete Administrator' do
|
||||||
find(:xpath, "//tr[contains(.,'#{@administrator.name}')]/td/a", text: 'Delete').click
|
within "#administrator_#{user_administrator.id}" do
|
||||||
|
click_on "Delete"
|
||||||
|
end
|
||||||
|
|
||||||
within("#administrators") do
|
within("#administrators") do
|
||||||
expect(page).not_to have_content @administrator.name
|
expect(page).not_to have_content user_administrator.name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Delete Administrator when its the current user' do
|
scenario 'Delete Administrator when its the current user' do
|
||||||
find(:xpath, "//tr[contains(.,'#{@admin.name}')]/td/a", text: 'Delete').click
|
|
||||||
|
within "#administrator_#{admin.id}" do
|
||||||
|
click_on "Delete"
|
||||||
|
end
|
||||||
|
|
||||||
within("#error") do
|
within("#error") do
|
||||||
expect(page).to have_content I18n.t("admin.administrators.administrator.restricted_removal")
|
expect(page).to have_content I18n.t("admin.administrators.administrator.restricted_removal")
|
||||||
@@ -44,49 +51,52 @@ feature 'Admin administrators' do
|
|||||||
|
|
||||||
context 'Search' do
|
context 'Search' do
|
||||||
|
|
||||||
|
let!(:administrator1) { create(:administrator, user: create(:user,
|
||||||
|
username: 'Bernard Sumner',
|
||||||
|
email: 'bernard@sumner.com')) }
|
||||||
|
let!(:administrator2) { create(:administrator, user: create(:user,
|
||||||
|
username: 'Tony Soprano',
|
||||||
|
email: 'tony@soprano.com')) }
|
||||||
|
|
||||||
background do
|
background do
|
||||||
user = create(:user, username: 'Bernard Sumner', email: 'bernard@sumner.com')
|
|
||||||
user2 = create(:user, username: 'Tony Soprano', email: 'tony@soprano.com')
|
|
||||||
@administrator1 = create(:administrator, user: user)
|
|
||||||
@administrator2 = create(:administrator, user: user2)
|
|
||||||
visit admin_administrators_path
|
visit admin_administrators_path
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'returns no results if search term is empty' do
|
scenario 'returns no results if search term is empty' do
|
||||||
expect(page).to have_content(@administrator1.name)
|
expect(page).to have_content(administrator1.name)
|
||||||
expect(page).to have_content(@administrator2.name)
|
expect(page).to have_content(administrator2.name)
|
||||||
|
|
||||||
fill_in 'name_or_email', with: ' '
|
fill_in 'name_or_email', with: ' '
|
||||||
click_button 'Search'
|
click_button 'Search'
|
||||||
|
|
||||||
expect(page).to have_content('Administrators: User search')
|
expect(page).to have_content('Administrators: User search')
|
||||||
expect(page).to have_content('No results found')
|
expect(page).to have_content('No results found')
|
||||||
expect(page).not_to have_content(@administrator1.name)
|
expect(page).not_to have_content(administrator1.name)
|
||||||
expect(page).not_to have_content(@administrator2.name)
|
expect(page).not_to have_content(administrator2.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'search by name' do
|
scenario 'search by name' do
|
||||||
expect(page).to have_content(@administrator1.name)
|
expect(page).to have_content(administrator1.name)
|
||||||
expect(page).to have_content(@administrator2.name)
|
expect(page).to have_content(administrator2.name)
|
||||||
|
|
||||||
fill_in 'name_or_email', with: 'Sumn'
|
fill_in 'name_or_email', with: 'Sumn'
|
||||||
click_button 'Search'
|
click_button 'Search'
|
||||||
|
|
||||||
expect(page).to have_content('Administrators: User search')
|
expect(page).to have_content('Administrators: User search')
|
||||||
expect(page).to have_content(@administrator1.name)
|
expect(page).to have_content(administrator1.name)
|
||||||
expect(page).not_to have_content(@administrator2.name)
|
expect(page).not_to have_content(administrator2.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'search by email' do
|
scenario 'search by email' do
|
||||||
expect(page).to have_content(@administrator1.email)
|
expect(page).to have_content(administrator1.email)
|
||||||
expect(page).to have_content(@administrator2.email)
|
expect(page).to have_content(administrator2.email)
|
||||||
|
|
||||||
fill_in 'name_or_email', with: @administrator2.email
|
fill_in 'name_or_email', with: administrator2.email
|
||||||
click_button 'Search'
|
click_button 'Search'
|
||||||
|
|
||||||
expect(page).to have_content('Administrators: User search')
|
expect(page).to have_content('Administrators: User search')
|
||||||
expect(page).to have_content(@administrator2.email)
|
expect(page).to have_content(administrator2.email)
|
||||||
expect(page).not_to have_content(@administrator1.email)
|
expect(page).not_to have_content(administrator1.email)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user