In
<% if (current_user.admin? && !current_user?(user) && !user.admin?) || current_user.sadmin? %>
| <%= link_to "delete", user, method: :delete,
data: { confirm: "You sure?" } %>
<% end %>
, it mean if "current_user.sadmin? " is true, the link will be displayed no matter other conditions. So ther is the failure
Failure/Error: it { should_not have_link('delete', href: user_path(sadmin)) }
expected #has_link?("delete", {:href=>"/users/422"}) to return false, got true
I guess
it { should have_link('delete', href: user_path(admin))}
failed, is becuase the admin user has been deleted in
it "should be able to delete another user" do
expect do
click_link('delete', match: :first)
end.to change(User, :count).by(-1)
end
part?