diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 3d549dfa..2ebbdeeb 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -4,4 +4,10 @@ class OrganizationsController < ApplicationController def index @organizations = Organization.all end + + def conferences + @current = @organization.conferences.upcoming.reorder(start_date: :asc) + @antiquated = @organization.conferences.past + render '/conferences/index' + end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6174500e..f77d7963 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -171,4 +171,18 @@ module ApplicationHelper def hidden_if_conference_over(conference) 'hidden' if Date.today > conference.end_date end + + def nav_root_link_for(conference) + link_text = ( + conference.try(:organization).try(:name) || + ENV['OSEM_NAME'] || + 'OSEM' + ) + link_to( + link_text, + root_path, + class: 'navbar-brand', + title: 'Open Source Event Manager' + ) + end end diff --git a/app/models/ability.rb b/app/models/ability.rb index 18f9d4c4..b833b6f4 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], Organization + can [:index, :conferences], Organization can [:index], Conference can [:show], Conference do |conference| conference.splashpage && conference.splashpage.public == true diff --git a/app/views/conferences/index.html.haml b/app/views/conferences/index.html.haml index 032db5c3..a3735478 100644 --- a/app/views/conferences/index.html.haml +++ b/app/views/conferences/index.html.haml @@ -4,7 +4,7 @@ .page-header %h2 Upcoming Conferences - @current.each do |conference| - = render partial: 'conference_details', locals: { conference: conference } + = render '/conferences/conference_details', conference: conference -if @antiquated and @antiquated.any? .row .col-md-12 @@ -17,7 +17,7 @@ %i.fa.fa-chevron-down{ style: 'display: none' } #antiquated.collapse - @antiquated.each do |conference| - = render partial: 'conference_details', locals: { conference: conference} + = render '/conferences/conference_details', conference: conference -content_for :script_body do :javascript diff --git a/app/views/layouts/_navigation.html.haml b/app/views/layouts/_navigation.html.haml index 9995123b..f7d5fa30 100644 --- a/app/views/layouts/_navigation.html.haml +++ b/app/views/layouts/_navigation.html.haml @@ -13,10 +13,8 @@ %span.icon-bar %span.icon-bar %span.icon-bar - - if conference.nil? || conference.new_record? - = link_to (ENV['OSEM_NAME'] || 'OSEM'), root_path, class: 'navbar-brand', title: 'Open Source Event Manager' - - else - = link_to conference.organization.name, organizations_path, class: 'navbar-brand', title: 'Open Source Event Manager' + = nav_root_link_for conference + .collapse.navbar-collapse#main-nav - if content_for :splash_nav %ul.nav.navbar-nav#splash-nav diff --git a/app/views/organizations/index.html.haml b/app/views/organizations/index.html.haml index b2794bd8..bc5a4d5e 100644 --- a/app/views/organizations/index.html.haml +++ b/app/views/organizations/index.html.haml @@ -12,5 +12,7 @@ .caption %h4 = organization.name - %button.btn.btn-success Conferences + = link_to 'Conferences', + conferences_organization_path(organization), + class: 'btn btn-success' / = link_to 'Edit', edit_organization_path(organization), class: 'btn btn-mini btn-default' diff --git a/bootstrap.sh b/bootstrap.sh index 92a8d746..06a642dd 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,4 +1,10 @@ #!/bin/bash + +# set env os release variables +. /etc/os-release + +if [[ "$ID" == "opensuse" ]]; then + pushd /vagrant echo -e "\ninstalling required software packages...\n" @@ -14,6 +20,42 @@ echo 'install: --no-format-executable' >> /etc/gemrc echo -e "\ninstalling bundler...\n" gem.ruby2.4 install bundler +elif [[ "$ID" == "centos" || "$VERSION" == "7" ]]; then + _YELLOW='\033[1;33m' # yellow color + _LRED='\033[1;31m' # Light red color + _NO_COLOUR='\033[0m' # no color + + printf "${_YELLOW}CEntOS-7 Setup${_NO_COLOUR}\n" + + printf "${_YELLOW}installing ruby-2.4${_NO_COLOUR}\n" + yum install -q -y https://github.com/feedforce/ruby-rpm/releases/download/2.4.2/ruby-2.4.2-1.el7.centos.x86_64.rpm + if [[ ! "$?" -eq 0 ]]; then + printf "${_LRED}Error trying to install ruby-2.4${_NO_COLOUR}\n" + fi + + printf "${_YELLOW}installing ruby-2.4 gems dependencies${_NO_COLOUR}\n" + gem install bundler + if [[ ! "$?" -eq 0 ]]; then + printf "${_LRED}Error trying to install ruby-2.4 bundler${_NO_COLOUR}\n" + fi + + printf "${_YELLOW}installing nodejs repo${_NO_COLOUR}\n" + curl -sL https://rpm.nodesource.com/setup_9.x | bash - > /dev/null + + printf "${_YELLOW}installing nodejs and devel tools${_NO_COLOUR}\n" + yum install -q -y git make gcc gcc-c++ libxml2-devel libxslt-devel nodejs screen mariadb mariadb-devel sqlite-devel ImageMagick bzip2 + + # for production: bundle install --without test development + printf "${_YELLOW}Opening firewall port: 3000${_NO_COLOUR}\n" + iptables -I INPUT -p tcp --dport 3000 -j ACCEPT + + printf "${_YELLOW}installing phantomjs${_NO_COLOUR}\n" + curl -L --silent https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 -o /tmp/phantomjs-2.1.1-linux-x86_64.tar.bz2 + tar jxvf /tmp/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /tmp/ phantomjs-2.1.1-linux-x86_64/bin/phantomjs + mv /tmp/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin + +fi + echo -e "\ninstalling your bundle...\n" su - vagrant -c "cd /vagrant/; bundle install --quiet" diff --git a/config/routes.rb b/config/routes.rb index 6e8a66de..33a92a48 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -149,7 +149,11 @@ Osem::Application.routes.draw do get '/revision_history/:id/revert_object' => 'versions#revert_object', as: 'revision_history_revert_object' get '/revision_history/:id/revert_attribute' => 'versions#revert_attribute', as: 'revision_history_revert_attribute' end - resources :organizations, only: [:index] + resources :organizations, only: [:index] do + member do + get :conferences + end + end resources :conferences, only: [:index, :show] do resources :booths do member do diff --git a/spec/controllers/organizations_controller_spec.rb b/spec/controllers/organizations_controller_spec.rb index 2916fdea..eb0109a1 100644 --- a/spec/controllers/organizations_controller_spec.rb +++ b/spec/controllers/organizations_controller_spec.rb @@ -2,6 +2,26 @@ require 'spec_helper' describe OrganizationsController do let!(:organization) { create(:organization) } + let!(:conference) do + create( + :conference, + splashpage: create(:splashpage, public: true), + venue: create(:venue), + organization: organization + ) + end + let!(:antiquated_conference) do + create( + :conference, + splashpage: create(:splashpage, public: true), + venue: create(:venue), + organization: organization, + start_date: 2.weeks.ago, + end_date: 1.week.ago + ) + end + + let!(:other_conference) { create(:conference) } let!(:user) { create(:user) } describe 'GET #index' do @@ -12,4 +32,27 @@ describe OrganizationsController do it { expect(response).to render_template('index') } end + + describe 'GET #conferences' do + before :each do + get :conferences, id: organization.id + end + + it 'loads the organization' do + expect(assigns(:organization)).to eq organization + end + + it 'includes organization conferences' do + expect(assigns(:current)).to include conference + end + + it 'does not include conferences outside organization' do + expect(assigns(:current)).not_to include other_conference + expect(assigns(:antiquated)).not_to include other_conference + end + + it 'includes antiquated organization conferences' do + expect(assigns(:antiquated)).to include antiquated_conference + end + end end diff --git a/spec/features/organization_spec.rb b/spec/features/organization_spec.rb index 6fcf590b..72948c2d 100644 --- a/spec/features/organization_spec.rb +++ b/spec/features/organization_spec.rb @@ -48,4 +48,12 @@ feature Organization do it_behaves_like 'successfully updates an organization' end + + context 'anonymously' do + scenario 'index should link to conferences list' do + visit organizations_path + + expect(page).to have_link('Conferences', href: "/organizations/#{organization.id}/conferences") + end + end end diff --git a/spec/features/splashpage_spec.rb b/spec/features/splashpage_spec.rb index ee9b63d5..d33c6c85 100644 --- a/spec/features/splashpage_spec.rb +++ b/spec/features/splashpage_spec.rb @@ -62,14 +62,18 @@ feature Splashpage do end end - context 'public splashpage already created' do + context 'navigation' do let!(:splashpage) { create(:splashpage, conference: conference, public: true)} - scenario 'should have organization name', feature: true, js: true do - sign_in participant - visit conference_path(conference.short_title) + context 'multiple organizations' do + let!(:additional_organization) { create(:organization) } - expect(page).to have_text(conference.organization.name) + scenario 'should have organization name', feature: true, js: true do + sign_in participant + visit conference_path(conference.short_title) + + expect(page).to have_text(conference.organization.name) + end end end end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 139a5cf9..6cd71d2a 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -58,5 +58,21 @@ describe ApplicationHelper, type: :helper do expect(concurrent_events(event).present?).to eq false end end + + describe 'navigation title link' do + it 'should default to OSEM' do + ENV.delete('OSEM_NAME') + expect(nav_root_link_for(nil)).to match 'OSEM' + end + + it 'should use the environment variable' do + ENV['OSEM_NAME'] = Faker::Company.name + expect(nav_root_link_for(nil)).to match ENV['OSEM_NAME'] + end + + it 'should use the conference organization name' do + expect(nav_root_link_for(conference)).to match conference.organization.name + end + end end end