From b9a50ef20d6deb0c966384e3e62a732025b1893d Mon Sep 17 00:00:00 2001 From: Henne Vogelsang Date: Fri, 7 Jun 2024 16:11:25 +0200 Subject: [PATCH 1/7] Drop Organization from database Rolling back this feature. It was a nice attempt but no one ever followed up and made this something else than a code of conduct holder... --- .../20181229233812_drop_organizations.rb | 11 +++++++++ ...33813_add_code_of_conduct_to_conference.rb | 5 ++++ db/schema.rb | 24 +++++++------------ 3 files changed, 25 insertions(+), 15 deletions(-) create mode 100644 db/migrate/20181229233812_drop_organizations.rb create mode 100644 db/migrate/20181229233813_add_code_of_conduct_to_conference.rb diff --git a/db/migrate/20181229233812_drop_organizations.rb b/db/migrate/20181229233812_drop_organizations.rb new file mode 100644 index 00000000..dd1be5f2 --- /dev/null +++ b/db/migrate/20181229233812_drop_organizations.rb @@ -0,0 +1,11 @@ +class DropOrganizations < ActiveRecord::Migration[7.0] + def change + drop_table :organizations do |t| + t.string :name, null: false + t.text :description + t.string :picture + end + + remove_reference :conferences, :organization, index: true + end +end diff --git a/db/migrate/20181229233813_add_code_of_conduct_to_conference.rb b/db/migrate/20181229233813_add_code_of_conduct_to_conference.rb new file mode 100644 index 00000000..6151241f --- /dev/null +++ b/db/migrate/20181229233813_add_code_of_conduct_to_conference.rb @@ -0,0 +1,5 @@ +class AddCodeOfConductToConference < ActiveRecord::Migration[7.0] + def change + add_column :conferences, :code_of_conduct, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 2ad25c7e..ab00f623 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -2,15 +2,17 @@ # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20181229233811) do +ActiveRecord::Schema[7.0].define(version: 2018_12_29_233813) do + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" create_table "answers", force: :cascade do |t| t.string "title" @@ -100,11 +102,10 @@ ActiveRecord::Schema.define(version: 20181229233811) do t.string "picture" t.integer "start_hour", default: 9 t.integer "end_hour", default: 20 - t.integer "organization_id" t.integer "ticket_layout", default: 0 t.string "custom_domain" t.integer "booth_limit", default: 0 - t.index ["organization_id"], name: "index_conferences_on_organization_id" + t.text "code_of_conduct" end create_table "conferences_questions", id: false, force: :cascade do |t| @@ -285,13 +286,6 @@ ActiveRecord::Schema.define(version: 20181229233811) do t.datetime "updated_at" end - create_table "organizations", force: :cascade do |t| - t.string "name", null: false - t.text "description" - t.string "picture" - t.text "code_of_conduct" - end - create_table "payments", force: :cascade do |t| t.string "last4" t.integer "amount" From dc1a6a43635e47782d988870d8570e987b92cb2b Mon Sep 17 00:00:00 2001 From: Henne Vogelsang Date: Fri, 7 Jun 2024 16:13:28 +0200 Subject: [PATCH 2/7] Drop Organization abilities --- app/models/ability.rb | 2 -- app/models/admin_ability.rb | 21 +++------------------ spec/ability/ability_spec.rb | 4 +--- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index 77746620..913c97ff 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -17,7 +17,6 @@ class Ability # Abilities for not signed in users (guests) def not_signed_in - can [:index, :conferences, :code_of_conduct], Organization can [:index], Conference can [:show], Conference do |conference| conference.splashpage&.public == true @@ -86,7 +85,6 @@ class Ability end end - can :index, Organization can :index, Ticket can :manage, TicketPurchase, user_id: user.id can [:new, :create], Payment, user_id: user.id diff --git a/app/models/admin_ability.rb b/app/models/admin_ability.rb index 6100455c..67bf6cfe 100644 --- a/app/models/admin_ability.rb +++ b/app/models/admin_ability.rb @@ -30,7 +30,6 @@ class AdminAbility conference.registration_open? && !conference.registration_limit_exceeded? || conference.program.speakers.confirmed.include?(user) end - can [:index, :admins], Organization can :index, Ticket can :manage, TicketPurchase, user_id: user.id can [:new, :create], Payment, user_id: user.id @@ -81,7 +80,6 @@ class AdminAbility # Abilities for signed in users with roles def signed_in_with_roles(user) - signed_in_with_organization_admin_role(user) if user.has_cached_role? :organization_admin, :any signed_in_with_organizer_role(user) if user.has_cached_role? :organizer, :any signed_in_with_cfp_role(user) if user.has_cached_role? :cfp, :any signed_in_with_info_desk_role(user) if user.has_cached_role? :info_desk, :any @@ -90,22 +88,9 @@ class AdminAbility common_abilities_for_roles(user) end - def signed_in_with_organization_admin_role(user) - org_ids_for_organization_admin = Organization.with_role(:organization_admin, user).pluck(:id) - conf_ids_for_organization_admin = Conference.where(organization_id: org_ids_for_organization_admin).pluck(:id) - - can [:read, :update, :destroy, :assign_org_admins, :unassign_org_admins, :admins], Organization, id: org_ids_for_organization_admin - can :new, Conference - can :manage, Conference, organization_id: org_ids_for_organization_admin - can [:index, :show], Role - - signed_in_with_organizer_role(user, conf_ids_for_organization_admin) - end - - def signed_in_with_organizer_role(user, conf_ids_for_organization_admin = []) - # ids of all the conferences for which the user has the 'organizer' role and - # conferences that belong to organizations for which user is 'organization_admin' - conf_ids = conf_ids_for_organization_admin.concat(Conference.with_role(:organizer, user).pluck(:id)).uniq + def signed_in_with_organizer_role(user) + # ids of all the conferences for which the user has the 'organizer' role + conf_ids = Conference.with_role(:organizer, user).pluck(:id) # ids of all the tracks that belong to the programs of the above conferences track_ids = Track.joins(:program).where('programs.conference_id IN (?)', conf_ids).pluck(:id) diff --git a/spec/ability/ability_spec.rb b/spec/ability/ability_spec.rb index d119f9c5..0f3438ac 100644 --- a/spec/ability/ability_spec.rb +++ b/spec/ability/ability_spec.rb @@ -11,8 +11,7 @@ describe 'User' do subject(:ability){ Ability.new(user) } let(:user){ nil } - let!(:organization) { create(:organization) } - let!(:my_conference) { create(:full_conference, organization: organization) } + let!(:my_conference) { create(:full_conference) } let(:my_room) { create(:room, venue: my_conference.venue) } @@ -36,7 +35,6 @@ describe 'User' do # Test abilities for not signed in users context 'when user is not signed in' do - it{ should be_able_to(:index, Organization)} it{ should be_able_to(:index, Conference)} it{ should be_able_to(:show, conference_public)} From 275be8c80aa27af0174b5af9948600de26a79891 Mon Sep 17 00:00:00 2001 From: Henne Vogelsang Date: Fri, 7 Jun 2024 16:19:29 +0200 Subject: [PATCH 3/7] Drop Organization Feature --- app/controllers/admin/base_controller.rb | 3 +- .../admin/conferences_controller.rb | 2 +- .../admin/organizations_controller.rb | 98 ------------------- app/controllers/admin/versions_controller.rb | 3 - app/controllers/organizations_controller.rb | 21 ---- app/helpers/application_helper.rb | 2 +- app/helpers/versions_helper.rb | 9 -- app/models/conference.rb | 10 +- app/models/organization.rb | 25 ----- app/pdfs/ticket_pdf.rb | 1 - .../admin/conferences/_form_fields.html.haml | 4 - app/views/admin/organizations/_form.html.haml | 22 ----- .../_users_with_org_admin_role.haml | 26 ----- app/views/admin/organizations/edit.html.haml | 9 -- app/views/admin/organizations/index.html.haml | 40 -------- app/views/admin/organizations/new.html.haml | 8 -- .../admin/organizations/show_org_admins.haml | 20 ---- .../versions/_object_desc_and_link.html.haml | 48 ++------- .../_registration_info.html.haml | 2 +- .../conference_registrations/show.html.haml | 3 +- app/views/conferences/_code_of_conduct.haml | 8 +- .../conferences/_conference_details.html.haml | 4 +- app/views/conferences/show.html.haml | 2 +- .../layouts/_admin_sidebar_index.html.haml | 10 -- app/views/layouts/_user_menu.html.haml | 5 - app/views/organizations/index.html.haml | 21 ---- app/views/physical_tickets/show.html.haml | 6 -- config/routes.rb | 12 --- 28 files changed, 22 insertions(+), 402 deletions(-) delete mode 100644 app/controllers/admin/organizations_controller.rb delete mode 100644 app/controllers/organizations_controller.rb delete mode 100644 app/models/organization.rb delete mode 100644 app/views/admin/organizations/_form.html.haml delete mode 100644 app/views/admin/organizations/_users_with_org_admin_role.haml delete mode 100644 app/views/admin/organizations/edit.html.haml delete mode 100644 app/views/admin/organizations/index.html.haml delete mode 100644 app/views/admin/organizations/new.html.haml delete mode 100644 app/views/admin/organizations/show_org_admins.haml delete mode 100644 app/views/organizations/index.html.haml diff --git a/app/controllers/admin/base_controller.rb b/app/controllers/admin/base_controller.rb index 82474426..9b842b71 100644 --- a/app/controllers/admin/base_controller.rb +++ b/app/controllers/admin/base_controller.rb @@ -21,8 +21,7 @@ module Admin return false end unless (current_user.has_cached_role? :organizer, :any) || (current_user.has_cached_role? :cfp, :any) || - (current_user.has_cached_role? :info_desk, :any) || (current_user.has_cached_role? :organization_admin, :any) || - (current_user.has_cached_role? :volunteers_coordinator, :any) || + (current_user.has_cached_role? :info_desk, :any) || (current_user.has_cached_role? :volunteers_coordinator, :any) || (current_user.has_cached_role? :track_organizer, :any) || current_user.is_admin raise CanCan::AccessDenied.new('You are not authorized to access this page.') end diff --git a/app/controllers/admin/conferences_controller.rb b/app/controllers/admin/conferences_controller.rb index 80e36f47..bc4e7cbf 100644 --- a/app/controllers/admin/conferences_controller.rb +++ b/app/controllers/admin/conferences_controller.rb @@ -180,7 +180,7 @@ module Admin :use_vpositions, :use_vdays, :vdays_attributes, :vpositions_attributes, :use_volunteers, :color, :sponsorship_levels_attributes, :sponsors_attributes, - :registration_limit, :organization_id, :ticket_layout, + :registration_limit, :ticket_layout, :booth_limit) end end diff --git a/app/controllers/admin/organizations_controller.rb b/app/controllers/admin/organizations_controller.rb deleted file mode 100644 index 14ff040d..00000000 --- a/app/controllers/admin/organizations_controller.rb +++ /dev/null @@ -1,98 +0,0 @@ -# frozen_string_literal: true - -module Admin - class OrganizationsController < Admin::BaseController - load_and_authorize_resource :organization - before_action :verify_user, only: [:assign_org_admins, :unassign_org_admins] - - def index - @organizations = Organization.all - end - - def create - @organization = Organization.new(organization_params) - if @organization.save - redirect_to admin_organizations_path, - notice: 'Organization successfully created' - else - redirect_to new_admin_organization_path, - error: @organization.errors.full_messages.join(', ') - end - end - - def new - @organization = Organization.new - end - - def edit; end - - def update - if @organization.update(organization_params) - redirect_to admin_organizations_path, - notice: 'Organization successfully updated' - else - redirect_to edit_admin_organization_path(@organization), - error: @organization.errors.full_messages.join(', ') - end - end - - def destroy - if @organization.destroy - redirect_to admin_organizations_path, - notice: 'Organization successfully destroyed' - else - redirect_to admin_organizations_path, - error: 'Organization cannot be destroyed' - end - end - - def assign_org_admins - if @user.has_cached_role? 'organization_admin', @organization - flash[:error] = "User #{@user.email} already has the role organization admin" - elsif @user.add_role 'organization_admin', @organization - flash[:notice] = "Successfully added role organization admin to user #{@user.email}" - else - flash[:error] = "Coud not add role organization admin to #{@user.email}" - end - - redirect_to admins_admin_organization_path(@organization) - end - - def unassign_org_admins - if @user.remove_role 'organization_admin', @organization - flash[:notice] = "Successfully removed role organization admin from user #{@user.email}" - else - flash[:error] = "Could not remove role organization admin from user #{@user.email}" - end - - redirect_to admins_admin_organization_path(@organization) - end - - def admins - @role = @organization.roles.first - @users = @role.users - render 'show_org_admins' - end - - private - - def user_params - params.require(:user).permit(:email) - end - - def verify_user - @user = User.find_by(email: user_params[:email]) - unless @user - redirect_to admins_admin_organization_path(@organization), - error: 'Could not find user. Please provide a valid email!' - return - end - end - - def organization_params - params.require(:organization).permit( - :name, :description, :picture, :code_of_conduct - ) - end - end -end diff --git a/app/controllers/admin/versions_controller.rb b/app/controllers/admin/versions_controller.rb index 1bc7ae2a..751ac746 100644 --- a/app/controllers/admin/versions_controller.rb +++ b/app/controllers/admin/versions_controller.rb @@ -8,9 +8,6 @@ module Admin def index @conferences_with_role = current_user.is_admin? ? Conference.pluck(:short_title) : Conference.with_role([:organizer, :cfp, :info_desk], current_user).pluck(:short_title) - if current_user.has_cached_role? :organization_admin, :any - @conferences_with_role = Organization.with_role('organization_admin', current_user).map { |org| org.conferences.pluck :short_title }.flatten - end @conferences_with_role.uniq! return if @conference.blank? diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb deleted file mode 100644 index 28696d33..00000000 --- a/app/controllers/organizations_controller.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class OrganizationsController < ApplicationController - load_and_authorize_resource :organization - - def index - @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 - render '/conferences/index' - end -end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e3474111..0be070a2 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -140,7 +140,7 @@ module ApplicationHelper def nav_root_link_for(conference) link_text = ( - conference.try(:organization).try(:name) || ENV.fetch('OSEM_NAME', 'OSEM') + ENV.fetch('OSEM_NAME', 'OSEM') ) link_to( link_text, diff --git a/app/helpers/versions_helper.rb b/app/helpers/versions_helper.rb index 0f355f5a..33cecc1e 100644 --- a/app/helpers/versions_helper.rb +++ b/app/helpers/versions_helper.rb @@ -8,15 +8,6 @@ module VersionsHelper version.item && conference ? link_to(link_text, link_url) : "#{link_text} with ID #{version.item_id}" end - def link_to_organization(organization_id) - return 'deleted organization' unless organization_id - - org = Organization.find_by(id: organization_id) - return current_or_last_object_state('Organization', organization_id).try(:name) unless org - - org.name.to_s - end - def link_to_conference(conference_id) return 'deleted conference' if conference_id.nil? diff --git a/app/models/conference.rb b/app/models/conference.rb index cac3a849..8c83f286 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -12,9 +12,6 @@ class Conference < ApplicationRecord scope :upcoming, (-> { where('end_date >= ?', Date.current) }) scope :past, (-> { where('end_date < ?', Date.current) }) - belongs_to :organization - delegate :code_of_conduct, to: :organization - has_paper_trail ignore: %i(updated_at guid revision events_per_week), meta: { conference_id: :id } has_and_belongs_to_many :questions @@ -83,7 +80,6 @@ class Conference < ApplicationRecord :start_hour, :end_hour, :ticket_layout, - :organization, :timezone, presence: true validates :short_title, uniqueness: true @@ -579,11 +575,11 @@ class Conference < ApplicationRecord # * +ActiveRecord+ def self.get_active_conferences_for_dashboard result = Conference.where('start_date > ?', Time.now) - .select('id, short_title, color, start_date, organization_id') + .select('id, short_title, color, start_date') if result.empty? result = Conference - .select('id, short_title, color, start_date, organization_id').limit(2) + .select('id, short_title, color, start_date').limit(2) .order(start_date: :desc) end result @@ -595,7 +591,7 @@ class Conference < ApplicationRecord # ====Returns # * +ActiveRecord+ def self.get_conferences_without_active_for_dashboard(active_conferences) - result = Conference.select('id, short_title, color, start_date, organization_id').order(start_date: :desc) + result = Conference.select('id, short_title, color, start_date').order(start_date: :desc) result - active_conferences end diff --git a/app/models/organization.rb b/app/models/organization.rb deleted file mode 100644 index 877de9df..00000000 --- a/app/models/organization.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -class Organization < ApplicationRecord - resourcify :roles, dependent: :delete_all - - has_paper_trail - - has_many :conferences, dependent: :destroy - - after_create :create_roles - - validates :name, - uniqueness: { - case_sensitive: false - }, - presence: true - - mount_uploader :picture, PictureUploader, mount_on: :picture - - private - - def create_roles - roles.where(name: 'organization_admin').first_or_create(description: 'For the administrators of an organization and its conferences') - end -end diff --git a/app/pdfs/ticket_pdf.rb b/app/pdfs/ticket_pdf.rb index cb624b1d..542e8cb0 100644 --- a/app/pdfs/ticket_pdf.rb +++ b/app/pdfs/ticket_pdf.rb @@ -67,7 +67,6 @@ class TicketPdf < Prawn::Document move_down 70 draw_text @conference.title.to_s, at: [@mid_horizontal + 30, cursor - 30], size: 12 - draw_text @conference.organization.name.to_s, at: [@mid_horizontal + 30, cursor - 50], size: 12 if @conference.venue draw_text @conference.venue_name, at: [@mid_horizontal + 30, cursor - 70] draw_text @conference.venue_street, at: [@mid_horizontal + 30, cursor - 90] diff --git a/app/views/admin/conferences/_form_fields.html.haml b/app/views/admin/conferences/_form_fields.html.haml index afa644ed..bcba474f 100644 --- a/app/views/admin/conferences/_form_fields.html.haml +++ b/app/views/admin/conferences/_form_fields.html.haml @@ -1,10 +1,6 @@ %h4 Basic Information %hr -- if f.object.new_record? - .form-group - = f.label :organization, "Organization" - = f.select :organization_id, Organization.accessible_by(current_ability, :update).pluck(:name, :id) .form-group = f.label :title, "Title" %abbr{title: 'This field is required'} * diff --git a/app/views/admin/organizations/_form.html.haml b/app/views/admin/organizations/_form.html.haml deleted file mode 100644 index 13544440..00000000 --- a/app/views/admin/organizations/_form.html.haml +++ /dev/null @@ -1,22 +0,0 @@ -= form_for(@organization, url: (@organization.new_record? ? admin_organizations_path : admin_organization_path(@organization))) do |f| - .form-group - = f.label :name, "Name" - %abbr{title: 'This field is required'} * - = f.text_field :name, required: true, class: 'form-control', placeholder: 'Name' - .form-group - = f.text_area :description, rows: 10, data: { provide: 'markdown' }, class: 'form-control', placeholder: 'Decribe about your organization...' - %span.help-block - = markdown_hint - .form-group - = f.text_area :code_of_conduct, rows: 10, data: { provide: 'markdown' }, class: 'form-control', placeholder: 'Rules governing behavior and dispute resolution...' - %span.help-block - = markdown_hint - .form-group - = image_tag f.object.picture.thumb.url if f.object.picture? - = f.file_field :picture - %p.text-right - %button{type: 'submit', class: 'btn btn-success'} - - if @organization.new_record? - Create Organization - - else - Update Organization diff --git a/app/views/admin/organizations/_users_with_org_admin_role.haml b/app/views/admin/organizations/_users_with_org_admin_role.haml deleted file mode 100644 index 0632afbf..00000000 --- a/app/views/admin/organizations/_users_with_org_admin_role.haml +++ /dev/null @@ -1,26 +0,0 @@ -.page-header - %h3 Users (#{users.length}) -- if users.present? - %table.datatable#users - %thead - %tr - %th Name - %th Email - - if ( can? :unassign_org_admins, organization ) - %th - Actions - %tbody - - users.each do |user| - %tr - %td= user.name - %td= user.email - - if ( can? :unassign_org_admins, organization ) - %td - = link_to 'Remove from organization admin', - unassign_org_admins_admin_organization_path(organization.id, - role.name, - user: {email: user.email}), - method: :delete, - class: 'btn btn-danger' -- else - %h5 No users found! diff --git a/app/views/admin/organizations/edit.html.haml b/app/views/admin/organizations/edit.html.haml deleted file mode 100644 index c9d69bcd..00000000 --- a/app/views/admin/organizations/edit.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -.row - .col-md-12 - .page-header - %h1 - Edit Organization - = @organization.name -.row - .col-md-8 - = render partial: 'form' diff --git a/app/views/admin/organizations/index.html.haml b/app/views/admin/organizations/index.html.haml deleted file mode 100644 index 09cf187e..00000000 --- a/app/views/admin/organizations/index.html.haml +++ /dev/null @@ -1,40 +0,0 @@ -.row - .col-md-12 - .page-header - %h1 Organizations - - if can? :manage, :all - .btn-group.pull-right - = link_to 'Create Organization', new_admin_organization_path, class: 'btn btn-success pull-right' - %p.text-muted - Manage organizations in OSEM -.row - .col-md-12 - %table.datatable - %thead - %tr - %th Name - %th Upcoming Conferences - %th Past Conferences - %th Code of Conduct? - %th Actions - %tbody - - @organizations.each do |organization| - %tr{ id: "organization-#{organization.id}" } - %td - = organization.name - %td - = organization.conferences.upcoming.count - %td - = organization.conferences.past.count - %td.text-center - - unless organization.code_of_conduct.blank? - = icon 'fa-solid', 'check', title: 'yes' - %td - .btn-group - = link_to 'Admins', admins_admin_organization_path(organization), - method: :get, class: 'btn btn-success' - = link_to 'Edit', edit_admin_organization_path(organization), - method: :get, class: 'btn btn-primary' - = link_to 'Delete', admin_organization_path(organization), - method: :delete, class: 'btn btn-danger', data: { confirm: "Warning: This will delete #{organization.name} and all its data which includes data for all conferences within #{organization.name}. Do you really want to continue?" } - = link_to 'Add Conference', new_admin_conference_path, method: :get, class: 'btn btn-info' diff --git a/app/views/admin/organizations/new.html.haml b/app/views/admin/organizations/new.html.haml deleted file mode 100644 index b38ea937..00000000 --- a/app/views/admin/organizations/new.html.haml +++ /dev/null @@ -1,8 +0,0 @@ -.row - .col-md-12 - .page-header - %h1 - Create Organization -.row - .col-md-8 - = render partial: 'form' diff --git a/app/views/admin/organizations/show_org_admins.haml b/app/views/admin/organizations/show_org_admins.haml deleted file mode 100644 index 5c7698db..00000000 --- a/app/views/admin/organizations/show_org_admins.haml +++ /dev/null @@ -1,20 +0,0 @@ -.row - .col-md-12 - .page-header - %h2 - Organization admins for #{@organization.name} - .text-muted - = @role.description - -.row.col-md-3 - - if ( can? :assign_org_admins, @organization ) - = form_for :user, url: assign_org_admins_admin_organization_path(@organization, @role.name), method: :post do |f| - .form-group - = f.label :email, 'Add user by email: ' - = f.text_field :email, placeholder: "User's email", class: 'form-control', required: true - = f.submit 'Add', id: 'user-add', class: 'btn btn-primary' - -.row - .col-md-12 - = render partial: 'users_with_org_admin_role', - locals: { users: @users, organization: @organization, role: @role } diff --git a/app/views/admin/versions/_object_desc_and_link.html.haml b/app/views/admin/versions/_object_desc_and_link.html.haml index 1728b999..34bf4c8f 100644 --- a/app/views/admin/versions/_object_desc_and_link.html.haml +++ b/app/views/admin/versions/_object_desc_and_link.html.haml @@ -7,26 +7,13 @@ end - case version.item_type -- when 'Organization' - organization - = link_to_organization(version.item_id) - - when 'UsersRole' - role = current_or_last_object_state('Role', object.role_id) - role_name = role.try(:name) || PaperTrail::Version.where(item_type: 'Role', item_id: object.role_id).last.changeset[:name].second role - - if role_name == 'organization_admin' - - if Organization.find_by(id: version.conference_id) - -# organization_admin belongs to organization and not conferences - - organization = Organization.find_by(id: version.conference_id) - = link_if_alive version, role_name, - admins_admin_organization_path(organization), organization - - else - (Deleted Organization) - - else - - conference = Conference.find_by(id: version.conference_id) - - conference_short_title = conference.try(:short_title) || current_or_last_object_state('Conference', version.conference_id).try(:short_title) || ' ' - = link_if_alive version, role.try(:name), admin_conference_role_path(conference_short_title,role.try(:name) || ' '), conference + - conference = Conference.find_by(id: version.conference_id) + - conference_short_title = conference.try(:short_title) || current_or_last_object_state('Conference', version.conference_id).try(:short_title) || ' ' + = link_if_alive version, role.try(:name), admin_conference_role_path(conference_short_title,role.try(:name) || ' '), conference = version.event == 'create' ? 'to' : 'from' user @@ -133,19 +120,10 @@ - when 'Role' role - role_name = object.try(:name) || PaperTrail::Version.where(item_type: 'Role', item_id: version.item_id).last.changeset[:name].second - - if role_name == 'organization_admin' - - if Organization.find_by(id: version.conference_id) - -# organization_admin belongs to organization and not conferences - - organization = Organization.find_by(id: version.conference_id) - = link_if_alive version, role_name, - admins_admin_organization_path(organization), organization - - else - (Role Deleted) - - else - - conference = Conference.find_by(id: version.conference_id) - - conference_short_title = conference.try(:short_title) || current_or_last_object_state('Conference', version.conference_id).try(:short_title) || ' ' - = link_if_alive version, role_name, - admin_conference_role_path(conference_short_title, role_name), conference + - conference = Conference.find_by(id: version.conference_id) + - conference_short_title = conference.try(:short_title) || current_or_last_object_state('Conference', version.conference_id).try(:short_title) || ' ' + = link_if_alive version, role_name, + admin_conference_role_path(conference_short_title, role_name), conference - when 'Venue' venue @@ -202,16 +180,8 @@ user = link_to_user(version.item_id) -- unless %w(Conference Subscription Registration User Organization).include?(version.item_type) - - if (version.item_type == 'Role' && role_name == 'organization_admin') || (version.item_type == 'UsersRole' && role_name == 'organization_admin') - in organization - - if Organization.find_by(id: version.conference_id) - -# organization_admin belongs to organization and not conferences - - organization = Organization.find_by(id: version.conference_id) - = link_to_organization(version.conference_id) - - else - (Organization Deleted) - - elsif version.item_type == 'Commercial' +- unless %w(Conference Subscription Registration User).include?(version.item_type) + - if version.item_type == 'Commercial' - commercial = current_or_last_object_state(version.item_type, version.item_id) - commercialable = current_or_last_object_state(commercial.commercialable_type, commercial.commercialable_id) - unless commercial.commercialable_type == 'Conference' diff --git a/app/views/conference_registrations/_registration_info.html.haml b/app/views/conference_registrations/_registration_info.html.haml index e8293d54..0fd04b51 100644 --- a/app/views/conference_registrations/_registration_info.html.haml +++ b/app/views/conference_registrations/_registration_info.html.haml @@ -27,4 +27,4 @@ (Scheduled on: #{event.time.to_date}) %br -= render 'conferences/code_of_conduct', organization: @conference.organization += render 'conferences/code_of_conduct' diff --git a/app/views/conference_registrations/show.html.haml b/app/views/conference_registrations/show.html.haml index c419d535..d9447049 100644 --- a/app/views/conference_registrations/show.html.haml +++ b/app/views/conference_registrations/show.html.haml @@ -37,8 +37,7 @@ You need to accept the = link_to 'Code of Conduct', '#', data: { toggle: 'modal', target: '#modal-code-of-conduct'} - = render 'conferences/code_of_conduct', - organization: @conference.organization + = render 'conferences/code_of_conduct' - if @conference.surveys.for_registration.any? .row .col-md-12 diff --git a/app/views/conferences/_code_of_conduct.haml b/app/views/conferences/_code_of_conduct.haml index 1b9b9867..d3110867 100644 --- a/app/views/conferences/_code_of_conduct.haml +++ b/app/views/conferences/_code_of_conduct.haml @@ -4,7 +4,7 @@ data: { toggle: 'modal', target: '#modal-code-of-conduct'} - content_for :modals do - - cache [organization, '#CoC-modal'] do + - cache '#CoC-modal' do .modal.fade{ id: "modal-code-of-conduct" } .modal-dialog .modal-content @@ -13,8 +13,6 @@ %i.fa-solid.fa-xmark %h3.modal-title Code of Conduct .modal-body - = markdown organization.code_of_conduct + = markdown conference.code_of_conduct .modal-footer - = link_to 'permalink', - [:code_of_conduct, organization], - target: '_blank' + = link_to 'permalink', :code_of_conduct diff --git a/app/views/conferences/_conference_details.html.haml b/app/views/conferences/_conference_details.html.haml index a79d31e1..ffdd197a 100644 --- a/app/views/conferences/_conference_details.html.haml +++ b/app/views/conferences/_conference_details.html.haml @@ -27,9 +27,7 @@ - if conference.program and conference.program.schedule_public = link_to "Schedule", conference_schedule_path(conference.short_title), class: 'btn btn-default' - unless conference.code_of_conduct.blank? - = link_to "Code of Conduct", - [:code_of_conduct, conference.organization], - class: 'btn btn-default' + = link_to "Code of Conduct", :code_of_conduct, class: 'btn btn-default' - if conference.registration_open? - if conference.user_registered?(current_user) = link_to "My Registration", conference_conference_registration_path(conference.short_title), class: 'btn btn-default' diff --git a/app/views/conferences/show.html.haml b/app/views/conferences/show.html.haml index 85b2bac6..41718b66 100644 --- a/app/views/conferences/show.html.haml +++ b/app/views/conferences/show.html.haml @@ -19,7 +19,7 @@ #splash - if @conference.code_of_conduct.present? - = render 'code_of_conduct', organization: @conference.organization + = render 'code_of_conduct' -# header/description = render 'header', conference: @conference, venue: @conference.venue diff --git a/app/views/layouts/_admin_sidebar_index.html.haml b/app/views/layouts/_admin_sidebar_index.html.haml index 91001405..3da79dd2 100644 --- a/app/views/layouts/_admin_sidebar_index.html.haml +++ b/app/views/layouts/_admin_sidebar_index.html.haml @@ -27,18 +27,8 @@ = link_to(admin_users_path) do %span.fa-solid.fa-user Users - - if can? :index, Organization - %li - = link_to(admin_organizations_path) do - %span.fa-solid.fa-users - Organizations - if can? :index, PaperTrail::Version %li = link_to(admin_revision_history_path) do %span.fa-solid.fa-clock-rotate-left Revision History - - if ENV.fetch('ORGANIZATIONS_ENABLED', nil) == 'true' - %li - = link_to(admin_organizations_path) do - %span.fa-solid.fa-user-group - Organizations diff --git a/app/views/layouts/_user_menu.html.haml b/app/views/layouts/_user_menu.html.haml index 887eee03..f3c965ad 100644 --- a/app/views/layouts/_user_menu.html.haml +++ b/app/views/layouts/_user_menu.html.haml @@ -76,8 +76,3 @@ = link_to(admin_revision_history_path) do %span.fa-solid.fa-clock-rotate-left Revision History - - if ENV.fetch('OSEM_ICHAIN_ENABLED', nil) == 'true' - %li - = link_to(admin_organizations_path) do - %span.fa-solid.fa-user-group - Organizations diff --git a/app/views/organizations/index.html.haml b/app/views/organizations/index.html.haml deleted file mode 100644 index bd97ac2b..00000000 --- a/app/views/organizations/index.html.haml +++ /dev/null @@ -1,21 +0,0 @@ -.container - .row - .col-md-12.page-header - %h1 - Organizations - .btn-group.pull-right - / = link_to 'Add new', new_organization_path, class: 'btn btn-mini btn-success' - - @organizations.each do |organization| - .col-md-4{ id: "organization-#{organization.id}" } - .thumbnail - = image_tag(organization.picture.thumb.url, width: '20%') if organization.picture? - .caption - %h4 - = organization.name - .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/app/views/physical_tickets/show.html.haml b/app/views/physical_tickets/show.html.haml index ec8e7379..69351745 100644 --- a/app/views/physical_tickets/show.html.haml +++ b/app/views/physical_tickets/show.html.haml @@ -34,12 +34,6 @@ = image_tag(@conference.picture.ticket.url, class: 'img-responsive') - else = image_tag('/img/osem-logo.png', class: 'img-responsive') - %p.text-left - %br - %strong - Organization - %br - = @conference.organization.name .col-md-5.box.well %p.text-left %strong diff --git a/config/routes.rb b/config/routes.rb index 5865281d..cc6147e6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -23,13 +23,6 @@ Osem::Application.routes.draw do end namespace :admin do - resources :organizations do - member do - get :admins - post :assign_org_admins - delete :unassign_org_admins - end - end resources :users do member do patch :toggle_confirmation @@ -150,11 +143,6 @@ 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] do - member do - get :conferences, 'code-of-conduct' - end - end resources :conferences, only: [:index, :show] do resources :booths do member do From 85149dc8373514f92e2a565b2efaed8c569fa517 Mon Sep 17 00:00:00 2001 From: Henne Vogelsang Date: Fri, 7 Jun 2024 16:31:23 +0200 Subject: [PATCH 4/7] Drop Organization from specs --- .../admin/conferences_controller_spec.rb | 101 +------ .../admin/organizations_controller_spec.rb | 200 -------------- .../organizations_controller_spec.rb | 60 ---- spec/factories/conferences.rb | 1 - spec/factories/organizations.rb | 15 - spec/features/cfp_ability_spec.rb | 14 +- spec/features/code_of_conduct_spec.rb | 91 ------ spec/features/conference_spec.rb | 12 +- spec/features/info_desk_ability_spec.rb | 14 +- .../organization_admin_ability_spec.rb | 259 ------------------ spec/features/organization_spec.rb | 62 ----- spec/features/organizer_ability_spec.rb | 16 +- spec/features/roles_spec.rb | 46 ---- spec/features/splashpage_spec.rb | 15 - spec/features/track_organizer_ability_spec.rb | 5 +- spec/features/user_ability_spec.rb | 3 +- spec/features/versions_spec.rb | 38 --- spec/helpers/application_helper_spec.rb | 4 - spec/models/organization_spec.rb | 17 -- 19 files changed, 14 insertions(+), 959 deletions(-) delete mode 100644 spec/controllers/admin/organizations_controller_spec.rb delete mode 100644 spec/controllers/organizations_controller_spec.rb delete mode 100644 spec/factories/organizations.rb delete mode 100644 spec/features/code_of_conduct_spec.rb delete mode 100644 spec/features/organization_admin_ability_spec.rb delete mode 100644 spec/features/organization_spec.rb delete mode 100644 spec/models/organization_spec.rb diff --git a/spec/controllers/admin/conferences_controller_spec.rb b/spec/controllers/admin/conferences_controller_spec.rb index 3207d382..0f9f3ffa 100644 --- a/spec/controllers/admin/conferences_controller_spec.rb +++ b/spec/controllers/admin/conferences_controller_spec.rb @@ -5,16 +5,13 @@ require 'spec_helper' describe Admin::ConferencesController do # It is necessary to use bang version of let to build roles before user - let!(:organization) { create(:organization, name: 'organization') } - let!(:conference) { create(:conference, organization: organization, end_date: Date.new(2014, 05, 26) + 15) } - let!(:organization_admin_role) { Role.find_by(name: 'organization_admin', resource: organization) } - let(:organization_admin) { create(:user, role_ids: organization_admin_role.id) } + let!(:conference) { create(:conference, end_date: Date.new(2014, 05, 26) + 15) } let(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) } let!(:organizer) { create(:organizer, resource: conference) } let!(:organizer2) { create(:organizer, email: 'organizer2@email.osem', resource: conference) } let(:participant) { create(:user) } - shared_examples 'access as organizer or organization_admin' do + shared_examples 'access as organizer' do describe 'PATCH #update' do context 'valid attributes' do it 'locates the requested conference' do @@ -197,95 +194,6 @@ describe Admin::ConferencesController do end end - shared_examples 'access as organization_admin' do - describe 'POST #create' do - context 'with valid attributes' do - it 'saves the conference to the database' do - expected = expect do - post :create, params: { conference: - attributes_for(:conference, short_title: 'dps15', organization_id: organization.id) } - end - expected.to change { Conference.count }.by 1 - end - - it 'redirects to conference#show' do - post :create, params: { conference: - attributes_for(:conference, short_title: 'dps15', organization_id: organization.id) } - - expect(response).to redirect_to admin_conference_path( - assigns[:conference].short_title) - end - - it 'creates roles for the conference' do - cfp_role = Role.find_by(name: 'cfp', resource: conference) - info_desk_role = Role.find_by(name: 'info_desk', resource: conference) - volunteers_coordinator_role = Role.find_by(name: 'volunteers_coordinator', resource: conference) - - post :create, params: { conference: - attributes_for(:conference, short_title: 'dps15') } - - expect(conference.roles.count).to eq 4 - - expect(conference.roles).to match_array [organizer_role, cfp_role, info_desk_role, volunteers_coordinator_role] - end - end - - context 'with invalid attributes' do - it 'does not save the conference to the database' do - expected = expect do - post :create, params: { conference: - attributes_for(:conference, short_title: nil, organization_id: organization.id) } - end - expected.to_not change { Conference.count } - end - - it 're-renders the new template' do - post :create, params: { conference: - attributes_for(:conference, short_title: nil, organization_id: organization.id) } - expect(response).to be_successful - end - end - - context 'with duplicate conference short title' do - it 'does not save the conference to the database' do - conference - expected = expect do - post :create, params: { conference: - attributes_for(:conference, short_title: conference.short_title, organization_id: organization.id) } - end - expected.to_not change { Conference.count } - end - - it 're-renders the new template' do - conference - post :create, params: { conference: attributes_for(:conference, short_title: conference.short_title, organization_id: organization.id) } - expect(response).to be_successful - end - end - end - - describe 'GET #new' do - it 'assigns a new conference to conference' do - get :new - expect(assigns(:conference)).to be_a_new(Conference) - end - - it 'renders the :new template' do - get :new - expect(response).to render_template :new - end - end - end - - describe 'organization admin access' do - before do - sign_in(organization_admin) - end - - it_behaves_like 'access as organizer or organization_admin' - it_behaves_like 'access as organization_admin' - end - shared_examples 'access as organizer, participant or guest' do |path, message| describe 'GET #new' do it 'requires organizer privileges' do @@ -299,8 +207,7 @@ describe Admin::ConferencesController do describe 'POST #create' do it 'requires organizer privileges' do - post :create, params: { conference: attributes_for(:conference, - short_title: 'ExCon', organization_id: organization.id) } + post :create, params: { conference: attributes_for(:conference, short_title: 'ExCon') } expect(response).to redirect_to(send(path)) if message expect(flash[:alert]).to match(/#{message}/) @@ -314,7 +221,7 @@ describe Admin::ConferencesController do sign_in(organizer) end - it_behaves_like 'access as organizer or organization_admin' + it_behaves_like 'access as organizer' it_behaves_like 'access as organizer, participant or guest', :root_path, 'You are not authorized to access this page.' end diff --git a/spec/controllers/admin/organizations_controller_spec.rb b/spec/controllers/admin/organizations_controller_spec.rb deleted file mode 100644 index 4468bb34..00000000 --- a/spec/controllers/admin/organizations_controller_spec.rb +++ /dev/null @@ -1,200 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe Admin::OrganizationsController do - let!(:admin) { create(:admin) } - let!(:organization) { create(:organization) } - let!(:user) { create(:user) } - - context 'logged in as user with no role' do - before :each do - sign_in user - end - - describe 'GET #new' do - before :each do - get :new - end - - it 'redirects to root' do - expect(flash[:alert]).to eq('You are not authorized to access this page.') - expect(response).to redirect_to(root_path) - end - end - - describe 'GET #index' do - before :each do - get :index - end - - it 'redirects to root' do - expect(flash[:alert]).to eq('You are not authorized to access this page.') - expect(response).to redirect_to(root_path) - end - end - - describe 'POST #create' do - it 'does not create new organization' do - expected = expect do - post :create, params: { organization: attributes_for(:organization) } - end - expected.to_not change(Organization, :count) - end - - it 'redirects to root' do - post :create, params: { organization: attributes_for(:organization) } - - expect(flash[:alert]).to eq('You are not authorized to access this page.') - expect(response).to redirect_to(root_path) - end - end - - describe 'PATCH #update' do - it 'does not update and redirects to root' do - old_name = organization.name - patch :update, params: { id: organization.id, organization: attributes_for(:organization, name: 'new name') } - - organization.reload - expect(organization.name).to eq(old_name) - expect(flash[:alert]).to eq('You are not authorized to access this page.') - expect(response).to redirect_to(root_path) - end - end - - describe 'DELETE #destroy' do - context 'for a valid organization' do - it 'does not destroy a resource' do - expected = expect do - delete :destroy, params: { id: organization.id } - end - expected.to_not change(Organization, :count) - end - - it 'redirects to root' do - delete :destroy, params: { id: organization.id } - - expect(flash[:alert]).to eq('You are not authorized to access this page.') - expect(response).to redirect_to(root_path) - end - end - end - end - - context 'logged in as admin' do - before :each do - sign_in admin - end - - describe 'GET #new' do - before do - get :new - end - it { expect(response).to render_template('new') } - end - - describe 'GET #index' do - before do - get :index - end - it { expect(response).to render_template('index') } - end - - describe 'POST #create' do - context 'with valid attributes' do - it 'creates new organization' do - expected = expect do - post :create, params: { organization: attributes_for(:organization) } - end - expected.to change { Organization.count }.by(1) - end - - it 'redirects to index' do - post :create, params: { organization: attributes_for(:organization) } - - expect(flash[:notice]).to eq('Organization successfully created') - expect(response).to redirect_to(admin_organizations_path) - end - end - - context 'with invalid attributes' do - it 'does not create new organization' do - expected = expect do - post :create, params: { organization: attributes_for(:organization, name: '') } - end - expected.to_not change(Organization, :count) - end - - it 'redirects to new' do - post :create, params: { organization: attributes_for(:organization, name: '') } - - expect(flash[:error]).to eq("Name can't be blank") - expect(response).to redirect_to(new_admin_organization_path) - end - end - end - - describe 'PATCH #update' do - it 'saves and redirects to index when the attributes are valid' do - patch :update, params: { id: organization.id, organization: attributes_for(:organization, name: 'changed name') } - - organization.reload - expect(organization.name).to eq('changed name') - expect(flash[:notice]).to eq('Organization successfully updated') - expect(response).to redirect_to(admin_organizations_path) - end - - it 'redirects to edit when attributes are invalid' do - patch :update, params: { id: organization.id, organization: attributes_for(:organization, name: '') } - - expect(flash[:error]).to eq("Name can't be blank") - expect(response).to redirect_to(edit_admin_organization_path(organization)) - end - end - - describe 'DELETE #destroy' do - context 'for a valid organization' do - it 'should successfully destroy a resource' do - expected = expect do - delete :destroy, params: { id: organization.id } - end - expected.to change { Organization.count }.by(-1) - end - - it 'redirects to index' do - delete :destroy, params: { id: organization.id } - - expect(flash[:notice]).to eq('Organization successfully destroyed') - expect(response).to redirect_to(admin_organizations_path) - end - end - end - - describe 'POST #assign_org_admins' do - let(:org_admin_role) { Role.find_by(name: 'organization_admin', resource: organization) } - - before do - post :assign_org_admins, params: { id: organization.id, - user: { email: user.email } } - end - - it 'assigns organization_admin role' do - expect(user.roles).to eq [org_admin_role] - end - end - - describe 'DELETE #unassign_org_admins' do - let(:org_admin_role) { Role.find_by(name: 'organization_admin', resource: organization) } - let!(:org_admin_user) { create(:user, role_ids: [org_admin_role.id]) } - - before do - delete :unassign_org_admins, params: { id: organization.id, - user: { email: org_admin_user.email } } - end - - it 'unassigns organization_admin role' do - expect(org_admin_user.reload.roles).to eq [] - end - end - end -end diff --git a/spec/controllers/organizations_controller_spec.rb b/spec/controllers/organizations_controller_spec.rb deleted file mode 100644 index e719f823..00000000 --- a/spec/controllers/organizations_controller_spec.rb +++ /dev/null @@ -1,60 +0,0 @@ -# frozen_string_literal: true - -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 - before :each do - sign_in user - get :index - end - - it { expect(response).to render_template('index') } - end - - describe 'GET #conferences' do - before :each do - get :conferences, params: { 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/factories/conferences.rb b/spec/factories/conferences.rb index ac454c92..0cd9ca18 100644 --- a/spec/factories/conferences.rb +++ b/spec/factories/conferences.rb @@ -14,7 +14,6 @@ FactoryBot.define do registration_limit { 0 } ticket_layout { 'portrait' } description { Faker::Hipster.paragraph } - organization after(:create) do |conference| Role.where(name: 'organizer', resource: conference).first_or_create(description: 'For the organizers of the conference (who shall have full access)') Role.where(name: 'cfp', resource: conference).first_or_create(description: 'For the members of the CfP team') diff --git a/spec/factories/organizations.rb b/spec/factories/organizations.rb deleted file mode 100644 index 1fde9081..00000000 --- a/spec/factories/organizations.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -FactoryBot.define do - factory :organization do - sequence(:name) { |n| "#{Faker::Company.name} #{n}" } - description { Faker::Lorem.paragraph } - - # after(:create) do |organization| - # File.open("spec/support/logos/#{1 + rand(13)}.png") do |file| - # organization.picture = file - # end - # organization.save! - # end - end -end diff --git a/spec/features/cfp_ability_spec.rb b/spec/features/cfp_ability_spec.rb index 3823f21f..2dd059cb 100644 --- a/spec/features/cfp_ability_spec.rb +++ b/spec/features/cfp_ability_spec.rb @@ -4,8 +4,7 @@ require 'spec_helper' feature 'Has correct abilities' do - let(:organization) { create(:organization) } - let(:conference) { create(:full_conference, organization: organization) } + let(:conference) { create(:full_conference) } let(:role_cfp) { Role.find_by(name: 'cfp', resource: conference) } let(:user_cfp) { create(:user, role_ids: [role_cfp.id]) } @@ -14,7 +13,7 @@ feature 'Has correct abilities' do sign_in user_cfp end - scenario 'for organization and conference attributes' do + scenario 'for conference attributes' do visit admin_conference_path(conference.short_title) expect(current_path).to eq(admin_conference_path(conference.short_title)) @@ -169,15 +168,6 @@ feature 'Has correct abilities' do visit admin_conference_path(conference.short_title) expect(current_path).to eq(admin_conference_path(conference.short_title)) - visit admin_organizations_path - expect(current_path).to eq(admin_organizations_path) - - visit edit_admin_organization_path(organization) - expect(current_path).to eq(root_path) - - visit new_admin_organization_path - expect(current_path).to eq(root_path) - visit edit_admin_conference_path(conference.short_title) expect(current_path).to eq(root_path) diff --git a/spec/features/code_of_conduct_spec.rb b/spec/features/code_of_conduct_spec.rb deleted file mode 100644 index 3676b336..00000000 --- a/spec/features/code_of_conduct_spec.rb +++ /dev/null @@ -1,91 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -feature 'Code of Conduct:' do - let!(:organization) { create(:organization) } - let!(:conference) { create(:full_conference, organization: organization) } - let(:admin) { create(:admin) } - let(:sample_text) { Faker::Lorem.paragraph } - - context 'on an organization' do - describe 'as admin' do - before { sign_in admin } - - it 'can add and remove' do - visit admin_organizations_path - within "tr#organization-#{organization.id}" do - expect(page).not_to have_css 'i.fa-check' - click_on 'Edit' - end - expect(page).to have_field 'organization[code_of_conduct]', with: '' - fill_in 'organization[code_of_conduct]', with: sample_text - click_on 'Update Organization' - within "tr#organization-#{organization.id}" do - expect(page).to have_css 'i.fa-check' - click_on 'Edit' - end - expect(page).to have_field 'organization[code_of_conduct]', with: sample_text - fill_in 'organization[code_of_conduct]', with: '' - click_on 'Update Organization' - within "tr#organization-#{organization.id}" do - expect(page).not_to have_css 'i.fa-check' - 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 - - context 'on a conference' do - it 'is linked from the index' do - visit conferences_path - within "#conference-#{conference.id}" do - click_on 'Code of Conduct' - end - expect(page).to have_text(sample_text) - end - - it 'is included in the splash page', js: true do - visit conference_path(conference) - click_on 'Code of Conduct' - expect(page).to have_text(sample_text) - end - end - end - - describe 'as a participant' do - let!(:organization) { create(:organization, code_of_conduct: sample_text) } - let!(:participant) { create(:user) } - - before do - sign_in participant - visit conferences_path - within "#conference-#{conference.id}" do - click_on 'Register' - end - end - - it 'can be viewed', js: true do - page.find('input#registration_accepted_code_of_conduct') - expect(page).to have_text('I have read and accept the Code of Conduct') - expect(page).not_to have_text(sample_text) - within 'form' do - click_on 'Code of Conduct' - end - page.find('.modal-dialog') - expect(page).to have_content(sample_text) - end - end - end -end diff --git a/spec/features/conference_spec.rb b/spec/features/conference_spec.rb index be4235cc..6a700c9b 100644 --- a/spec/features/conference_spec.rb +++ b/spec/features/conference_spec.rb @@ -4,17 +4,9 @@ require 'spec_helper' feature Conference do let(:user) { create(:admin) } - let!(:organization) { create(:organization) } describe 'admin' do - let(:conference) { create(:conference, organization: organization) } - - scenario 'has organization name in menu bar for conference views', feature: true, js: true do - sign_in user - visit admin_conference_path(conference.short_title) - - expect(find('.navbar-brand').text).to eq(conference.organization.name) - end + let(:conference) { create(:conference) } scenario 'adds a new conference', feature: true, js: true do expected_count = Conference.count + 1 @@ -22,7 +14,6 @@ feature Conference do visit new_admin_conference_path - select organization.name, from: 'conference_organization_id' fill_in 'conference_title', with: 'Example Con' fill_in 'conference_short_title', with: 'ExCon' @@ -37,7 +28,6 @@ feature Conference do expect(flash) .to eq('Conference was successfully created.') expect(Conference.count).to eq(expected_count) - expect(Conference.last.organization).to eq(organization) user.reload expect(user.has_cached_role? :organizer, Conference.last).to be(true) end diff --git a/spec/features/info_desk_ability_spec.rb b/spec/features/info_desk_ability_spec.rb index 066c95b8..daf89066 100644 --- a/spec/features/info_desk_ability_spec.rb +++ b/spec/features/info_desk_ability_spec.rb @@ -4,8 +4,7 @@ require 'spec_helper' feature 'Has correct abilities' do - let(:organization) { create(:organization) } - let(:conference) { create(:full_conference, organization: organization) } + let(:conference) { create(:full_conference) } let(:role_info_desk) { Role.find_by(name: 'info_desk', resource: conference) } let(:user_info_desk) { create(:user, role_ids: [role_info_desk.id]) } @@ -14,7 +13,7 @@ feature 'Has correct abilities' do sign_in user_info_desk end - scenario 'for organization and conference attributes' do + scenario 'for conference attributes' do visit admin_conference_path(conference.short_title) expect(current_path).to eq(admin_conference_path(conference.short_title)) @@ -47,15 +46,6 @@ feature 'Has correct abilities' do expect(page).to_not have_link('E-Mails', href: "/admin/conferences/#{conference.short_title}/emails") expect(page).to_not have_link('New Conference', href: '/admin/conferences/new') - visit admin_organizations_path - expect(current_path).to eq(admin_organizations_path) - - visit edit_admin_organization_path(organization) - expect(current_path).to eq(root_path) - - visit new_admin_organization_path - expect(current_path).to eq(root_path) - visit edit_admin_conference_path(conference.short_title) expect(current_path).to eq(root_path) diff --git a/spec/features/organization_admin_ability_spec.rb b/spec/features/organization_admin_ability_spec.rb deleted file mode 100644 index 5765d97f..00000000 --- a/spec/features/organization_admin_ability_spec.rb +++ /dev/null @@ -1,259 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -feature 'Has correct abilities' do - let(:organization) { create(:organization) } - let(:conference) { create(:full_conference, organization: organization) } - let(:role_organization_admin) { Role.find_by(name: 'organization_admin', resource: organization) } - let(:user_organization_admin) { create(:user, role_ids: [role_organization_admin.id]) } - let!(:registration_ticket) { create(:registration_ticket, conference: conference) } - - context 'when user is organization_admin' do - before do - sign_in user_organization_admin - end - - scenario 'for organization attributes' do - visit admin_organizations_path - expect(current_path).to eq(admin_organizations_path) - - visit edit_admin_organization_path(organization) - expect(current_path).to eq(edit_admin_organization_path(organization)) - - visit new_admin_organization_path - expect(current_path).to eq(root_path) - end - - scenario 'for conference attributes' do - visit admin_conference_path(conference.short_title) - expect(current_path).to eq(admin_conference_path(conference.short_title)) - - expect(page).to have_selector('li.nav-header.nav-header-bigger a', text: 'Dashboard') - expect(page).to have_link('Basics', href: "/admin/conferences/#{conference.short_title}/edit") - expect(page).to have_link('Contact', href: "/admin/conferences/#{conference.short_title}/contact/edit") - expect(page).to have_link('Commercials', href: "/admin/conferences/#{conference.short_title}/commercials") - expect(page).to have_link('Splashpage', href: "/admin/conferences/#{conference.short_title}/splashpage") - expect(page).to have_link('Venue', href: "/admin/conferences/#{conference.short_title}/venue") - expect(page).to have_link('Rooms', href: "/admin/conferences/#{conference.short_title}/venue/rooms") - expect(page).to have_link('Lodgings', href: "/admin/conferences/#{conference.short_title}/lodgings") - expect(page).to have_link('Program', href: "/admin/conferences/#{conference.short_title}/program") - expect(page).to have_link('Calls for Content', href: "/admin/conferences/#{conference.short_title}/program/cfps") - expect(page).to have_link('Events', href: "/admin/conferences/#{conference.short_title}/program/events") - expect(page).to have_link('Tracks', href: "/admin/conferences/#{conference.short_title}/program/tracks") - expect(page).to have_link('Event Types', href: "/admin/conferences/#{conference.short_title}/program/event_types") - expect(page).to have_link('Difficulty Levels', href: "/admin/conferences/#{conference.short_title}/program/difficulty_levels") - expect(page).to have_link('Schedules', href: "/admin/conferences/#{conference.short_title}/schedules") - expect(page).to have_link('Reports', href: "/admin/conferences/#{conference.short_title}/program/reports") - expect(page).to have_link('Registrations', href: "/admin/conferences/#{conference.short_title}/registrations") - expect(page).to have_link('Registration Period', href: "/admin/conferences/#{conference.short_title}/registration_period") - expect(page).to have_link('Questions', href: "/admin/conferences/#{conference.short_title}/questions") - expect(page).to have_text('Donations') - expect(page).to have_link('Sponsorship Levels', href: "/admin/conferences/#{conference.short_title}/sponsorship_levels") - expect(page).to have_link('Sponsors', href: "/admin/conferences/#{conference.short_title}/sponsors") - expect(page).to have_link('Tickets', href: "/admin/conferences/#{conference.short_title}/tickets") - expect(page).to have_link('E-Mails', href: "/admin/conferences/#{conference.short_title}/emails") - expect(page).to have_link('Roles', href: "/admin/conferences/#{conference.short_title}/roles") - expect(page).to have_link('Resources', href: "/admin/conferences/#{conference.short_title}/resources") - expect(page).to have_link('New Conference', href: '/admin/conferences/new') - - visit edit_admin_conference_path(conference.short_title) - expect(current_path).to eq(edit_admin_conference_path(conference.short_title)) - - visit edit_admin_conference_contact_path(conference.short_title) - expect(current_path).to eq(edit_admin_conference_contact_path(conference.short_title)) - - visit admin_conference_commercials_path(conference.short_title) - expect(current_path).to eq(admin_conference_commercials_path(conference.short_title)) - - visit new_admin_conference_splashpage_path(conference.short_title) - expect(current_path).to eq(new_admin_conference_splashpage_path(conference.short_title)) - - visit edit_admin_conference_splashpage_path(conference.short_title) - expect(current_path).to eq(edit_admin_conference_splashpage_path(conference.short_title)) - - visit new_admin_conference_venue_path(conference.short_title) - expect(current_path).to eq(new_admin_conference_venue_path(conference.short_title)) - - conference.venue = create(:venue) - visit edit_admin_conference_venue_path(conference.short_title) - expect(current_path).to eq(edit_admin_conference_venue_path(conference.short_title)) - - visit admin_conference_venue_rooms_path(conference.short_title) - expect(current_path).to eq(admin_conference_venue_rooms_path(conference.short_title)) - - create(:room, venue: conference.venue) - visit edit_admin_conference_venue_room_path(conference.short_title, conference.venue.rooms.first) - expect(current_path).to eq(edit_admin_conference_venue_room_path(conference.short_title, conference.venue.rooms.first)) - - visit admin_conference_lodgings_path(conference.short_title) - expect(current_path).to eq(admin_conference_lodgings_path(conference.short_title)) - - visit new_admin_conference_lodging_path(conference.short_title) - expect(current_path).to eq(new_admin_conference_lodging_path(conference.short_title)) - - create(:lodging, conference: conference) - visit edit_admin_conference_lodging_path(conference.short_title, conference.lodgings.first) - expect(current_path).to eq(edit_admin_conference_lodging_path(conference.short_title, conference.lodgings.first)) - - visit new_admin_conference_program_path(conference.short_title) - expect(current_path).to eq(new_admin_conference_program_path(conference.short_title)) - - visit edit_admin_conference_program_path(conference.short_title) - expect(current_path).to eq(edit_admin_conference_program_path(conference.short_title)) - - # Only event exists - visit new_admin_conference_program_cfp_path(conference.short_title) - expect(current_path).to eq(new_admin_conference_program_cfp_path(conference.short_title)) - - # Event and booth cfps exist - cfb = create(:cfp, cfp_type: 'booths', program: conference.program) - visit new_admin_conference_program_cfp_path(conference.short_title) - expect(current_path).to eq new_admin_conference_program_cfp_path(conference.short_title) - - visit edit_admin_conference_program_cfp_path(conference.short_title, conference.program.cfp) - expect(current_path).to eq(edit_admin_conference_program_cfp_path(conference.short_title, conference.program.cfp)) - - # Event, booth, track cfps exist - call_for_tracks = create(:cfp, cfp_type: 'tracks', program: conference.program) - visit new_admin_conference_program_cfp_path(conference.short_title) - expect(current_path).to eq root_path - - # Booth and track cfps exist - conference.program.cfp.destroy! - visit new_admin_conference_program_cfp_path(conference.short_title) - expect(current_path).to eq new_admin_conference_program_cfp_path(conference.short_title) - - # Only booth exists - call_for_tracks.destroy! - visit new_admin_conference_program_cfp_path(conference.short_title) - expect(current_path).to eq(new_admin_conference_program_cfp_path(conference.short_title)) - - visit edit_admin_conference_program_cfp_path(conference.short_title, cfb) - expect(current_path). to eq(edit_admin_conference_program_cfp_path(conference.short_title, cfb)) - - # No cfp exists - cfb.destroy - visit new_admin_conference_program_cfp_path(conference.short_title) - expect(current_path).to eq(new_admin_conference_program_cfp_path(conference.short_title)) - - # Only Tracks cfp exists - call_for_tracks = create(:cfp, cfp_type: 'tracks', program: conference.program) - visit new_admin_conference_program_cfp_path(conference.short_title) - expect(current_path).to eq new_admin_conference_program_cfp_path(conference.short_title) - - visit edit_admin_conference_program_cfp_path(conference.short_title, call_for_tracks) - expect(current_path).to eq edit_admin_conference_program_cfp_path(conference.short_title, call_for_tracks) - - # Event and track cfps exist - create(:cfp, cfp_type: 'events', program: conference.program) - visit new_admin_conference_program_cfp_path(conference.short_title) - expect(current_path).to eq new_admin_conference_program_cfp_path(conference.short_title) - - call_for_tracks.destroy! - visit admin_conference_program_events_path(conference.short_title) - expect(current_path).to eq(admin_conference_program_events_path(conference.short_title)) - - create(:event, program: conference.program) - visit edit_admin_conference_program_event_path(conference.short_title, conference.program.events.first) - expect(current_path).to eq(edit_admin_conference_program_event_path(conference.short_title, conference.program.events.first)) - - visit admin_conference_program_event_types_path(conference.short_title) - expect(current_path).to eq(admin_conference_program_event_types_path(conference.short_title)) - - visit new_admin_conference_program_event_type_path(conference.short_title) - expect(current_path).to eq(new_admin_conference_program_event_type_path(conference.short_title)) - - visit edit_admin_conference_program_event_type_path(conference.short_title, conference.program.event_types.first) - expect(current_path).to eq(edit_admin_conference_program_event_type_path(conference.short_title, conference.program.event_types.first)) - - visit admin_conference_program_difficulty_levels_path(conference.short_title) - expect(current_path).to eq(admin_conference_program_difficulty_levels_path(conference.short_title)) - - visit new_admin_conference_program_difficulty_level_path(conference.short_title) - expect(current_path).to eq(new_admin_conference_program_difficulty_level_path(conference.short_title)) - - visit edit_admin_conference_program_difficulty_level_path(conference.short_title, conference.program.difficulty_levels.first) - expect(current_path).to eq(edit_admin_conference_program_difficulty_level_path(conference.short_title, conference.program.difficulty_levels.first)) - - visit admin_conference_schedules_path(conference.short_title) - expect(current_path).to eq(admin_conference_schedules_path(conference.short_title)) - - create(:schedule, program: conference.program) - visit admin_conference_schedule_path(conference.short_title, conference.program.schedules.first) - expect(current_path).to eq(admin_conference_schedule_path(conference.short_title, conference.program.schedules.first)) - - visit admin_conference_program_reports_path(conference.short_title) - expect(current_path).to eq(admin_conference_program_reports_path(conference.short_title)) - - visit admin_conference_registrations_path(conference.short_title) - expect(current_path).to eq(admin_conference_registrations_path(conference.short_title)) - - create(:registration, user: create(:user), conference: conference) - visit edit_admin_conference_registration_path(conference.short_title, conference.registrations.first) - expect(current_path).to eq(edit_admin_conference_registration_path(conference.short_title, conference.registrations.first)) - - visit new_admin_conference_registration_period_path(conference.short_title) - expect(current_path).to eq(new_admin_conference_registration_period_path(conference.short_title)) - - create(:registration_period, conference: conference) - visit edit_admin_conference_registration_period_path(conference.short_title) - expect(current_path).to eq(edit_admin_conference_registration_period_path(conference.short_title)) - - visit admin_conference_questions_path(conference.short_title) - expect(current_path).to eq(admin_conference_questions_path(conference.short_title)) - - visit admin_conference_sponsorship_levels_path(conference.short_title) - expect(current_path).to eq(admin_conference_sponsorship_levels_path(conference.short_title)) - - visit new_admin_conference_sponsorship_level_path(conference.short_title) - expect(current_path).to eq(new_admin_conference_sponsorship_level_path(conference.short_title)) - - create(:sponsorship_level, conference: conference) - visit edit_admin_conference_sponsorship_level_path(conference.short_title, conference.sponsorship_levels.first) - expect(current_path).to eq(edit_admin_conference_sponsorship_level_path(conference.short_title, conference.sponsorship_levels.first)) - - visit admin_conference_sponsors_path(conference.short_title) - expect(current_path).to eq(admin_conference_sponsors_path(conference.short_title)) - - visit new_admin_conference_sponsor_path(conference.short_title) - expect(current_path).to eq(new_admin_conference_sponsor_path(conference.short_title)) - - create(:sponsor, conference: conference, sponsorship_level: conference.sponsorship_levels.first) - visit edit_admin_conference_sponsor_path(conference.short_title, conference.sponsors.first) - expect(current_path).to eq(edit_admin_conference_sponsor_path(conference.short_title, conference.sponsors.first)) - - visit admin_conference_tickets_path(conference.short_title) - expect(current_path).to eq(admin_conference_tickets_path(conference.short_title)) - - visit new_admin_conference_ticket_path(conference.short_title) - expect(current_path).to eq(new_admin_conference_ticket_path(conference.short_title)) - - create(:ticket, conference: conference) - visit edit_admin_conference_ticket_path(conference.short_title, conference.tickets.first) - expect(current_path).to eq(edit_admin_conference_ticket_path(conference.short_title, conference.tickets.first)) - - visit admin_conference_program_tracks_path(conference.short_title) - expect(current_path).to eq(admin_conference_program_tracks_path(conference.short_title)) - - visit admin_conference_roles_path(conference.short_title) - expect(current_path).to eq(admin_conference_roles_path(conference.short_title)) - - visit admin_conference_emails_path(conference.short_title) - expect(current_path).to eq(admin_conference_emails_path(conference.short_title)) - - visit admin_conference_resources_path(conference.short_title) - expect(current_path).to eq(admin_conference_resources_path(conference.short_title)) - - visit new_admin_conference_resource_path(conference.short_title) - expect(current_path).to eq(new_admin_conference_resource_path(conference.short_title)) - - create(:resource, conference: conference) - visit edit_admin_conference_resource_path(conference.short_title, conference.resources.first) - expect(current_path).to eq(edit_admin_conference_resource_path(conference.short_title, conference.resources.first)) - - visit admin_revision_history_path - expect(current_path).to eq(admin_revision_history_path) - end - end -end diff --git a/spec/features/organization_spec.rb b/spec/features/organization_spec.rb deleted file mode 100644 index ad71cce3..00000000 --- a/spec/features/organization_spec.rb +++ /dev/null @@ -1,62 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -feature Organization do - let!(:organization) { create(:organization) } - let!(:organization_admin_role) { Role.find_by(name: 'organization_admin', resource: organization) } - let(:organization_admin) { create(:user, role_ids: [organization_admin_role.id]) } - let(:admin_user) { create(:admin) } - - shared_examples 'successfully updates an organization' do - scenario 'updates a exsisting organization', feature: true, js: true do - visit edit_admin_organization_path(organization) - fill_in 'organization_name', with: 'changed name' - - click_button 'Update Organization' - - organization.reload - page.find('#flash') - expect(flash).to eq('Organization successfully updated') - expect(organization.name).to eq('changed name') - end - end - - context 'signed in as site admin' do - before do - sign_in admin_user - end - scenario 'creates a new organization', feature: true, js: true do - visit new_admin_organization_path - fill_in 'organization_name', with: 'Organization name' - - click_button 'Create Organization' - page.find('#flash') - expect(flash).to eq('Organization successfully created') - expect(Organization.last.name).to eq('Organization name') - end - - it_behaves_like 'successfully updates an organization' - end - - context 'signed in as organization admin' do - before do - sign_in organization_admin - end - scenario "can't create new organization", feature: true, js: true do - visit new_admin_organization_path - page.find('#flash') - expect(flash).to eq('You are not authorized to access this page.') - end - - 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/organizer_ability_spec.rb b/spec/features/organizer_ability_spec.rb index 6339b6fa..5547e799 100644 --- a/spec/features/organizer_ability_spec.rb +++ b/spec/features/organizer_ability_spec.rb @@ -4,9 +4,8 @@ require 'spec_helper' feature 'Has correct abilities' do - let(:organization) { create(:organization) } - let(:conference) { create(:full_conference, organization: organization) } - let(:other_conference) { create(:conference, organization: organization) } # user is organizer, venue is not set by default + let(:conference) { create(:full_conference) } + let(:other_conference) { create(:conference) } # user is organizer, venue is not set by default let(:role_organizer_conf) { Role.find_by(name: 'organizer', resource: conference) } let(:role_organizer_other_conf) { Role.find_by(name: 'organizer', resource: other_conference) } let(:user_organizer) { create(:user, role_ids: [role_organizer_conf.id, role_organizer_other_conf.id]) } @@ -17,17 +16,6 @@ feature 'Has correct abilities' do sign_in user_organizer end - scenario 'for organization attributes' do - visit admin_organizations_path - expect(current_path).to eq(admin_organizations_path) - - visit edit_admin_organization_path(organization) - expect(current_path).to eq(root_path) - - visit new_admin_organization_path - expect(current_path).to eq(root_path) - end - scenario 'for conference attributes' do visit admin_conference_path(conference.short_title) expect(current_path).to eq(admin_conference_path(conference.short_title)) diff --git a/spec/features/roles_spec.rb b/spec/features/roles_spec.rb index d0968caf..3bc34196 100644 --- a/spec/features/roles_spec.rb +++ b/spec/features/roles_spec.rb @@ -101,52 +101,6 @@ feature Role do end end - context 'organization_admin' do - let!(:organization) { create(:organization) } - let!(:org_admin_role) { Role.find_by(name: 'organization_admin', resource: organization) } - let!(:organization_admin) { create(:user, role_ids: [org_admin_role.id]) } - let(:user_with_no_role) { create :user } - let!(:other_organization) { create(:organization) } - - before do - sign_in organization_admin - visit admin_organizations_path - end - - context 'for the organization it belongs to' do - scenario 'successfully adds role organization_admin' do - click_link('Admins', href: admins_admin_organization_path(organization.id)) - - fill_in 'user_email', with: user_with_no_role.email - click_button 'Add' - user_with_no_role.reload - - expect(user_with_no_role.has_cached_role?('organization_admin', organization)).to be true - end - - scenario 'successfully removes role organization_admin' do - click_link('Admins', href: admins_admin_organization_path(organization.id)) - - first('tbody > tr').find('.btn-danger').click - organization_admin.reload - expect(organization_admin.has_cached_role?('organization_admin', organization)).to be false - end - end - - context 'for the organizations it does not belong to' do - scenario 'does not successfully add role organization_admin' do - click_link('Admins', href: admins_admin_organization_path(other_organization.id)) - - expect(page.has_field?('user_email')).to be false - end - - scenario 'does not successfully removes role organization_admin' do - click_link('Admins', href: admins_admin_organization_path(other_organization.id)) - expect(page.has_css?('.btn-danger')).to be false - end - end - end - context 'organizer' do Role.all.each.map(&:name).each do |role| it_behaves_like 'successfully', role, 'organizer' diff --git a/spec/features/splashpage_spec.rb b/spec/features/splashpage_spec.rb index 96138354..31f843f1 100644 --- a/spec/features/splashpage_spec.rb +++ b/spec/features/splashpage_spec.rb @@ -65,19 +65,4 @@ feature Splashpage do expect(current_path).to eq(root_path) end end - - context 'navigation' do - let!(:splashpage) { create(:splashpage, conference: conference, public: true)} - - context 'multiple organizations' do - let!(:additional_organization) { create(:organization) } - - 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/features/track_organizer_ability_spec.rb b/spec/features/track_organizer_ability_spec.rb index ec2ffdf1..8ad930eb 100644 --- a/spec/features/track_organizer_ability_spec.rb +++ b/spec/features/track_organizer_ability_spec.rb @@ -4,8 +4,7 @@ require 'spec_helper' feature 'Has correct abilities' do - let(:organization) { create(:organization) } - let(:conference) { create(:full_conference, organization: organization) } + let(:conference) { create(:full_conference) } let(:self_organized_track) { create(:track, :self_organized, program: conference.program, state: 'confirmed') } let(:role_track_organizer) { Role.where(name: 'track_organizer', resource: self_organized_track).first_or_create } let(:user_track_organizer) { create(:user, role_ids: [role_track_organizer.id]) } @@ -15,7 +14,7 @@ feature 'Has correct abilities' do sign_in user_track_organizer end - scenario 'for organization and conference attributes' do + scenario 'for conference attributes' do visit admin_conference_path(conference.short_title) expect(current_path).to eq(admin_conference_path(conference.short_title)) diff --git a/spec/features/user_ability_spec.rb b/spec/features/user_ability_spec.rb index 322ed6d0..6b957ec1 100644 --- a/spec/features/user_ability_spec.rb +++ b/spec/features/user_ability_spec.rb @@ -4,8 +4,7 @@ require 'spec_helper' feature 'Has correct abilities' do - let(:organization) { create(:organization) } - let(:conference) { create(:full_conference, organization: organization) } # user is cfp + let(:conference) { create(:full_conference) } # user is cfp let(:user) { create(:user) } context 'when user has no role' do diff --git a/spec/features/versions_spec.rb b/spec/features/versions_spec.rb index bc1ebf89..181598e5 100644 --- a/spec/features/versions_spec.rb +++ b/spec/features/versions_spec.rb @@ -306,44 +306,6 @@ feature 'Version' do expect(page).to have_no_text('Someone (probably via the console) created new commercial') end - scenario 'display changes in organization', feature: true, versioning: true, js: true do - admin = create(:admin) - sign_in admin - - visit new_admin_organization_path - fill_in 'organization_name', with: 'New org' - click_button 'Create Organization' - - visit admin_revision_history_path - expect(page).to have_text('created new organization New org') - end - - context 'organization role', feature: true, versioning: true, js: true do - let!(:user) { create(:user) } - let!(:role) do - Role.find_by( - resource_id: conference.organization.id, - resource_type: 'Organization' - ) - end - - setup do - user.add_role :organization_admin, conference.organization - user.remove_role :organization_admin, conference.organization - visit admin_revision_history_path - end - - it 'is recorded to history when user is added' do - skip('fails since paper_trail 12.2.0') - expect(page).to have_text(/added role organization_admin with ID \d+ to user #{user.name} in organization #{conference.organization.name}/) - end - - it 'is recorded to history when user is removed' do - skip('fails since paper_trail 12.2.0') - expect(page).to have_text(/removed role organization_admin with ID \d+ from user #{user.name} in organization #{conference.organization.name}/) - end - end - scenario 'display changes in users_role for conference role', feature: true, versioning: true, js: true do user = create(:user) role = Role.find_by(name: 'cfp', resource_id: conference.id, resource_type: 'Conference') diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 5a036ebc..041e2714 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -67,10 +67,6 @@ describe ApplicationHelper, type: :helper do ENV.delete('OSEM_NAME') expect(nav_root_link_for(nil)).to match 'OSEM' end - - it 'should use the conference organization name' do - expect(nav_root_link_for(conference)).to match h(conference.organization.name) - end end end diff --git a/spec/models/organization_spec.rb b/spec/models/organization_spec.rb deleted file mode 100644 index b9d78b7d..00000000 --- a/spec/models/organization_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe Organization do - let(:organization) { create(:organization) } - - describe 'validation' do - it 'is not valid without a name' do - should validate_presence_of(:name) - end - end - - describe 'associations' do - it { should have_many(:conferences).dependent(:destroy) } - end -end From 9f1e877ea010298bdb78e1a3324b328d33d6ac39 Mon Sep 17 00:00:00 2001 From: Henne Vogelsang Date: Fri, 7 Jun 2024 17:35:41 +0200 Subject: [PATCH 5/7] Expose Conference.code_of_conduct --- .../admin/conferences_controller.rb | 2 +- app/controllers/conferences_controller.rb | 2 ++ .../admin/conferences/_form_fields.html.haml | 5 +++++ .../_registration_info.html.haml | 10 +++------- app/views/conferences/_code_of_conduct.haml | 18 ------------------ .../conferences/_conference_details.html.haml | 4 ++-- app/views/conferences/_social_media.haml | 6 ++++++ .../conferences/code_of_conduct.html.haml | 10 ++++++++++ app/views/conferences/show.html.haml | 3 --- config/routes.rb | 4 ++++ 10 files changed, 33 insertions(+), 31 deletions(-) delete mode 100644 app/views/conferences/_code_of_conduct.haml create mode 100644 app/views/conferences/code_of_conduct.html.haml diff --git a/app/controllers/admin/conferences_controller.rb b/app/controllers/admin/conferences_controller.rb index bc4e7cbf..69ee19a3 100644 --- a/app/controllers/admin/conferences_controller.rb +++ b/app/controllers/admin/conferences_controller.rb @@ -181,7 +181,7 @@ module Admin :vpositions_attributes, :use_volunteers, :color, :sponsorship_levels_attributes, :sponsors_attributes, :registration_limit, :ticket_layout, - :booth_limit) + :booth_limit, :code_of_conduct) end end end diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index a9dcdd3b..8a4262f1 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -108,6 +108,8 @@ class ConferencesController < ApplicationController end end + def code_of_conduct; end + private def conference_finder_conditions diff --git a/app/views/admin/conferences/_form_fields.html.haml b/app/views/admin/conferences/_form_fields.html.haml index bcba474f..c9a20452 100644 --- a/app/views/admin/conferences/_form_fields.html.haml +++ b/app/views/admin/conferences/_form_fields.html.haml @@ -32,6 +32,11 @@ %span.help-block This will be displayed on the front page. = f.hidden_field :picture_cache + .form-group + = f.text_area :code_of_conduct, rows: 10, data: { provide: 'markdown' }, class: 'form-control' + %span.help-block + Rules governing behavior and dispute resolution... + = markdown_hint = f.select :ticket_layout, Conference.ticket_layouts.keys, {}, class: 'form-control' %span.help-block Layout type for tickets of the conference. diff --git a/app/views/conference_registrations/_registration_info.html.haml b/app/views/conference_registrations/_registration_info.html.haml index 0fd04b51..cb2a3086 100644 --- a/app/views/conference_registrations/_registration_info.html.haml +++ b/app/views/conference_registrations/_registration_info.html.haml @@ -1,16 +1,14 @@ -- unless @conference.code_of_conduct.blank? - - code_of_conduct_link = link_to 'Code of Conduct', '#', - data: { toggle: 'modal', target: '#modal-code-of-conduct'} +- if @conference.code_of_conduct.present? - if @registration.accepted_code_of_conduct = icon 'fa-solid', 'square-check' I have read and accepted the - = code_of_conduct_link + = link_to "Code of Conduct", code_of_conduct_conference_path(@conference.short_title) - else .checkbox %label = f.check_box :accepted_code_of_conduct, required: true I have read and accept the - = code_of_conduct_link + = link_to "Code of Conduct", code_of_conduct_conference_path(@conference.short_title) %abbr{title: 'This field is required'} * - if @conference.program.events.with_registration_open.any? || @registration.events.any? @@ -26,5 +24,3 @@ - if event.scheduled? (Scheduled on: #{event.time.to_date}) %br - -= render 'conferences/code_of_conduct' diff --git a/app/views/conferences/_code_of_conduct.haml b/app/views/conferences/_code_of_conduct.haml deleted file mode 100644 index d3110867..00000000 --- a/app/views/conferences/_code_of_conduct.haml +++ /dev/null @@ -1,18 +0,0 @@ -= content_for :splash_nav do - %li - = link_to 'Code of Conduct', '#', - data: { toggle: 'modal', target: '#modal-code-of-conduct'} - -- content_for :modals do - - cache '#CoC-modal' do - .modal.fade{ id: "modal-code-of-conduct" } - .modal-dialog - .modal-content - .modal-header - %button.close{ data: { dismiss: 'modal' } } - %i.fa-solid.fa-xmark - %h3.modal-title Code of Conduct - .modal-body - = markdown conference.code_of_conduct - .modal-footer - = link_to 'permalink', :code_of_conduct diff --git a/app/views/conferences/_conference_details.html.haml b/app/views/conferences/_conference_details.html.haml index ffdd197a..571cca4a 100644 --- a/app/views/conferences/_conference_details.html.haml +++ b/app/views/conferences/_conference_details.html.haml @@ -26,8 +26,8 @@ = link_to "View Conference", conference_path(conference.short_title), class: 'btn btn-default' - if conference.program and conference.program.schedule_public = link_to "Schedule", conference_schedule_path(conference.short_title), class: 'btn btn-default' - - unless conference.code_of_conduct.blank? - = link_to "Code of Conduct", :code_of_conduct, class: 'btn btn-default' + - if conference.code_of_conduct.present? + = link_to "Code of Conduct", code_of_conduct_conference_path(conference.short_title), class: 'btn btn-default' - if conference.registration_open? - if conference.user_registered?(current_user) = link_to "My Registration", conference_conference_registration_path(conference.short_title), class: 'btn btn-default' diff --git a/app/views/conferences/_social_media.haml b/app/views/conferences/_social_media.haml index 672a19cd..9b542aa0 100644 --- a/app/views/conferences/_social_media.haml +++ b/app/views/conferences/_social_media.haml @@ -27,3 +27,9 @@ - if contact.email? = mail_to "#{ contact.email }" do %i.fa-solid.fa-envelope.fa-4x + .row + .col-md-12 + - if @conference.code_of_conduct.present? + %hr + %p.text-center + = link_to "Code of Conduct", code_of_conduct_conference_path(@conference.short_title) diff --git a/app/views/conferences/code_of_conduct.html.haml b/app/views/conferences/code_of_conduct.html.haml new file mode 100644 index 00000000..57f27cf7 --- /dev/null +++ b/app/views/conferences/code_of_conduct.html.haml @@ -0,0 +1,10 @@ +.container + .row + .col-md-12 + .page-header + %h1 + = @conference.short_title + Code Of Conduct + .row + .col-md-12 + = markdown @conference.code_of_conduct diff --git a/app/views/conferences/show.html.haml b/app/views/conferences/show.html.haml index 41718b66..1bdf80b3 100644 --- a/app/views/conferences/show.html.haml +++ b/app/views/conferences/show.html.haml @@ -18,9 +18,6 @@ #splash - - if @conference.code_of_conduct.present? - = render 'code_of_conduct' - -# header/description = render 'header', conference: @conference, venue: @conference.venue diff --git a/config/routes.rb b/config/routes.rb index cc6147e6..730d43cf 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -192,6 +192,10 @@ Osem::Application.routes.draw do get :events end end + + member do + get 'code-of-conduct' + end end namespace :api, defaults: {format: 'json'} do From 494af47af24329c77abdd1ab587f4d00ea4846ce Mon Sep 17 00:00:00 2001 From: Henne Vogelsang Date: Fri, 7 Jun 2024 16:34:23 +0200 Subject: [PATCH 6/7] Remove Organization from the rest of the code base.. --- CHANGES.md | 12 ------------ lib/tasks/roles.rake | 4 ---- 2 files changed, 16 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 0080f621..6da2b749 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -41,18 +41,6 @@ data. bundle exec rake data:set_conference_in_versions RAILS_ENV=production ``` -### Organization admins - -We have a new role `organization admins` which allow a user to manage their -organization and create and manage a conference within the organization. This -needs the role to exist in the database, otherwise the application crashes -as it is assumed to exist. For that, run the following rake task: - -``` -bundle exec rake roles:add RAILS_ENV=production -``` - - # Changes in OSEM 1.0 [Released May 24, 2016](https://osem.io/1.0) diff --git a/lib/tasks/roles.rake b/lib/tasks/roles.rake index 3b392963..026ba09a 100644 --- a/lib/tasks/roles.rake +++ b/lib/tasks/roles.rake @@ -4,10 +4,6 @@ namespace :roles do desc 'Adds back deleted roles to all conferences' task add: :environment do - Organization.all.each do |org| - Role.where(name: 'organization_admin', resource: org).first_or_create(description: 'For the administrators of an organization and its conferences') - end - Conference.all.each do |c| Role.where(name: 'organizer', resource: c).first_or_create(description: 'For the organizers of the conference (who shall have full access)') Role.where(name: 'cfp', resource: c).first_or_create(description: 'For the members of the CfP team') From 350153a5f0b2668d4452c3791a16b1e6fefd1875 Mon Sep 17 00:00:00 2001 From: Henne Vogelsang Date: Fri, 7 Jun 2024 16:34:45 +0200 Subject: [PATCH 7/7] Update rubocop TODO --- .rubocop_todo.yml | 213 ++++++++++++++++++++++++---------------------- 1 file changed, 112 insertions(+), 101 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 7521eabc..3b48cdae 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,12 +1,12 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-06-06 15:22:39 UTC using RuboCop version 1.63.5. +# on 2024-06-07 15:38:52 UTC using RuboCop version 1.64.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 3 +# Offense count: 4 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. # Include: **/*.gemfile, **/Gemfile, **/gems.rb @@ -14,13 +14,13 @@ Bundler/OrderedGems: Exclude: - 'Gemfile' -# Offense count: 161 +# Offense count: 151 # Configuration parameters: EnforcedStyle. # SupportedStyles: link_or_button, strict Capybara/ClickLinkOrButtonStyle: Enabled: false -# Offense count: 350 +# Offense count: 280 # This cop supports safe autocorrection (--autocorrect). Capybara/CurrentPathExpectation: Exclude: @@ -28,7 +28,6 @@ Capybara/CurrentPathExpectation: - 'spec/features/cfp_ability_spec.rb' - 'spec/features/conference_registration_spec.rb' - 'spec/features/info_desk_ability_spec.rb' - - 'spec/features/organization_admin_ability_spec.rb' - 'spec/features/organizer_ability_spec.rb' - 'spec/features/proposals_spec.rb' - 'spec/features/registration_periods_spec.rb' @@ -37,29 +36,20 @@ Capybara/CurrentPathExpectation: - 'spec/features/track_organizer_ability_spec.rb' - 'spec/features/user_ability_spec.rb' -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: have_no, not_to -Capybara/NegationMatcher: - Exclude: - - 'spec/features/code_of_conduct_spec.rb' - -# Offense count: 14 +# Offense count: 13 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: DefaultSelector. Capybara/RSpec/HaveSelector: Exclude: - 'spec/features/cfp_ability_spec.rb' - 'spec/features/info_desk_ability_spec.rb' - - 'spec/features/organization_admin_ability_spec.rb' - 'spec/features/organizer_ability_spec.rb' - 'spec/features/proposals_spec.rb' - 'spec/features/sponsor_spec.rb' - 'spec/features/track_organizer_ability_spec.rb' - 'spec/features/voting_spec.rb' -# Offense count: 82 +# Offense count: 78 # This cop supports safe autocorrection (--autocorrect). Capybara/SpecificFinders: Enabled: false @@ -81,7 +71,7 @@ FactoryBot/AssociationStyle: - 'spec/factories/surveys.rb' - 'spec/factories/tracks.rb' -# Offense count: 12 +# Offense count: 11 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Include, EnforcedStyle, ExplicitOnly. # Include: **/*_spec.rb, **/spec/**/*, **/test/**/*, **/features/support/factories/**/*.rb @@ -168,7 +158,7 @@ Layout/ExtraSpacing: - 'db/migrate/20140719160903_create_delayed_jobs.rb' - 'spec/models/conference_spec.rb' -# Offense count: 43 +# Offense count: 42 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses @@ -242,7 +232,7 @@ Layout/LineContinuationSpacing: - 'app/controllers/conference_registrations_controller.rb' - 'app/models/cfp.rb' -# Offense count: 32 +# Offense count: 31 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: aligned, indented @@ -273,14 +263,14 @@ Layout/MultilineHashBraceLayout: - 'config/routes.rb' - 'spec/models/event_spec.rb' -# Offense count: 33 +# Offense count: 32 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: symmetrical, new_line, same_line Layout/MultilineMethodCallBraceLayout: Enabled: false -# Offense count: 47 +# Offense count: 38 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: aligned, indented, indented_relative_to_receiver @@ -326,12 +316,11 @@ Layout/SpaceAroundKeyword: Exclude: - 'config/initializers/feature.rb' -# Offense count: 4 +# Offense count: 3 # This cop supports safe autocorrection (--autocorrect). Layout/SpaceAroundMethodCallOperator: Exclude: - 'spec/features/cfp_ability_spec.rb' - - 'spec/features/organization_admin_ability_spec.rb' - 'spec/features/organizer_ability_spec.rb' - 'spec/models/program_spec.rb' @@ -345,7 +334,7 @@ Layout/SpaceAroundOperators: - 'app/views/admin/events/_all_with_comments.xlsx.axlsx' - 'lib/tasks/data.rake' -# Offense count: 139 +# Offense count: 138 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. # SupportedStyles: space, no_space @@ -382,7 +371,7 @@ Layout/SpaceInsideArrayLiteralBrackets: - 'config/initializers/devise.rb' - 'config/routes.rb' -# Offense count: 44 +# Offense count: 42 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. # SupportedStyles: space, no_space @@ -447,12 +436,11 @@ Layout/TrailingEmptyLines: - 'lib/tasks/event_attatchments.rake' - 'lib/tasks/roles.rake' -# Offense count: 13 +# Offense count: 11 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowedMethods, AllowedPatterns. Lint/AmbiguousBlockAssociation: Exclude: - - 'spec/controllers/admin/conferences_controller_spec.rb' - 'spec/controllers/admin/event_schedules_controller_spec.rb' - 'spec/controllers/admin/registration_periods_controller_spec.rb' - 'spec/controllers/admin/users_controller_spec.rb' @@ -511,11 +499,12 @@ Lint/UnusedBlockArgument: Exclude: - 'lib/tasks/user.rake' -# Offense count: 1 +# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods. Lint/UnusedMethodArgument: Exclude: + - 'app/helpers/application_helper.rb' - 'config/initializers/fuckups.rb' # Offense count: 2 @@ -525,16 +514,16 @@ Lint/UriRegexp: - 'app/models/commercial.rb' - 'app/models/contact.rb' -# Offense count: 127 +# Offense count: 125 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: - Max: 72 + Max: 70 # Offense count: 28 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. # AllowedMethods: refine Metrics/BlockLength: - Max: 211 + Max: 202 # Offense count: 1 # Configuration parameters: CountBlocks. @@ -544,9 +533,9 @@ Metrics/BlockNesting: # Offense count: 14 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 652 + Max: 649 -# Offense count: 26 +# Offense count: 25 # Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/CyclomaticComplexity: Max: 16 @@ -561,7 +550,7 @@ Metrics/MethodLength: Metrics/ModuleLength: Max: 174 -# Offense count: 23 +# Offense count: 21 # Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/PerceivedComplexity: Max: 19 @@ -661,13 +650,13 @@ RSpec/BeEmpty: - 'spec/controllers/conference_registration_controller_spec.rb' - 'spec/models/conference_spec.rb' -# Offense count: 161 +# Offense count: 143 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnabledMethods. RSpec/Capybara/FeatureMethods: Enabled: false -# Offense count: 318 +# Offense count: 302 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: @@ -713,29 +702,26 @@ RSpec/EmptyLineAfterExampleGroup: Exclude: - 'spec/controllers/admin/users_controller_spec.rb' -# Offense count: 11 +# Offense count: 10 # This cop supports safe autocorrection (--autocorrect). RSpec/EmptyLineAfterFinalLet: Exclude: - 'spec/controllers/admin/event_schedules_controller_spec.rb' - 'spec/controllers/admin/users_controller_spec.rb' - 'spec/controllers/application_controller_spec.rb' - - 'spec/features/conference_spec.rb' - 'spec/models/conference_spec.rb' - 'spec/models/payment_spec.rb' - 'spec/models/ticket_spec.rb' -# Offense count: 16 +# Offense count: 12 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowConsecutiveOneLiners. RSpec/EmptyLineAfterHook: Exclude: - 'spec/controllers/admin/booths_controller_spec.rb' - 'spec/controllers/admin/comments_controller_spec.rb' - - 'spec/controllers/admin/organizations_controller_spec.rb' - 'spec/controllers/admin/ticket_scannings_controller_spec.rb' - 'spec/controllers/admin/users_controller_spec.rb' - - 'spec/features/organization_spec.rb' - 'spec/features/roles_spec.rb' - 'spec/models/conference_spec.rb' - 'spec/models/payment_spec.rb' @@ -754,18 +740,17 @@ RSpec/EmptyLineAfterSubject: - 'spec/models/survey_spec.rb' - 'spec/models/track_spec.rb' -# Offense count: 215 +# Offense count: 202 # Configuration parameters: CountAsOne. RSpec/ExampleLength: - Max: 187 + Max: 181 -# Offense count: 15 +# Offense count: 13 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples. # DisallowedExamples: works RSpec/ExampleWording: Exclude: - - 'spec/controllers/admin/organizations_controller_spec.rb' - 'spec/controllers/admin/registration_periods_controller_spec.rb' - 'spec/helpers/application_helper_spec.rb' - 'spec/helpers/events_helper_spec.rb' @@ -775,16 +760,14 @@ RSpec/ExampleWording: - 'spec/models/ticket_purchase_spec.rb' - 'spec/models/ticket_spec.rb' -# Offense count: 37 +# Offense count: 32 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: method_call, block RSpec/ExpectChange: Exclude: - 'spec/controllers/admin/booths_controller_spec.rb' - - 'spec/controllers/admin/conferences_controller_spec.rb' - 'spec/controllers/admin/event_schedules_controller_spec.rb' - - 'spec/controllers/admin/organizations_controller_spec.rb' - 'spec/controllers/admin/registration_periods_controller_spec.rb' - 'spec/controllers/admin/schedules_controller_spec.rb' - 'spec/controllers/admin/ticket_scannings_controller_spec.rb' @@ -811,7 +794,7 @@ RSpec/FilePath: - 'spec/models/comment_spec.rb' - 'spec/models/openid.rb' -# Offense count: 172 +# Offense count: 166 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: implicit, each, example @@ -823,7 +806,7 @@ RSpec/IdenticalEqualityAssertion: Exclude: - 'spec/controllers/admin/conferences_controller_spec.rb' -# Offense count: 140 +# Offense count: 137 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: is_expected, should @@ -834,7 +817,6 @@ RSpec/ImplicitExpect: - 'spec/models/conference_spec.rb' - 'spec/models/event_schedule_spec.rb' - 'spec/models/event_type_spec.rb' - - 'spec/models/organization_spec.rb' - 'spec/models/registration_period_spec.rb' - 'spec/models/room_spec.rb' - 'spec/models/schedule_spec.rb' @@ -844,7 +826,7 @@ RSpec/ImplicitExpect: - 'spec/models/ticket_spec.rb' - 'spec/models/user_spec.rb' -# Offense count: 39 +# Offense count: 38 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: single_line_only, single_statement_only, disallow, require_implicit @@ -854,7 +836,6 @@ RSpec/ImplicitSubject: - 'spec/models/booth_spec.rb' - 'spec/models/conference_spec.rb' - 'spec/models/event_type_spec.rb' - - 'spec/models/organization_spec.rb' - 'spec/models/registration_period_spec.rb' - 'spec/models/sponsor_spec.rb' - 'spec/models/sponsorship_level_spec.rb' @@ -901,11 +882,11 @@ RSpec/LeadingSubject: - 'spec/models/conference_spec.rb' - 'spec/models/ticket_spec.rb' -# Offense count: 61 +# Offense count: 56 RSpec/LetSetup: Enabled: false -# Offense count: 4 +# Offense count: 3 # This cop supports safe autocorrection (--autocorrect). RSpec/MatchArray: Exclude: @@ -919,7 +900,7 @@ RSpec/MatchArray: RSpec/MessageSpies: EnforcedStyle: receive -# Offense count: 244 +# Offense count: 225 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: hash, symbol @@ -931,14 +912,14 @@ RSpec/MultipleDescribes: Exclude: - 'spec/models/conference_spec.rb' -# Offense count: 270 +# Offense count: 251 RSpec/MultipleExpectations: - Max: 97 + Max: 94 -# Offense count: 249 +# Offense count: 218 # Configuration parameters: AllowSubject. RSpec/MultipleMemoizedHelpers: - Max: 32 + Max: 31 # Offense count: 396 # Configuration parameters: EnforcedStyle, IgnoreSharedExamples. @@ -950,7 +931,7 @@ RSpec/NamedSubject: - 'spec/models/room_spec.rb' - 'spec/models/track_spec.rb' -# Offense count: 208 +# Offense count: 202 # Configuration parameters: AllowedGroups. RSpec/NestedGroups: Max: 7 @@ -964,12 +945,27 @@ RSpec/NoExpectationExample: - 'spec/controllers/admin/registration_periods_controller_spec.rb' - 'spec/features/voting_spec.rb' -# Offense count: 83 +# Offense count: 78 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: not_to, to_not RSpec/NotToNot: - Enabled: false + Exclude: + - 'spec/controllers/admin/booths_controller_spec.rb' + - 'spec/controllers/admin/event_schedules_controller_spec.rb' + - 'spec/controllers/admin/registration_periods_controller_spec.rb' + - 'spec/controllers/admin/ticket_scannings_controller_spec.rb' + - 'spec/controllers/booths_controller_spec.rb' + - 'spec/features/cfp_ability_spec.rb' + - 'spec/features/info_desk_ability_spec.rb' + - 'spec/features/organizer_ability_spec.rb' + - 'spec/features/sponsor_spec.rb' + - 'spec/features/track_organizer_ability_spec.rb' + - 'spec/features/tracks_spec.rb' + - 'spec/models/program_spec.rb' + - 'spec/models/track_spec.rb' + - 'spec/models/user_spec.rb' + - 'spec/pdfs/ticket_pdf_spec.rb' # Offense count: 1 RSpec/OverwritingSetup: @@ -1005,7 +1001,7 @@ RSpec/ReturnFromStub: Exclude: - 'spec/helpers/events_helper_spec.rb' -# Offense count: 19 +# Offense count: 18 # This cop supports safe autocorrection (--autocorrect). RSpec/ScatteredLet: Exclude: @@ -1018,7 +1014,7 @@ RSpec/ScatteredSetup: Exclude: - 'spec/models/payment_spec.rb' -# Offense count: 32 +# Offense count: 30 # This cop supports safe autocorrection (--autocorrect). RSpec/SortMetadata: Exclude: @@ -1069,11 +1065,10 @@ RSpec/VoidExpect: Exclude: - 'spec/models/conference_spec.rb' -# Offense count: 3 +# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). RSpecRails/AvoidSetupHook: Exclude: - - 'spec/features/versions_spec.rb' - 'spec/helpers/events_helper_spec.rb' # Offense count: 2 @@ -1101,7 +1096,7 @@ RSpecRails/InferredSpecType: - 'spec/helpers/users_helper_spec.rb' - 'spec/routing/routing_spec.rb' -# Offense count: 24 +# Offense count: 23 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: ExpectedOrder, Include. # ExpectedOrder: index, show, new, edit, create, update, destroy @@ -1276,7 +1271,7 @@ Rails/FilePath: - 'spec/features/sponsor_spec.rb' - 'spec/support/deprecation_shitlist.rb' -# Offense count: 81 +# Offense count: 80 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowedMethods, AllowedPatterns. # AllowedMethods: order, limit, select, lock @@ -1322,7 +1317,7 @@ Rails/HttpStatus: - 'app/controllers/admin/venue_commercials_controller.rb' - 'app/controllers/commercials_controller.rb' -# Offense count: 102 +# Offense count: 99 Rails/I18nLocaleTexts: Enabled: false @@ -1396,13 +1391,12 @@ Rails/Present: - 'app/models/program.rb' - 'app/models/venue.rb' -# Offense count: 6 +# Offense count: 5 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Include. # Include: **/Rakefile, **/*.rake Rails/RakeEnvironment: Exclude: - - 'lib/tasks/dump_db.rake' - 'lib/tasks/spec.rake' # Offense count: 1 @@ -1413,10 +1407,25 @@ Rails/RedundantActiveRecordAllMethod: Exclude: - 'db/migrate/20160309182655_remove_dietary_choices_table.rb' -# Offense count: 20 +# Offense count: 19 # This cop supports unsafe autocorrection (--autocorrect-all). Rails/RedundantPresenceValidationOnBelongsTo: - Enabled: false + Exclude: + - 'app/models/booth.rb' + - 'app/models/cfp.rb' + - 'app/models/comment.rb' + - 'app/models/contact.rb' + - 'app/models/event.rb' + - 'app/models/event_schedule.rb' + - 'app/models/events_registration.rb' + - 'app/models/payment.rb' + - 'app/models/qanswer.rb' + - 'app/models/question.rb' + - 'app/models/registration.rb' + - 'app/models/room.rb' + - 'app/models/sponsor.rb' + - 'app/models/survey_reply.rb' + - 'app/models/ticket_purchase.rb' # Offense count: 2 Rails/RenderInline: @@ -1458,7 +1467,7 @@ Rails/SkipsModelValidations: Rails/ThreeStateBooleanColumn: Enabled: false -# Offense count: 48 +# Offense count: 47 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: strict, flexible @@ -1469,7 +1478,6 @@ Rails/TimeZone: - 'config/environments/test.rb' - 'db/migrate/20180226032958_add_created_at_and_updated_at_to_event_types.rb' - 'db/migrate/20180313012253_add_timestamps_to_tickets.rb' - - 'lib/tasks/dump_db.rake' - 'spec/controllers/admin/comments_controller_spec.rb' - 'spec/factories/users.rb' - 'spec/helpers/application_helper_spec.rb' @@ -1482,7 +1490,7 @@ Rails/TopLevelHashWithIndifferentAccess: Exclude: - 'db/migrate/20140701123203_add_events_per_week_to_conference.rb' -# Offense count: 13 +# Offense count: 12 # Configuration parameters: Include. # Include: app/models/**/*.rb Rails/UniqueValidationWithoutIndex: @@ -1492,7 +1500,6 @@ Rails/UniqueValidationWithoutIndex: - 'app/models/commercial.rb' - 'app/models/conference.rb' - 'app/models/events_registration.rb' - - 'app/models/organization.rb' - 'app/models/registration.rb' - 'app/models/role.rb' - 'app/models/subscription.rb' @@ -1594,7 +1601,7 @@ Style/ConditionalAssignment: - 'db/migrate/20140610165551_migrate_data_person_to_user.rb' - 'db/migrate/20140820124117_undo_wrong_migration20140801080705_add_users_to_events.rb' -# Offense count: 518 +# Offense count: 517 # Configuration parameters: AllowedConstants. Style/Documentation: Enabled: false @@ -1639,7 +1646,7 @@ Style/ExpandPathArguments: Exclude: - 'spec/spec_helper.rb' -# Offense count: 36 +# Offense count: 38 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never @@ -1652,7 +1659,7 @@ Style/GlobalStdStream: Exclude: - 'config/environments/production.rb' -# Offense count: 28 +# Offense count: 27 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. Style/GuardClause: @@ -1682,11 +1689,11 @@ Style/HashLikeCase: Exclude: - 'app/helpers/versions_helper.rb' -# Offense count: 367 +# Offense count: 346 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys -# SupportedShorthandSyntax: always, never, either, consistent +# SupportedShorthandSyntax: always, never, either, consistent, either_consistent Style/HashSyntax: Enabled: false @@ -1697,18 +1704,11 @@ Style/HashTransformValues: - 'app/controllers/admin/comments_controller.rb' - 'app/helpers/chart_helper.rb' -# Offense count: 57 +# Offense count: 56 # This cop supports safe autocorrection (--autocorrect). Style/IfUnlessModifier: Enabled: false -# Offense count: 8 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/LineEndConcatenation: - Exclude: - - 'spec/features/conference_spec.rb' - - 'spec/features/registration_periods_spec.rb' - # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Style/MapToHash: @@ -1928,14 +1928,13 @@ Style/RedundantParentheses: - 'app/models/venue.rb' - 'lib/tasks/version.rake' -# Offense count: 3 +# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowMultipleReturnValues. Style/RedundantReturn: Exclude: - 'app/controllers/admin/booths_controller.rb' - 'app/controllers/admin/events_controller.rb' - - 'app/controllers/admin/organizations_controller.rb' # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). @@ -1981,13 +1980,27 @@ Style/SoleNestedConditional: - 'db/migrate/20140801170430_move_event_media_to_commercial.rb' - 'db/migrate/20151018152439_create_programs_table.rb' -# Offense count: 28 +# Offense count: 20 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Mode. Style/StringConcatenation: - Enabled: false + Exclude: + - 'app/controllers/admin/commercials_controller.rb' + - 'app/controllers/admin/conferences_controller.rb' + - 'app/controllers/admin/events_controller.rb' + - 'app/controllers/admin/roles_controller.rb' + - 'app/controllers/admin/surveys_controller.rb' + - 'app/controllers/payments_controller.rb' + - 'app/helpers/application_helper.rb' + - 'app/helpers/users_helper.rb' + - 'app/helpers/versions_helper.rb' + - 'app/models/commercial.rb' + - 'app/models/conference.rb' + - 'lib/tasks/data.rake' + - 'spec/features/contact_spec.rb' + - 'spec/helpers/events_helper_spec.rb' -# Offense count: 16 +# Offense count: 12 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes @@ -1997,12 +2010,11 @@ Style/StringLiterals: - 'config/deploy.rb' - 'config/environments/production.rb' - 'config/puma.rb' - - 'lib/tasks/dump_db.rake' - 'lib/tasks/events_registrations.rake' - 'lib/tasks/factory_bot.rake' - 'lib/tasks/user.rake' -# Offense count: 14 +# Offense count: 8 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: single_quotes, double_quotes @@ -2011,9 +2023,8 @@ Style/StringLiteralsInInterpolation: - 'app/views/admin/events/_all_events.xlsx.axlsx' - 'app/views/admin/events/_all_with_comments.xlsx.axlsx' - 'app/views/admin/events/_confirmed_events.xlsx.axlsx' - - 'lib/tasks/dump_db.rake' -# Offense count: 110 +# Offense count: 105 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, MinSize. # SupportedStyles: percent, brackets @@ -2059,7 +2070,7 @@ Style/WordArray: EnforcedStyle: percent MinSize: 6 -# Offense count: 525 +# Offense count: 497 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. # URISchemes: http, https