Compare commits
2 Commits
f3159d30f1
...
9a1f9abf84
| Author | SHA1 | Date | |
|---|---|---|---|
| 9a1f9abf84 | |||
| 2753388e1e |
@ -48,19 +48,20 @@
|
||||
<%= @user.invitations.count %>
|
||||
</span>
|
||||
<span>
|
||||
<button data-action="click->modal#open">
|
||||
<button id="add-invitations" data-action="click->modal#open">
|
||||
<%= render partial: "icons/plus-circle", locals: {
|
||||
custom_class: "text-green-600 hover:text-green-500 -mt-2 -mb-1 h-6 w-6 inline-block"
|
||||
} %>
|
||||
</button>
|
||||
<% if @user.invitations.unused.count > 0 %>
|
||||
<%= link_to invitations_admin_user_path(@user.cn), data: {
|
||||
turbo_method: :delete,
|
||||
turbo_confirm: "Delete all of #{@user.cn}'s available invitations?"
|
||||
} do %>
|
||||
<%= render partial: "icons/x-circle", locals: {
|
||||
custom_class: "text-red-600 hover:text-red-500 -mt-2 -mb-1 h-6 w-6 inline-block"
|
||||
} %>
|
||||
<% if @user.invitations.unused.count > 0 %>
|
||||
<%= link_to invitations_admin_user_path(@user.cn),
|
||||
id: "remove-invitations", data: {
|
||||
turbo_method: :delete,
|
||||
turbo_confirm: "Delete all of #{@user.cn}'s available invitations?"
|
||||
} do %>
|
||||
<%= render partial: "icons/x-circle", locals: {
|
||||
custom_class: "text-red-600 hover:text-red-500 -mt-2 -mb-1 h-6 w-6 inline-block"
|
||||
} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</span>
|
||||
|
||||
55
spec/features/admin/users_spec.rb
Normal file
55
spec/features/admin/users_spec.rb
Normal file
@ -0,0 +1,55 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe "Admin: User management", type: :feature do
|
||||
let(:admin) { create :user }
|
||||
let(:user) { create :user, id: 2, cn: "alfred", email: "alfred@example.com" }
|
||||
|
||||
before do
|
||||
user.save!
|
||||
|
||||
allow(Devise::LDAP::Adapter).to receive(:get_ldap_param)
|
||||
.with(admin.cn, :admin).and_return(["true"])
|
||||
allow(Devise::LDAP::Adapter).to receive(:get_ldap_param)
|
||||
.with(user.cn, :admin).and_return(nil)
|
||||
allow_any_instance_of(User).to receive(:ldap_entry)
|
||||
.and_return({ uid: user.cn, mail: user.email, display_name: "Freddy" })
|
||||
allow_any_instance_of(LdapManager::FetchAvatar).to receive(:call)
|
||||
.and_return(nil)
|
||||
|
||||
login_as admin, :scope => :user
|
||||
end
|
||||
|
||||
describe "User details page" do
|
||||
before do
|
||||
visit admin_user_path("alfred")
|
||||
end
|
||||
|
||||
it "shows the user info" do
|
||||
within "h1" do
|
||||
expect(page).to have_content("User: alfred")
|
||||
end
|
||||
expect(page).to have_content("alfred@example.com")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Add invitations to account' do
|
||||
visit admin_user_path("alfred")
|
||||
find("#add-invitations").click
|
||||
|
||||
select "5", :from => "amount"
|
||||
uncheck "notify_user"
|
||||
click_button "Add"
|
||||
|
||||
expect(user.invitations.count).to eq(5)
|
||||
end
|
||||
|
||||
scenario 'Remove invitations from account' do
|
||||
3.times { Invitation.create(user: user) }
|
||||
expect(user.invitations.count).to eq(3)
|
||||
|
||||
visit admin_user_path("alfred")
|
||||
find("#remove-invitations").click
|
||||
|
||||
expect(user.invitations.count).to eq(0)
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user