diff --git a/.rubocop.yml b/.rubocop.yml index 23ceccc8..bdb72694 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,10 +2,16 @@ require: rubocop-rspec inherit_from: .rubocop_todo.yml +inherit_mode: + merge: + - Exclude + AllCops: UseCache: true CacheRootDirectory: tmp/rubocop_cache_rails_dir MaxFilesInCache: 4000 + Exclude: + - db/schema.rb #################### Style ########################### diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0dc492c9..958943c2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1156,7 +1156,6 @@ Style/StringLiterals: - 'config/deploy.rb' - 'config/environments/production.rb' - 'config/puma.rb' - - 'db/schema.rb' - 'lib/tasks/dump_db.rake' - 'lib/tasks/events_registrations.rake' - 'lib/tasks/factory_bot.rake' diff --git a/Dockerfile.base b/Dockerfile.base index 9e274751..1865285a 100644 --- a/Dockerfile.base +++ b/Dockerfile.base @@ -17,7 +17,7 @@ RUN zypper -n install --no-recommends \ # as ruby ruby2.5-devel \ # as browser for feature tests - chromium + chromium xorg-x11-fonts # Setup sudo RUN echo 'osem ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers diff --git a/Gemfile b/Gemfile index 067631c7..3d897cef 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' -ruby ENV['OSEM_RUBY_VERSION'] || '2.5.5' +ruby '~> 2.5.0' # rails-assets requires >= 1.8.4 if Gem::Version.new(Bundler::VERSION) < Gem::Version.new('1.8.4') @@ -247,7 +247,6 @@ group :test do gem 'database_cleaner' gem 'geckodriver-helper' gem 'rspec-rails' - gem 'transactional_capybara' gem 'webdrivers' # for measuring test coverage gem 'codecov', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 55b474f0..f2b06ecc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -13,25 +13,25 @@ GEM remote: https://rails-assets.org/ specs: Ascii85 (1.0.3) - actioncable (5.2.3) - actionpack (= 5.2.3) + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.3) - actionpack (= 5.2.3) - actionview (= 5.2.3) - activejob (= 5.2.3) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.3) - actionview (= 5.2.3) - activesupport (= 5.2.3) - rack (~> 2.0) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.3) - activesupport (= 5.2.3) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -41,20 +41,20 @@ GEM activemodel (>= 4.1, < 6.1) case_transform (>= 0.2) jsonapi-renderer (>= 0.1.1.beta1, < 0.3) - activejob (5.2.3) - activesupport (= 5.2.3) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) globalid (>= 0.3.6) - activemodel (5.2.3) - activesupport (= 5.2.3) - activerecord (5.2.3) - activemodel (= 5.2.3) - activesupport (= 5.2.3) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) arel (>= 9.0) - activestorage (5.2.3) - actionpack (= 5.2.3) - activerecord (= 5.2.3) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) marcel (~> 0.3.1) - activesupport (5.2.3) + activesupport (5.2.4.3) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -76,8 +76,8 @@ GEM ast (2.4.0) autoprefixer-rails (9.6.4) execjs - awesome_nested_set (3.1.4) - activerecord (>= 4.0.0, < 5.3) + awesome_nested_set (3.2.1) + activerecord (>= 4.0.0, < 7.0) aws_cf_signer (0.1.3) axlsx_rails (0.5.2) actionpack (>= 3.1) @@ -90,7 +90,7 @@ GEM bootstrap-switch-rails (3.0.2) bootstrap3-datetimepicker-rails (4.17.47) momentjs-rails (>= 2.8.1) - builder (3.2.3) + builder (3.2.4) byebug (11.0.1) cancancan (2.3.0) capybara (3.26.0) @@ -125,7 +125,8 @@ GEM simplecov url coderay (1.1.1) - concurrent-ruby (1.1.5) + concurrent-ruby (1.1.6) + connection_pool (2.2.2) countable-rails (0.0.1) railties (>= 3.1) countries (3.0.0) @@ -137,7 +138,7 @@ GEM sort_alphabetical (~> 1.0) crack (0.4.3) safe_yaml (~> 1.0.0) - crass (1.0.5) + crass (1.0.6) daemons (1.3.1) dalli (2.7.10) dante (0.2.0) @@ -230,7 +231,7 @@ GEM htmlentities (4.3.4) http-cookie (1.0.3) domain_name (~> 0.5) - i18n (1.7.0) + i18n (1.8.3) concurrent-ruby (~> 1.0) i18n_data (0.8.0) inversion (1.1.1) @@ -269,7 +270,7 @@ GEM rb-inotify (~> 0.9, >= 0.9.7) ruby_dep (~> 1.2) loggability (0.14.0) - loofah (2.4.0) + loofah (2.6.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) lumberjack (1.0.12) @@ -281,14 +282,14 @@ GEM mime-types (3.2.2) mime-types-data (~> 3.2015) mime-types-data (3.2018.0812) - mimemagic (0.3.3) + mimemagic (0.3.5) mina (1.2.3) open4 (~> 1.3.4) rake mini_magick (4.9.5) mini_mime (1.0.2) mini_portile2 (2.4.0) - minitest (5.13.0) + minitest (5.14.1) momentjs-rails (2.20.1) railties (>= 3.1) monetize (1.9.2) @@ -306,7 +307,7 @@ GEM nenv (0.3.0) netrc (0.11.0) nio4r (2.5.2) - nokogiri (1.10.8) + nokogiri (1.10.9) mini_portile2 (~> 2.4.0) notiffany (0.1.1) nenv (~> 0.1) @@ -377,24 +378,24 @@ GEM slop (~> 3.4) public_suffix (3.1.1) puma (3.12.6) - rack (2.1.4) + rack (2.2.3) rack-openid (1.3.1) rack (>= 1.1.0) ruby-openid (>= 2.1.8) rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.3) - actioncable (= 5.2.3) - actionmailer (= 5.2.3) - actionpack (= 5.2.3) - actionview (= 5.2.3) - activejob (= 5.2.3) - activemodel (= 5.2.3) - activerecord (= 5.2.3) - activestorage (= 5.2.3) - activesupport (= 5.2.3) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) bundler (>= 1.3.0) - railties (= 5.2.3) + railties (= 5.2.4.3) sprockets-rails (>= 2.0.0) rails-assets-bootstrap (3.3.6) rails-assets-jquery (>= 1.9.1, < 3) @@ -428,9 +429,9 @@ GEM rails-i18n (5.1.3) i18n (>= 0.7, < 2) railties (>= 5.0, < 6) - railties (5.2.3) - actionpack (= 5.2.3) - activesupport (= 5.2.3) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) @@ -559,18 +560,16 @@ GEM stripe (> 5, < 6) sysexits (1.2.0) temple (0.8.0) - thor (0.20.3) + thor (1.0.1) thread_safe (0.3.6) tilt (2.0.9) timecop (0.9.1) - transactional_capybara (0.2.0) - capybara transitions (1.2.1) ttfunk (1.5.1) turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) - tzinfo (1.2.5) + tzinfo (1.2.7) thread_safe (~> 0.1) uglifier (4.1.20) execjs (>= 0.3.0, < 3) @@ -597,7 +596,7 @@ GEM addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff - websocket-driver (0.7.1) + websocket-driver (0.7.2) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) whenever (0.10.0) @@ -713,7 +712,6 @@ DEPENDENCIES stripe stripe-ruby-mock timecop - transactional_capybara transitions turbolinks uglifier (>= 1.3.0) diff --git a/INSTALL.md b/INSTALL.md index 39f9ce4c..27037af2 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -37,7 +37,7 @@ There is a rudimentary docker-compose configuration for production usage (`docke 1. Configure OSEM - You have at least to set `SECRET_KEY_BASE` + You have at least to set `OSEM_DB_PASSWORD` and `SECRET_KEY_BASE` ``` cp dotenv.example .env.production vim .env.production diff --git a/app/models/admin_ability.rb b/app/models/admin_ability.rb index 19d6c4d3..455246d2 100644 --- a/app/models/admin_ability.rb +++ b/app/models/admin_ability.rb @@ -99,6 +99,8 @@ class AdminAbility can :manage, Conference, organization_id: org_ids_for_organization_admin can [:index, :show], Role + can [:index, :revert_object, :revert_attribute], PaperTrail::Version, organization_id: org_ids_for_organization_admin + signed_in_with_organizer_role(user, conf_ids_for_organization_admin) end diff --git a/app/models/role.rb b/app/models/role.rb index 2be87d7b..7b67a158 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -5,7 +5,9 @@ class Role < ApplicationRecord has_many :users_roles has_many :users, through: :users_roles - has_paper_trail on: [:create, :update], only: [:name, :description], meta: { conference_id: :resource_id } + has_paper_trail on: [:create, :update], + only: [:name, :description], + meta: { conference_id: :conference_id, organization_id: :organization_id } before_destroy :cancel scopify @@ -14,6 +16,14 @@ class Role < ApplicationRecord validates :name, uniqueness: { scope: :resource } + def conference_id + resource_type == 'Conference' ? resource_id : nil + end + + def organization_id + resource_type == 'Organization' ? resource_id : nil + end + private # Needed to ensure that removing all user from role doesn't remove role. diff --git a/app/models/users_role.rb b/app/models/users_role.rb index b5dbe9fb..eb046f3d 100644 --- a/app/models/users_role.rb +++ b/app/models/users_role.rb @@ -4,11 +4,8 @@ class UsersRole < ApplicationRecord belongs_to :role belongs_to :user - has_paper_trail on: [:create, :destroy], meta: { conference_id: :conference_id } + delegate :conference_id, :organization_id, to: :role - private - - def conference_id - role.resource_id - end + has_paper_trail on: [:create, :destroy], + meta: { conference_id: :conference_id, organization_id: :organization_id } end diff --git a/app/views/admin/cfps/_form.html.haml b/app/views/admin/cfps/_form.html.haml index 1cff0645..8e3c7f35 100644 --- a/app/views/admin/cfps/_form.html.haml +++ b/app/views/admin/cfps/_form.html.haml @@ -17,7 +17,7 @@ input_html: { class: 'form-control', id: 'registration-period-end-datepicker' } = f.input :description, hint: markdown_hint, - input_html: { rows: 2, data: { provide: 'markdown-editable' } } + input_html: { rows: 2, data: { provide: 'markdown' } } - if cfp.cfp_type == 'events' = f.input :enable_registrations, as: :boolean, hint: 'Allow submitters to request registration?' diff --git a/app/views/admin/conferences/edit.html.haml b/app/views/admin/conferences/edit.html.haml index edb8f12b..456c5f12 100644 --- a/app/views/admin/conferences/edit.html.haml +++ b/app/views/admin/conferences/edit.html.haml @@ -9,7 +9,7 @@ = semantic_form_for(@conference, url: admin_conference_path(@conference.short_title), html: {multipart: true}) do |f| = f.input :title, hint: "The full title of the conference, e.g. 'openSUSE Conference 2014'" = f.input :short_title, hint: "A short title, e.g. 'oSC14', to be used in URLs" - = f.input :description, hint: markdown_hint('A description of the conference.'), input_html: { rows: 5, data: { provide: 'markdown-editable' } } + = f.input :description, hint: markdown_hint('A description of the conference.'), input_html: { rows: 5, data: { provide: 'markdown' } } = f.input :color, hint: 'The color will be used eg for the dashboard.', input_html: {size: 6, type: 'color'} = f.label 'Conference Logo' %br diff --git a/app/views/admin/lodgings/_form.html.haml b/app/views/admin/lodgings/_form.html.haml index 11d829aa..8d5ba82e 100644 --- a/app/views/admin/lodgings/_form.html.haml +++ b/app/views/admin/lodgings/_form.html.haml @@ -11,7 +11,7 @@ = semantic_form_for(@lodging, url: (@lodging.new_record? ? admin_conference_lodgings_path : admin_conference_lodging_path(@conference.short_title, @lodging))) do |f| = f.input :name, input_html: { autofocus: true} = f.input :website_link, input_html: { type: :url } - = f.input :description, input_html: { rows: 5, cols: 20, data: { provide: 'markdown-editable' } }, hint: markdown_hint + = f.input :description, input_html: { rows: 5, cols: 20, data: { provide: 'markdown' } }, hint: markdown_hint - if @lodging.picture? = image_tag @lodging.picture.thumb.url = f.input :picture diff --git a/app/views/admin/organizations/_form.html.haml b/app/views/admin/organizations/_form.html.haml index fa326431..9e8db2a1 100644 --- a/app/views/admin/organizations/_form.html.haml +++ b/app/views/admin/organizations/_form.html.haml @@ -2,11 +2,11 @@ = f.inputs name: 'Organization details' do = f.input :name, as: :string, required: true = f.input :description, as: :text, - input_html: { rows: 10, data: { provide: 'markdown-editable' } }, + input_html: { rows: 10, data: { provide: 'markdown' } }, hint: markdown_hint, placeholder: 'Decribe about your organization...' = f.input :code_of_conduct, as: :text, - input_html: { rows: 10, data: { provide: 'markdown-editable' } }, + input_html: { rows: 10, data: { provide: 'markdown' } }, hint: markdown_hint, placeholder: 'Rules governing behavior and dispute resolution...' = image_tag f.object.picture.thumb.url if f.object.picture? diff --git a/app/views/admin/resources/_form.html.haml b/app/views/admin/resources/_form.html.haml index ce5f25b0..a7a1b328 100644 --- a/app/views/admin/resources/_form.html.haml +++ b/app/views/admin/resources/_form.html.haml @@ -9,7 +9,7 @@ .col-md-8 = semantic_form_for(@resource, :url => (@resource.new_record? ? admin_conference_resources_path : admin_conference_resource_path(@conference.short_title, @resource))) do |f| = f.input :name, input_html: { autofocus: true } - = f.input :description, input_html: { rows: 5, data: { provide: 'markdown-editable' } } + = f.input :description, input_html: { rows: 5, data: { provide: 'markdown' } } = f.input :used = f.input :quantity %p.text-right diff --git a/app/views/admin/sponsors/_form.html.haml b/app/views/admin/sponsors/_form.html.haml index 5e475714..19bc2ae6 100644 --- a/app/views/admin/sponsors/_form.html.haml +++ b/app/views/admin/sponsors/_form.html.haml @@ -10,7 +10,7 @@ .col-md-8 = semantic_form_for(@sponsor, url: (@sponsor.new_record? ? admin_conference_sponsors_path : admin_conference_sponsor_path(@conference.short_title, @sponsor))) do |f| = f.input :name, input_html: { autofocus: true } - = f.input :description, input_html: { rows: 5, cols: 20, data: { provide: 'markdown-editable' } }, hint: markdown_hint + = f.input :description, input_html: { rows: 5, cols: 20, data: { provide: 'markdown' } }, hint: markdown_hint = image_tag f.object.picture.thumb.url if f.object.picture? = f.input :picture = f.input :website_url diff --git a/app/views/admin/tickets/_form.html.haml b/app/views/admin/tickets/_form.html.haml index 73c93229..c4e4288c 100644 --- a/app/views/admin/tickets/_form.html.haml +++ b/app/views/admin/tickets/_form.html.haml @@ -10,7 +10,7 @@ .col-md-8 = semantic_form_for(@ticket, url: (@ticket.new_record? ? admin_conference_tickets_path : admin_conference_ticket_path(@conference.short_title, @ticket))) do |f| = f.input :title, input_html: { autofocus: true } - = f.input :description, input_html: { rows: 5, data: { provide: 'markdown-editable' } } + = f.input :description, input_html: { rows: 5, data: { provide: 'markdown' } } = f.input :price = f.input :price_currency, as: :select, class: 'form-control', collection: ['USD', 'EUR', 'GBP', 'INR', 'CNY', 'CHF'], include_blank: false = f.input :registration_ticket, hint: 'A registration ticket is with which user register for the conference.' diff --git a/app/views/admin/tracks/_form.html.haml b/app/views/admin/tracks/_form.html.haml index cfdd9bf3..7c9fda4e 100644 --- a/app/views/admin/tracks/_form.html.haml +++ b/app/views/admin/tracks/_form.html.haml @@ -23,6 +23,6 @@ with = link_to 'rooms', admin_conference_venue_rooms_path(@conference.short_title) , if you want to select a room for the track. - = f.input :description, input_html: {rows: 2, data: { provide: 'markdown-editable' } }, hint: markdown_hint + = f.input :description, input_html: {rows: 2, data: { provide: 'markdown' } }, hint: markdown_hint = f.input :cfp_active, label: 'Allow event submitters to select this track for their proposal' = f.action :submit, as: :button, button_html: { class: 'btn btn-primary' } diff --git a/app/views/admin/users/_form.html.haml b/app/views/admin/users/_form.html.haml index 40ec8a7a..7604f0d3 100644 --- a/app/views/admin/users/_form.html.haml +++ b/app/views/admin/users/_form.html.haml @@ -20,7 +20,7 @@ = f.input :email = f.input :password if @user.new_record? = f.input :affiliation, as: :string - = f.input :biography, input_html: { rows: 10, data: { provide: 'markdown-editable' } }, + = f.input :biography, input_html: { rows: 10, data: { provide: 'markdown' } }, hint: markdown_hint = f.actions do = f.action :submit, button_html: {class: 'btn btn-primary'} diff --git a/app/views/admin/venues/_form.html.haml b/app/views/admin/venues/_form.html.haml index e19325da..85742702 100644 --- a/app/views/admin/venues/_form.html.haml +++ b/app/views/admin/venues/_form.html.haml @@ -14,7 +14,7 @@ .col-md-8 = semantic_form_for(@venue, url: admin_conference_venue_path(@conference.short_title)) do |f| = f.inputs :name, :website - = f.input :description, input_html: { rows: 5, cols: 20, data: { provide: 'markdown-editable' } }, hint: markdown_hint + = f.input :description, input_html: { rows: 5, cols: 20, data: { provide: 'markdown' } }, hint: markdown_hint = f.label 'Venue Logo' %br - if @venue.picture? 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..be9f4741 100644 --- a/app/views/admin/versions/_object_desc_and_link.html.haml +++ b/app/views/admin/versions/_object_desc_and_link.html.haml @@ -15,18 +15,14 @@ - 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 + - if version.conference_id - 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 + - elsif version.organization_id + - organization = Organization.find(version.organization_id) + = link_if_alive version, role_name, + admins_admin_organization_path(organization), organization = version.event == 'create' ? 'to' : 'from' user @@ -133,19 +129,15 @@ - 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 + - if version.conference_id - 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 + - elsif version.organization_id + - organization = Organization.find(version.organization_id) + = link_if_alive version, role_name, + admins_admin_organization_path(organization), organization - when 'Venue' venue @@ -203,20 +195,16 @@ = 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' + - 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' in conference = link_to_conference(version.conference_id) + - elsif version.organization_id + - organization = Organization.find(version.organization_id) + in organization + = link_to_organization(version.organization_id) - else in conference = link_to_conference(version.conference_id) diff --git a/app/views/booths/_form.html.haml b/app/views/booths/_form.html.haml index 583db3d9..8135de50 100644 --- a/app/views/booths/_form.html.haml +++ b/app/views/booths/_form.html.haml @@ -3,11 +3,11 @@ .col-md-8 = semantic_form_for(@booth, url: @url, html: { multipart: true }) do |f| = f.input :title, as: :string, input_html: { autofocus: true }, required: true - = f.input :description, input_html: { rows: 5, data: { provide: 'markdown-editable' } }, required: true, + = f.input :description, input_html: { rows: 5, data: { provide: 'markdown' } }, required: true, hint: 'This field becomes public upon request acceptance' - = f.input :reasoning, input_html: { rows: 5, data: { provide: 'markdown-editable' } }, required: true, + = f.input :reasoning, input_html: { rows: 5, data: { provide: 'markdown' } }, required: true, label: 'How it fits the conference' - = f.input :submitter_relationship, input_html: { rows: 5, data: { provide: 'markdown-editable' } }, required: true, + = f.input :submitter_relationship, input_html: { rows: 5, data: { provide: 'markdown' } }, required: true, label: 'Submitter\'s relation', hint: 'e.g. employee, comunity manager, etc' = f.input :website_url diff --git a/app/views/proposals/_proposal_form.html.haml b/app/views/proposals/_proposal_form.html.haml index 5131790e..89942deb 100644 --- a/app/views/proposals/_proposal_form.html.haml +++ b/app/views/proposals/_proposal_form.html.haml @@ -29,7 +29,7 @@ %span{ class: 'help-block select-help-text collapse event_difficulty_level_id', id: "#{difficulty_level.id}-help" } = difficulty_level.description - = f.input :abstract, required: true, input_html: { rows: 5, data: { provide: 'markdown-editable' } }, + = f.input :abstract, required: true, input_html: { rows: 5, data: { provide: 'markdown' } }, hint: markdown_hint('[Tips to improve your presentations.](http://blog.hubspot.com/blog/tabid/6307/bid/5975/10-Rules-to-Instantly-Improve-Your-Presentations.aspx)') %p diff --git a/app/views/proposals/new.html.haml b/app/views/proposals/new.html.haml index 256cad22..b7fc22f5 100644 --- a/app/views/proposals/new.html.haml +++ b/app/views/proposals/new.html.haml @@ -47,7 +47,7 @@ collection: @languages, include_blank: false, label: 'Language', input_html: { class: 'select-help-toggle' } - = f.input :abstract, required: true, input_html: { rows: 5, data: { provide: 'markdown-editable' } }, + = f.input :abstract, required: true, input_html: { rows: 5, data: { provide: 'markdown' } }, hint: markdown_hint %p diff --git a/app/views/tracks/_form.html.haml b/app/views/tracks/_form.html.haml index 42832e80..1fc8bc5a 100644 --- a/app/views/tracks/_form.html.haml +++ b/app/views/tracks/_form.html.haml @@ -15,6 +15,6 @@ = f.input :color, input_html: {size: 6, type: 'color'}, required: true = f.input :start_date, as: :string, input_html: { id: 'registration-period-start-datepicker', start_date: @conference.start_date, end_date: @conference.end_date, readonly: 'readonly' } = f.input :end_date, as: :string, input_html: { id: 'registration-period-end-datepicker', readonly: 'readonly' } - = f.input :description, input_html: {rows: 2, data: { provide: 'markdown-editable' } }, required: true, hint: "This will be public #{markdown_hint}".html_safe - = f.input :relevance, input_html: {rows: 5, data: { provide: 'markdown-editable' } }, required: true, hint: "Please explain here how this track relates to the conference, how you are related to its content and why we should accept it. #{markdown_hint}".html_safe + = f.input :description, input_html: {rows: 2, data: { provide: 'markdown' } }, required: true, hint: "This will be public #{markdown_hint}".html_safe + = f.input :relevance, input_html: {rows: 5, data: { provide: 'markdown' } }, required: true, hint: "Please explain here how this track relates to the conference, how you are related to its content and why we should accept it. #{markdown_hint}".html_safe = f.action :submit, as: :button, button_html: { class: 'btn btn-primary' } diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 6f70b651..52c0d57f 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -14,7 +14,7 @@ = link_to 'Change your avatar here', 'https://gravatar.com' = f.input :affiliation, as: :string, hint: 'This could be a company, a user group, or nothing at all.' - = f.input :biography, input_html: { rows: 5, data: { provide: 'markdown-editable' } }, + = f.input :biography, input_html: { rows: 5, data: { provide: 'markdown' } }, hint: markdown_hint You have used %span#bio_length diff --git a/db/migrate/20160627122446_create_surveys.rb b/db/migrate/20160627122446_create_surveys.rb index ca7f52ea..9fdfd30d 100644 --- a/db/migrate/20160627122446_create_surveys.rb +++ b/db/migrate/20160627122446_create_surveys.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CreateSurveys < ActiveRecord::Migration +class CreateSurveys < ActiveRecord::Migration[5.0] def change create_table :surveys do |t| t.datetime :start_date diff --git a/db/migrate/20160628093634_create_survey_questions.rb b/db/migrate/20160628093634_create_survey_questions.rb index 63020a7d..b89dd3b2 100644 --- a/db/migrate/20160628093634_create_survey_questions.rb +++ b/db/migrate/20160628093634_create_survey_questions.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CreateSurveyQuestions < ActiveRecord::Migration +class CreateSurveyQuestions < ActiveRecord::Migration[5.0] def change create_table :survey_questions do |t| t.references :survey diff --git a/db/migrate/20160629145954_add_target_to_surveys.rb b/db/migrate/20160629145954_add_target_to_surveys.rb index 385ea38a..e0efc45d 100644 --- a/db/migrate/20160629145954_add_target_to_surveys.rb +++ b/db/migrate/20160629145954_add_target_to_surveys.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddTargetToSurveys < ActiveRecord::Migration +class AddTargetToSurveys < ActiveRecord::Migration[5.0] def change add_column :surveys, :target, :integer, default: 0 end diff --git a/db/migrate/20160630094850_create_survey_replies.rb b/db/migrate/20160630094850_create_survey_replies.rb index 8e8d43a2..fb8f3b83 100644 --- a/db/migrate/20160630094850_create_survey_replies.rb +++ b/db/migrate/20160630094850_create_survey_replies.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CreateSurveyReplies < ActiveRecord::Migration +class CreateSurveyReplies < ActiveRecord::Migration[5.0] def change create_table :survey_replies do |t| t.integer :survey_question_id diff --git a/db/migrate/20160630130731_create_survey_submissions.rb b/db/migrate/20160630130731_create_survey_submissions.rb index a64c4e5d..35a89fc8 100644 --- a/db/migrate/20160630130731_create_survey_submissions.rb +++ b/db/migrate/20160630130731_create_survey_submissions.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CreateSurveySubmissions < ActiveRecord::Migration +class CreateSurveySubmissions < ActiveRecord::Migration[5.0] def change create_table :survey_submissions do |t| t.integer :user_id diff --git a/db/migrate/20161229080315_add_comments_count_to_events.rb b/db/migrate/20161229080315_add_comments_count_to_events.rb index 25e9ed58..b886b079 100644 --- a/db/migrate/20161229080315_add_comments_count_to_events.rb +++ b/db/migrate/20161229080315_add_comments_count_to_events.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddCommentsCountToEvents < ActiveRecord::Migration +class AddCommentsCountToEvents < ActiveRecord::Migration[4.2] def change add_column :events, :comments_count, :integer, default: 0, null: false diff --git a/db/migrate/20170108053041_add_default_to_revision_in_conference.rb b/db/migrate/20170108053041_add_default_to_revision_in_conference.rb index 1e06838c..66517402 100644 --- a/db/migrate/20170108053041_add_default_to_revision_in_conference.rb +++ b/db/migrate/20170108053041_add_default_to_revision_in_conference.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddDefaultToRevisionInConference < ActiveRecord::Migration +class AddDefaultToRevisionInConference < ActiveRecord::Migration[4.2] def change change_column :conferences, :revision, :integer, default: 0, null: false end diff --git a/db/migrate/20170212145523_add_enabled_to_event_schedules.rb b/db/migrate/20170212145523_add_enabled_to_event_schedules.rb index 9d9cb819..e4255dfd 100644 --- a/db/migrate/20170212145523_add_enabled_to_event_schedules.rb +++ b/db/migrate/20170212145523_add_enabled_to_event_schedules.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddEnabledToEventSchedules < ActiveRecord::Migration +class AddEnabledToEventSchedules < ActiveRecord::Migration[5.0] def change add_column :event_schedules, :enabled, :boolean, default: true end diff --git a/db/migrate/20170516190048_create_booths.rb b/db/migrate/20170516190048_create_booths.rb index 4c315511..944fd30a 100644 --- a/db/migrate/20170516190048_create_booths.rb +++ b/db/migrate/20170516190048_create_booths.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CreateBooths < ActiveRecord::Migration +class CreateBooths < ActiveRecord::Migration[4.2] def change create_table :booths do |t| t.string :title diff --git a/db/migrate/20170530072155_add_type_to_cfps.rb b/db/migrate/20170530072155_add_type_to_cfps.rb index 603a6de0..9cfae8bf 100644 --- a/db/migrate/20170530072155_add_type_to_cfps.rb +++ b/db/migrate/20170530072155_add_type_to_cfps.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddTypeToCfps < ActiveRecord::Migration +class AddTypeToCfps < ActiveRecord::Migration[4.2] class TmpCfp < ActiveRecord::Base self.table_name = 'cfps' end diff --git a/db/migrate/20170530112510_create_booth_requests.rb b/db/migrate/20170530112510_create_booth_requests.rb index a6358a68..a244c309 100644 --- a/db/migrate/20170530112510_create_booth_requests.rb +++ b/db/migrate/20170530112510_create_booth_requests.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CreateBoothRequests < ActiveRecord::Migration +class CreateBoothRequests < ActiveRecord::Migration[4.2] def change create_table :booth_requests do |t| t.references :booth, index: true, foreign_key: true diff --git a/db/migrate/20170603095900_create_physical_tickets.rb b/db/migrate/20170603095900_create_physical_tickets.rb index ef8abb65..20d3c838 100644 --- a/db/migrate/20170603095900_create_physical_tickets.rb +++ b/db/migrate/20170603095900_create_physical_tickets.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CreatePhysicalTickets < ActiveRecord::Migration +class CreatePhysicalTickets < ActiveRecord::Migration[4.2] def change create_table :physical_tickets do |t| t.integer :ticket_purchase_id, null: false diff --git a/db/migrate/20170629162450_add_short_name_to_tracks.rb b/db/migrate/20170629162450_add_short_name_to_tracks.rb index a334885f..9cb2054b 100644 --- a/db/migrate/20170629162450_add_short_name_to_tracks.rb +++ b/db/migrate/20170629162450_add_short_name_to_tracks.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddShortNameToTracks < ActiveRecord::Migration +class AddShortNameToTracks < ActiveRecord::Migration[4.2] class TmpProgram < ActiveRecord::Base self.table_name = 'programs' end diff --git a/db/migrate/20170629232817_add_ticket_layout_to_conferences.rb b/db/migrate/20170629232817_add_ticket_layout_to_conferences.rb index faf67332..36a1028c 100644 --- a/db/migrate/20170629232817_add_ticket_layout_to_conferences.rb +++ b/db/migrate/20170629232817_add_ticket_layout_to_conferences.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddTicketLayoutToConferences < ActiveRecord::Migration +class AddTicketLayoutToConferences < ActiveRecord::Migration[4.2] def change add_column :conferences, :ticket_layout, :integer, default: 0 end diff --git a/db/migrate/20170705075039_add_state_cfp_active_and_submitter_reference_to_tracks.rb b/db/migrate/20170705075039_add_state_cfp_active_and_submitter_reference_to_tracks.rb index b42cf9c2..4094812b 100644 --- a/db/migrate/20170705075039_add_state_cfp_active_and_submitter_reference_to_tracks.rb +++ b/db/migrate/20170705075039_add_state_cfp_active_and_submitter_reference_to_tracks.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddStateCfpActiveAndSubmitterReferenceToTracks < ActiveRecord::Migration +class AddStateCfpActiveAndSubmitterReferenceToTracks < ActiveRecord::Migration[4.2] def change add_column :tracks, :state, :string add_column :tracks, :cfp_active, :boolean diff --git a/db/migrate/20170711102511_create_ticket_scannings.rb b/db/migrate/20170711102511_create_ticket_scannings.rb index 12c20eb1..bbf35e3c 100644 --- a/db/migrate/20170711102511_create_ticket_scannings.rb +++ b/db/migrate/20170711102511_create_ticket_scannings.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CreateTicketScannings < ActiveRecord::Migration +class CreateTicketScannings < ActiveRecord::Migration[4.2] def change create_table :ticket_scannings do |t| t.integer :physical_ticket_id, null: false diff --git a/db/migrate/20170712120556_add_room_and_dates_to_tracks.rb b/db/migrate/20170712120556_add_room_and_dates_to_tracks.rb index 6c2d92b9..6cd0228c 100644 --- a/db/migrate/20170712120556_add_room_and_dates_to_tracks.rb +++ b/db/migrate/20170712120556_add_room_and_dates_to_tracks.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddRoomAndDatesToTracks < ActiveRecord::Migration +class AddRoomAndDatesToTracks < ActiveRecord::Migration[4.2] def change add_reference :tracks, :room, index: true, foreign_key: true add_column :tracks, :start_date, :date diff --git a/db/migrate/20170715131706_make_track_state_not_null_and_add_default_value.rb b/db/migrate/20170715131706_make_track_state_not_null_and_add_default_value.rb index 2d8d9b2d..87cb13fe 100644 --- a/db/migrate/20170715131706_make_track_state_not_null_and_add_default_value.rb +++ b/db/migrate/20170715131706_make_track_state_not_null_and_add_default_value.rb @@ -1,11 +1,13 @@ # frozen_string_literal: true -class MakeTrackStateNotNullAndAddDefaultValue < ActiveRecord::Migration +class MakeTrackStateNotNullAndAddDefaultValue < ActiveRecord::Migration[4.2] class TmpTrack < ActiveRecord::Base self.table_name = 'tracks' end def change + TmpTrack.reset_column_information + TmpTrack.where(state: nil).each do |track| track.state = 'confirmed' track.save! diff --git a/db/migrate/20170720134353_make_track_cfp_active_not_null.rb b/db/migrate/20170720134353_make_track_cfp_active_not_null.rb index b96d84fe..3e921419 100644 --- a/db/migrate/20170720134353_make_track_cfp_active_not_null.rb +++ b/db/migrate/20170720134353_make_track_cfp_active_not_null.rb @@ -1,16 +1,18 @@ # frozen_string_literal: true -class MakeTrackCfpActiveNotNull < ActiveRecord::Migration +class MakeTrackCfpActiveNotNull < ActiveRecord::Migration[4.2] class TmpTrack < ActiveRecord::Base self.table_name = 'tracks' end def change + TmpTrack.reset_column_information + TmpTrack.where(cfp_active: nil).each do |track| track.cfp_active = true track.save! end - change_column_null :tracks, :cfp_active, false + change_column :tracks, :cfp_active, :boolean, null: false, default: false end end diff --git a/db/migrate/20170721001700_add_index_to_physical_tickets.rb b/db/migrate/20170721001700_add_index_to_physical_tickets.rb index 042430fe..08a436e6 100644 --- a/db/migrate/20170721001700_add_index_to_physical_tickets.rb +++ b/db/migrate/20170721001700_add_index_to_physical_tickets.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddIndexToPhysicalTickets < ActiveRecord::Migration +class AddIndexToPhysicalTickets < ActiveRecord::Migration[4.2] def change add_column :physical_tickets, :token, :string add_index :physical_tickets, :token, unique: true diff --git a/db/migrate/20170721184810_add_custom_domain_to_conferences.rb b/db/migrate/20170721184810_add_custom_domain_to_conferences.rb index a3e2897b..664bfbbe 100644 --- a/db/migrate/20170721184810_add_custom_domain_to_conferences.rb +++ b/db/migrate/20170721184810_add_custom_domain_to_conferences.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddCustomDomainToConferences < ActiveRecord::Migration +class AddCustomDomainToConferences < ActiveRecord::Migration[4.2] def change add_column :conferences, :custom_domain, :string end diff --git a/db/migrate/20170726065629_add_relevance_to_tracks.rb b/db/migrate/20170726065629_add_relevance_to_tracks.rb index 7db35227..21f2d17c 100644 --- a/db/migrate/20170726065629_add_relevance_to_tracks.rb +++ b/db/migrate/20170726065629_add_relevance_to_tracks.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddRelevanceToTracks < ActiveRecord::Migration +class AddRelevanceToTracks < ActiveRecord::Migration[4.2] def change add_column :tracks, :relevance, :text end diff --git a/db/migrate/20170727081731_add_include_booths_to_splashpages.rb b/db/migrate/20170727081731_add_include_booths_to_splashpages.rb index ea5882c1..350e1851 100644 --- a/db/migrate/20170727081731_add_include_booths_to_splashpages.rb +++ b/db/migrate/20170727081731_add_include_booths_to_splashpages.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddIncludeBoothsToSplashpages < ActiveRecord::Migration +class AddIncludeBoothsToSplashpages < ActiveRecord::Migration[4.2] def change add_column :splashpages, :include_booths, :boolean end diff --git a/db/migrate/20170728182033_add_booth_limit_to_conferences.rb b/db/migrate/20170728182033_add_booth_limit_to_conferences.rb index ae0f1410..1176375e 100644 --- a/db/migrate/20170728182033_add_booth_limit_to_conferences.rb +++ b/db/migrate/20170728182033_add_booth_limit_to_conferences.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddBoothLimitToConferences < ActiveRecord::Migration +class AddBoothLimitToConferences < ActiveRecord::Migration[4.2] def change add_column :conferences, :booth_limit, :integer, default: 0 end diff --git a/db/migrate/20170731161207_add_booths_to_email_settings.rb b/db/migrate/20170731161207_add_booths_to_email_settings.rb index 5df76759..422006ca 100644 --- a/db/migrate/20170731161207_add_booths_to_email_settings.rb +++ b/db/migrate/20170731161207_add_booths_to_email_settings.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddBoothsToEmailSettings < ActiveRecord::Migration +class AddBoothsToEmailSettings < ActiveRecord::Migration[4.2] def change add_column :email_settings, :send_on_booths_acceptance, :boolean, default: false add_column :email_settings, :booths_acceptance_subject, :string diff --git a/db/migrate/20170807092805_add_registration_ticket_to_tickets.rb b/db/migrate/20170807092805_add_registration_ticket_to_tickets.rb index c2e4fd8e..d3ce8184 100644 --- a/db/migrate/20170807092805_add_registration_ticket_to_tickets.rb +++ b/db/migrate/20170807092805_add_registration_ticket_to_tickets.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddRegistrationTicketToTickets < ActiveRecord::Migration +class AddRegistrationTicketToTickets < ActiveRecord::Migration[4.2] def change add_column :tickets, :registration_ticket, :boolean, default: false end diff --git a/db/migrate/20170809120927_add_track_reference_to_schedule.rb b/db/migrate/20170809120927_add_track_reference_to_schedule.rb index b98fca24..9a6a0ecc 100644 --- a/db/migrate/20170809120927_add_track_reference_to_schedule.rb +++ b/db/migrate/20170809120927_add_track_reference_to_schedule.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddTrackReferenceToSchedule < ActiveRecord::Migration +class AddTrackReferenceToSchedule < ActiveRecord::Migration[4.2] def change add_reference :schedules, :track, index: true, foreign_key: true end diff --git a/db/migrate/20170814174637_add_selected_schedule_to_tracks.rb b/db/migrate/20170814174637_add_selected_schedule_to_tracks.rb index bedc96c3..55ad57b3 100644 --- a/db/migrate/20170814174637_add_selected_schedule_to_tracks.rb +++ b/db/migrate/20170814174637_add_selected_schedule_to_tracks.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddSelectedScheduleToTracks < ActiveRecord::Migration +class AddSelectedScheduleToTracks < ActiveRecord::Migration[4.2] def change add_column :tracks, :selected_schedule_id, :integer add_index :tracks, :selected_schedule_id diff --git a/db/migrate/20170905110034_add_description_to_cfps.rb b/db/migrate/20170905110034_add_description_to_cfps.rb index 968a907c..a058a1e1 100644 --- a/db/migrate/20170905110034_add_description_to_cfps.rb +++ b/db/migrate/20170905110034_add_description_to_cfps.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddDescriptionToCfps < ActiveRecord::Migration +class AddDescriptionToCfps < ActiveRecord::Migration[4.2] def change add_column :cfps, :description, :text end diff --git a/db/migrate/20170924190528_add_amount_paid_to_ticket_purchases.rb b/db/migrate/20170924190528_add_amount_paid_to_ticket_purchases.rb index f3357ee3..7ada30a4 100644 --- a/db/migrate/20170924190528_add_amount_paid_to_ticket_purchases.rb +++ b/db/migrate/20170924190528_add_amount_paid_to_ticket_purchases.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddAmountPaidToTicketPurchases < ActiveRecord::Migration +class AddAmountPaidToTicketPurchases < ActiveRecord::Migration[4.2] def change add_column :ticket_purchases, :amount_paid, :float, default: 0 end diff --git a/db/migrate/20171130172334_rebuild_conference_pictures.rb b/db/migrate/20171130172334_rebuild_conference_pictures.rb index c19ae041..d8477144 100644 --- a/db/migrate/20171130172334_rebuild_conference_pictures.rb +++ b/db/migrate/20171130172334_rebuild_conference_pictures.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -class RebuildConferencePictures < ActiveRecord::Migration +class RebuildConferencePictures < ActiveRecord::Migration[5.0] def up - Conference.all.each do |conference| + Conference.where.not(picture: nil).each do |conference| conference.picture.recreate_versions! end end diff --git a/db/migrate/20171201163628_add_mastodon_to_contact.rb b/db/migrate/20171201163628_add_mastodon_to_contact.rb index a3cc50b6..4ed4d8ff 100644 --- a/db/migrate/20171201163628_add_mastodon_to_contact.rb +++ b/db/migrate/20171201163628_add_mastodon_to_contact.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddMastodonToContact < ActiveRecord::Migration +class AddMastodonToContact < ActiveRecord::Migration[5.0] def change add_column :contacts, :mastodon, :string end diff --git a/db/migrate/20200331214534_add_organization_to_versions.rb b/db/migrate/20200331214534_add_organization_to_versions.rb new file mode 100644 index 00000000..dc3e06f7 --- /dev/null +++ b/db/migrate/20200331214534_add_organization_to_versions.rb @@ -0,0 +1,35 @@ +class AddOrganizationToVersions < ActiveRecord::Migration[5.2] + def up + add_reference :versions, :organization + deconflate + end + + def down + conflate + remove_reference :versions, :organization + end + + private + + def conflate + say 'conflate' + + PaperTrail::Version.where.not(organization_id: nil).each do |version| + version.update_attributes conference_id: version.organization_id + end + end + + def deconflate + say 'deconflate' + + PaperTrail::Version.where.not(conference_id: nil).where(item_type: %[Role UsersRole]).each do |version| + id = version.conference_id + + if Organization.exists?(id) + raise "version #{version.id} conflates organization #{id} with conference #{id}" if Conference.exists?(id) + + version.update_attributes conference_id: nil, organization_id: id + end + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 4c2bc28e..c16b9f8f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,10 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2018_12_29_233811) do - - # These are extensions that must be enabled in order to support this database - enable_extension "plpgsql" +ActiveRecord::Schema.define(version: 2020_03_31_214534) do create_table "answers", force: :cascade do |t| t.string "title" @@ -641,7 +638,9 @@ ActiveRecord::Schema.define(version: 2018_12_29_233811) do t.text "object_changes" t.datetime "created_at" t.integer "conference_id" + t.integer "organization_id" t.index ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id" + t.index ["organization_id"], name: "index_versions_on_organization_id" end create_table "votes", force: :cascade do |t| diff --git a/docker-compose.override.yml.example b/docker-compose.override.yml.example index f5dca21d..2d816375 100644 --- a/docker-compose.override.yml.example +++ b/docker-compose.override.yml.example @@ -1,4 +1,5 @@ -version: '2' +version: "2.4" + services: osem: build: diff --git a/docker-compose.yml b/docker-compose.yml index 8f31749c..ca3e36f7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,11 @@ -version: "2" +version: "2.4" services: database: image: postgres environment: PGDATA: /var/lib/postgresql/data/pgdata + POSTGRES_PASSWORD: $OSEM_DB_PASSWORD osem: build: context: . diff --git a/docker-compose.yml.production-example b/docker-compose.yml.production-example index 73fa1ad1..ed4892a2 100644 --- a/docker-compose.yml.production-example +++ b/docker-compose.yml.production-example @@ -1,10 +1,11 @@ -version: "2" +version: "2.4" services: production_database: image: postgres environment: PGDATA: /var/lib/postgresql/data/pgdata + POSTGRES_PASSWORD: $OSEM_DB_PASSWORD volumes: - osem_production_database:/var/lib/postgresql/data/pgdata production_web: @@ -18,6 +19,7 @@ services: env_file: .env.production # see dotenv.example file environment: OSEM_DB_HOST: production_database + RAILS_SERVE_STATIC_FILES: 'true' command: /osem/bin/osem-init.sh volumes: - osem_production_web_data:/osem/public/system diff --git a/dotenv.example b/dotenv.example index ca6bbfa8..89cd16e9 100644 --- a/dotenv.example +++ b/dotenv.example @@ -32,9 +32,6 @@ # OSEM_MEMCACHED_USERNAME='root' # OSEM_MEMCACHED_PASSWORD='1234' -# The ruby version to use -# OSEM_RUBY_VERSION=2.5.0 - # What time is it? # OSEM_TIME_ZONE="UTC" diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 24affba4..38fd26d6 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -59,6 +59,17 @@ FactoryBot.define do biography { '
' } end + factory :organization_admin, parent: :user do + transient do + organization { create(:organization) } + end + + after(:create) do |user, evaluator| + user.roles << Role.find_or_create_by(name: 'organization_admin', resource: evaluator.organization) + user.save! + end + end + factory :organizer, parent: :user do transient do resource { create(:resource) } diff --git a/spec/features/commercials_spec.rb b/spec/features/commercials_spec.rb index 5ddb08b2..814c49d0 100644 --- a/spec/features/commercials_spec.rb +++ b/spec/features/commercials_spec.rb @@ -75,7 +75,7 @@ feature Commercial do expect(page).to have_css("button[type='submit']:disabled", text: 'Save Materials') end - scenario 'updates a commercial of an event', feature: true, js: true do + scenario 'updates materials of an event', feature: true, js: true do commercial = create(:commercial, commercialable_id: event.id, commercialable_type: 'Event') @@ -85,7 +85,6 @@ feature Commercial do click_button 'Update' page.find('#flash') expect(flash).to eq('Materials were successfully updated.') - TransactionalCapybara::AjaxHelpers.wait_for_ajax(page) expect(event.commercials.count).to eq(1) commercial.reload expect(commercial.url).to eq('https://www.youtube.com/watch?v=M9bq_alk-sw') @@ -117,8 +116,7 @@ feature Commercial do click_link 'Delete' end page.find('#flash') - expect(flash).to eq('Materials were successfully destroyed.') - TransactionalCapybara::AjaxHelpers.wait_for_ajax(page) + expect(flash).to eq('Materials successfully destroyed.') expect(event.commercials.count).to eq(0) end end diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index 9bd0e1c3..53e949c9 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -114,9 +114,12 @@ feature Event do visit conference_program_proposals_path(conference.short_title) click_link 'New Proposal' + expect(page).to have_selector(".in[id='#{find_field('event[event_type_id]').value}-help']") # End of animation fill_in 'event_title', with: 'Example Proposal' select('Example Event Type', from: 'event[event_type_id]') + expect(page).to have_selector(".in[id='#{find_field('event[event_type_id]').value}-help']") # End of animation + fill_in 'event_abstract', with: 'Lorem ipsum abstract' expect(page).to have_text('You have used 3 words') @@ -127,7 +130,6 @@ feature Event do page.find('#flash') expect(page).to have_content 'Proposal was successfully submitted.' - TransactionalCapybara::AjaxHelpers.wait_for_ajax(page) expect(current_path).to eq(conference_program_proposals_path(conference.short_title)) expect(Event.count).to eq(expected_count) end diff --git a/spec/features/versions_spec.rb b/spec/features/versions_spec.rb index cf0c49ed..2988cc1c 100644 --- a/spec/features/versions_spec.rb +++ b/spec/features/versions_spec.rb @@ -318,17 +318,14 @@ feature 'Version' do end context 'organization role', feature: true, versioning: true, js: true do + let!(:organization_admin) { create(:organization_admin, organization: conference.organization) } 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 + + sign_in organization_admin visit admin_revision_history_path end @@ -392,7 +389,7 @@ feature 'Version' do click_link 'Comments (0)' fill_in 'comment_body', with: 'Sample comment' click_button 'Add Comment' - TransactionalCapybara::AjaxHelpers.wait_for_ajax(page) + expect(page).to have_text('Comments (1)') Comment.last.destroy PaperTrail::Version.last.reify.save diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index fe6bab9b..b809992f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -20,9 +20,6 @@ require 'webdrivers' # all migrations applied ActiveRecord::Migration.maintain_test_schema! -# Keep capybara and the database on the same page -require 'transactional_capybara/rspec' - # Adds rspec helper provided by paper_trail # makes it easier to control when PaperTrail is enabled during testing. require 'paper_trail/frameworks/rspec' @@ -49,10 +46,8 @@ RSpec.configure do |config| # config.mock_with :flexmock # config.mock_with :rr - # If you're not using ActiveRecord, or you'd prefer not to run each of your - # examples within a transaction, remove the following line or assign false - # instead of true. - config.use_transactional_fixtures = false + # Test within database transactions + config.use_transactional_examples = true # Run specs in random order to surface order dependencies. If you find an # order dependency and want to debug it, you can fix the order by providing @@ -78,12 +73,10 @@ RSpec.configure do |config| end Capybara.register_driver :chrome_headless do |app| - capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( - chromeOptions: { args: %w(headless disable-gpu window-size=1920x1080 no-sandbox) } - ) - Capybara::Selenium::Driver.new( - app, browser: :chrome, desired_capabilities: capabilities + options = Selenium::WebDriver::Chrome::Options.new( + args: %w(headless disable-gpu window-size=1920x1080 no-sandbox) ) + Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) end Capybara.default_max_wait_time = 10 # seconds diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb index c9d3073b..722e270d 100644 --- a/spec/support/database_cleaner.rb +++ b/spec/support/database_cleaner.rb @@ -2,16 +2,7 @@ RSpec.configure do |config| config.before(:suite) do - DatabaseCleaner.clean_with(:transaction) + DatabaseCleaner.clean_with(:truncation) Rails.application.load_seed end - - config.before(:each) do - DatabaseCleaner.start - end - - config.after(:each) do |example| - TransactionalCapybara::AjaxHelpers.wait_for_ajax(page) if example.metadata[:js] - DatabaseCleaner.clean - end end diff --git a/spec/support/external_request.rb b/spec/support/external_request.rb index fb69975f..a3ebf939 100644 --- a/spec/support/external_request.rb +++ b/spec/support/external_request.rb @@ -2,7 +2,10 @@ # Mock external requests to youtube require 'webmock/rspec' -WebMock.disable_net_connect!(allow_localhost: true, allow: /stripe.com/) +driver_urls = Webdrivers::Common.subclasses.map do |driver| + Addressable::URI.parse(driver.base_url).host +end +WebMock.disable_net_connect!(allow_localhost: true, allow: [*driver_urls, /stripe.com/]) RSpec.configure do |config| config.before(:each) do diff --git a/spec/support/kneet_connections.rb b/spec/support/kneet_connections.rb deleted file mode 100644 index 87f0bcd5..00000000 --- a/spec/support/kneet_connections.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -module ActiveRecord - class Base - mattr_accessor :shared_connection - @@shared_connection = nil - - def self.connection - @@shared_connection || retrieve_connection - end - end -end - -ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection diff --git a/spec/support/save_feature_failures.rb b/spec/support/save_feature_failures.rb index 8b1fb104..3f7129c4 100644 --- a/spec/support/save_feature_failures.rb +++ b/spec/support/save_feature_failures.rb @@ -9,7 +9,7 @@ RSpec.configure do |config| example_filename += '.html' if RSpec.current_example.exception.present? save_page(example_filename) - save_page(example_screenshotname) + save_screenshot(example_screenshotname) # rubocop:disable Lint/Debugger # remove the file if the test starts working again else File.unlink(example_filename) if File.exist?(example_filename)