Show code of conduct on organizations

This commit is contained in:
James Mason 2018-03-16 12:18:09 -07:00 committed by Ana María Martínez Gómez
parent a6daff8582
commit 217ec1a46f
5 changed files with 30 additions and 7 deletions

View file

@ -5,6 +5,12 @@ class OrganizationsController < ApplicationController
@organizations = Organization.all
end
def code_of_conduct
@title = "#{@organization.name}: Code of Conduct"
@content = @organization.code_of_conduct
render 'document'
end
def conferences
@current = @organization.conferences.upcoming.reorder(start_date: :asc)
@antiquated = @organization.conferences.past

View file

@ -15,7 +15,7 @@ class Ability
# Abilities for not signed in users (guests)
def not_signed_in
can [:index, :conferences], Organization
can [:index, :conferences, :code_of_conduct], Organization
can [:index], Conference
can [:show], Conference do |conference|
conference.splashpage && conference.splashpage.public == true

View file

@ -6,13 +6,16 @@
.btn-group.pull-right
/ = link_to 'Add new', new_organization_path, class: 'btn btn-mini btn-success'
- @organizations.each do |organization|
.col-md-4
.col-md-4{ id: "organization-#{organization.id}" }
.thumbnail
= image_tag(organization.picture.thumb.url, width: '20%') if organization.picture?
.caption
%h4
= organization.name
= link_to 'Conferences',
conferences_organization_path(organization),
class: 'btn btn-success'
/ = link_to 'Edit', edit_organization_path(organization), class: 'btn btn-mini btn-default'
.btn-group
= link_to 'Conferences',
conferences_organization_path(organization),
class: 'btn btn-success'
- unless organization.code_of_conduct.blank?
= link_to 'Code of Conduct', [:code_of_conduct, organization], class: 'btn btn-info'
/ = link_to 'Edit', edit_organization_path(organization), class: 'btn btn-mini btn-default'

View file

@ -152,7 +152,7 @@ Osem::Application.routes.draw do
end
resources :organizations, only: [:index] do
member do
get :conferences
get :conferences, 'code-of-conduct'
end
end
resources :conferences, only: [:index, :show] do

View file

@ -30,5 +30,19 @@ feature 'Code of Conduct:' do
end
end
end
describe 'anonymously' do
let!(:organization) { create(:organization, code_of_conduct: sample_text) }
context 'on the organization' do
it 'can be read' do
visit organizations_path
within "#organization-#{organization.id}" do
click_on 'Code of Conduct'
end
expect(page).to have_text(sample_text)
end
end
end
end
end