-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Favor links on organizations page (#2008)
- Loading branch information
Showing
11 changed files
with
99 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.OrganizationsIndex-organizationsList { | ||
display: grid; | ||
grid-template-columns: repeat(2, 1fr); | ||
list-style-type: none; | ||
} | ||
|
||
.OrganizationsIndex-organizationsList a { | ||
padding-left: 0; | ||
} |
22 changes: 22 additions & 0 deletions
22
app/components/organizations_index/organizations_index.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<%= c 'main', style: :lightestGrayBackground, **attrs do %> | ||
<%= c 'page_header', styles: [:flexboxColumn, :wide, :xlargePaddingTop] do %> | ||
<%= c 'heading' do %> | ||
<%= t('.main_heading', first_name: current_user.first_name) %> | ||
<% end %> | ||
<%= c 'heading', tag: :h2 do %> | ||
<%= t('.heading') %> | ||
<% end %> | ||
<% end %> | ||
|
||
<%= c 'section', styles: [:wide, :noSpaceBetween] do %> | ||
<ul class="OrganizationsIndex-organizationsList"> | ||
<% organizations.each do |organization| %> | ||
<li> | ||
<%= c 'button', link: organization_dashboard_path(organization), styles: [:plain, :underline] do %> | ||
<%= organization.name %> | ||
<% end %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module OrganizationsIndex | ||
class OrganizationsIndex < ApplicationComponent | ||
def initialize(current_user:, organizations:) | ||
super | ||
|
||
@current_user = current_user | ||
@organizations = organizations | ||
end | ||
|
||
attr_reader :current_user, :organizations | ||
end | ||
end |
13 changes: 0 additions & 13 deletions
13
app/components/set_organization_form/set_organization_form.css
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
app/components/set_organization_form/set_organization_form.html.erb
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
app/components/set_organization_form/set_organization_form.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1 @@ | ||
<%= c 'main', style: :lightestGrayBackground do %> | ||
<%= c 'page_header', styles: [:wide, :inheritBackgroundColor, :xlargePaddingTop, :spaceBetween] do %> | ||
<%= c 'heading' do %> | ||
<%= t ".heading", first_name: current_user.first_name %> | ||
<% end %> | ||
<% end %> | ||
|
||
|
||
<%= c 'set_organization_form', organizations: @organizations %> | ||
<% end %> | ||
<%= c 'organizations_index', current_user: current_user, organizations: @organizations %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe 'Organizations' do | ||
let(:organizations) { create_list(:organization, 2) } | ||
let!(:other_organizations) { create_list(:organization, 2) } | ||
let(:admin) { create(:user, admin: true) } | ||
|
||
describe 'GET /organizations' do | ||
subject { -> { get organizations_path(as: user) } } | ||
|
||
context 'unauthenticated' do | ||
let(:user) { nil } | ||
|
||
it 'redirects to the sign in path' do | ||
subject.call | ||
expect(response).to redirect_to(sign_in_path) | ||
end | ||
end | ||
|
||
context 'authenticated' do | ||
let(:user) { create(:user, organizations: organizations) } | ||
before { subject.call } | ||
|
||
it 'should be successful' do | ||
expect(response).to be_successful | ||
end | ||
|
||
it 'displays only the organizations the user belongs to' do | ||
expect(page).to have_css("a[href='#{organization_dashboard_path(organizations.first)}']", text: organizations.first.name) | ||
expect(page).to have_css("a[href='#{organization_dashboard_path(organizations.second)}']", text: organizations.second.name) | ||
expect(page).not_to have_css("a[href='#{organization_dashboard_path(other_organizations.first)}']", | ||
text: other_organizations.first.name) | ||
expect(page).not_to have_css("a[href='#{organization_dashboard_path(other_organizations.second)}']", | ||
text: other_organizations.second.name) | ||
end | ||
|
||
context 'user has admin privileges' do | ||
let(:user) { create(:user, admin: true) } | ||
|
||
it 'displays all organizations' do | ||
Organization.find_each do |organization| | ||
expect(page).to have_css("a[href='#{organization_dashboard_path(organization)}']", text: organization.name) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |