Compare commits
2 Commits
f3159d30f1
...
9a1f9abf84
| Author | SHA1 | Date | |
|---|---|---|---|
|
9a1f9abf84
|
|||
|
2753388e1e
|
@@ -48,19 +48,20 @@
|
|||||||
<%= @user.invitations.count %>
|
<%= @user.invitations.count %>
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
<button data-action="click->modal#open">
|
<button id="add-invitations" data-action="click->modal#open">
|
||||||
<%= render partial: "icons/plus-circle", locals: {
|
<%= 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"
|
custom_class: "text-green-600 hover:text-green-500 -mt-2 -mb-1 h-6 w-6 inline-block"
|
||||||
} %>
|
} %>
|
||||||
</button>
|
</button>
|
||||||
<% if @user.invitations.unused.count > 0 %>
|
<% if @user.invitations.unused.count > 0 %>
|
||||||
<%= link_to invitations_admin_user_path(@user.cn), data: {
|
<%= link_to invitations_admin_user_path(@user.cn),
|
||||||
turbo_method: :delete,
|
id: "remove-invitations", data: {
|
||||||
turbo_confirm: "Delete all of #{@user.cn}'s available invitations?"
|
turbo_method: :delete,
|
||||||
} do %>
|
turbo_confirm: "Delete all of #{@user.cn}'s available invitations?"
|
||||||
<%= render partial: "icons/x-circle", locals: {
|
} do %>
|
||||||
custom_class: "text-red-600 hover:text-red-500 -mt-2 -mb-1 h-6 w-6 inline-block"
|
<%= 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 %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</span>
|
</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
|
||||||
Reference in New Issue
Block a user