diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 2ebbdeeb..9328bfc2 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -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 diff --git a/app/models/ability.rb b/app/models/ability.rb index d6b3ef21..79a5e4dc 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -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 diff --git a/app/views/organizations/index.html.haml b/app/views/organizations/index.html.haml index c8743363..bd97ac2b 100644 --- a/app/views/organizations/index.html.haml +++ b/app/views/organizations/index.html.haml @@ -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' diff --git a/config/routes.rb b/config/routes.rb index ce1881e0..bccc1567 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/spec/features/code_of_conduct_spec.rb b/spec/features/code_of_conduct_spec.rb index 2300fe1f..2caf8e4c 100644 --- a/spec/features/code_of_conduct_spec.rb +++ b/spec/features/code_of_conduct_spec.rb @@ -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