-
Notifications
You must be signed in to change notification settings - Fork 69
Delete a organization + organization policy #368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1be5c19
6c89900
d34e083
26d77a4
035117b
4bfc636
9418484
7f6a087
0c6c1e7
2231b63
43b3738
7cc1d11
14fe6bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class OrganizationPolicy < ApplicationPolicy | ||
alias_method :organization, :record | ||
|
||
def index? | ||
true | ||
end | ||
|
||
def create? | ||
user&.superadmin? | ||
end | ||
|
||
def update? | ||
user&.superadmin? || user&.admins?(organization) | ||
end | ||
|
||
def set_current? | ||
user&.as_member_of(organization) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,20 +27,16 @@ | |
<td><%= link_to org.name, org %></td> | ||
<td><%= org.users.count %></td> | ||
<td class="hover-actions"> | ||
<% if current_user.admins?(org) %> | ||
<% if current_user&.admins?(org) %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have the same question here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to previous comment, this controller doesn't require authentication at this point, so now you can visit the |
||
<%= link_to edit_organization_path(org), class: 'action' do %> | ||
<%= glyph :pencil %> | ||
<%= t 'global.edit' %> | ||
<% end %> | ||
<%= link_to organization_path(org), | ||
data: { method: :delete }, | ||
class: 'action' do %> | ||
<%= glyph :trash %> | ||
<%= t 'global.borrar' %> | ||
<% end %> | ||
<% end %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<%= paginate @organizations %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are we showing all organizations now?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unfortunately yes, without pagination 🙊 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe Admin::OrganizationsController, type: :controller do | ||
let(:organization) { Fabricate(:organization) } | ||
let(:member) { Fabricate(:member, organization: organization) } | ||
let(:user) { member.user } | ||
|
||
before do | ||
login(user) | ||
allow(controller).to receive(:authenticate_superuser!).and_return(true) | ||
end | ||
|
||
describe "DELETE #destroy" do | ||
it "sign out if current user is logged to organization deleted" do | ||
expect { | ||
delete :destroy, id: organization.id | ||
}.to change { controller.current_user }.to nil | ||
end | ||
end | ||
end |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind to add this kind of change to the model tests also? Thanks 😍
e.g. https://github.com/coopdevs/timeoverflow/blob/develop/spec/models/member_spec.rb#L8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👉 7f6a087