Merge pull request #3621 from consul/upgrade_to_rails_5.1
Upgrade to Rails 5.1
This commit is contained in:
12
.rubocop.yml
12
.rubocop.yml
@@ -198,15 +198,6 @@ Performance/EndWith:
|
||||
Performance/StartWith:
|
||||
Enabled: true
|
||||
|
||||
Rails/ActionFilter:
|
||||
Enabled: true
|
||||
|
||||
Rails/ApplicationJob:
|
||||
Enabled: true
|
||||
|
||||
Rails/ApplicationRecord:
|
||||
Enabled: true
|
||||
|
||||
Rails/CreateTableWithTimestamps:
|
||||
Enabled: true
|
||||
Exclude:
|
||||
@@ -241,9 +232,6 @@ Rails/HasManyOrHasOneDependent:
|
||||
Enabled: true
|
||||
Severity: refactor
|
||||
|
||||
Rails/HttpPositionalArguments:
|
||||
Enabled: true
|
||||
|
||||
Rails/InverseOf:
|
||||
Enabled: true
|
||||
Exclude:
|
||||
|
||||
10
Gemfile
10
Gemfile
@@ -1,8 +1,8 @@
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem "rails", "5.0.7.2"
|
||||
gem "rails", "5.1.7"
|
||||
|
||||
gem "acts-as-taggable-on", "~> 5.0.0"
|
||||
gem "acts-as-taggable-on", "~> 6.0.0"
|
||||
gem "acts_as_votable", "~> 0.11.1"
|
||||
gem "ahoy_matey", "~> 1.6.0"
|
||||
gem "ancestry", "~> 3.0.7"
|
||||
@@ -66,8 +66,8 @@ source "https://rails-assets.org" do
|
||||
end
|
||||
|
||||
group :development, :test do
|
||||
gem "bullet", "~> 5.7.0"
|
||||
gem "byebug", "~> 10.0.0"
|
||||
gem "bullet", "~> 5.9.0"
|
||||
gem "byebug", "~> 11.1.1"
|
||||
gem "factory_bot_rails", "~> 4.8.2"
|
||||
gem "faker", "~> 1.8.7"
|
||||
gem "i18n-tasks", "~> 0.9.29"
|
||||
@@ -82,7 +82,6 @@ group :test do
|
||||
gem "capybara", "~> 3.29.0"
|
||||
gem "capybara-webmock", "~> 0.5.3"
|
||||
gem "coveralls", "~> 0.8.22", require: false
|
||||
gem "database_cleaner", "~> 1.7.0"
|
||||
gem "email_spec", "~> 2.2.0"
|
||||
gem "rspec-rails", "~> 3.8"
|
||||
gem "selenium-webdriver", "~> 3.141"
|
||||
@@ -94,6 +93,7 @@ group :development do
|
||||
gem "capistrano-rails", "~> 1.4.0", require: false
|
||||
gem "capistrano3-delayed-job", "~> 1.7.3"
|
||||
gem "capistrano3-puma", "~> 4.0.0"
|
||||
gem "database_cleaner", "~> 1.7.0"
|
||||
gem "erb_lint", require: false
|
||||
gem "github_changelog_generator", "~> 1.15.0"
|
||||
gem "mdl", "~> 0.5.0", require: false
|
||||
|
||||
109
Gemfile.lock
109
Gemfile.lock
@@ -10,45 +10,45 @@ GEM
|
||||
remote: https://rubygems.org/
|
||||
remote: https://rails-assets.org/
|
||||
specs:
|
||||
actioncable (5.0.7.2)
|
||||
actionpack (= 5.0.7.2)
|
||||
nio4r (>= 1.2, < 3.0)
|
||||
actioncable (5.1.7)
|
||||
actionpack (= 5.1.7)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (~> 0.6.1)
|
||||
actionmailer (5.0.7.2)
|
||||
actionpack (= 5.0.7.2)
|
||||
actionview (= 5.0.7.2)
|
||||
activejob (= 5.0.7.2)
|
||||
actionmailer (5.1.7)
|
||||
actionpack (= 5.1.7)
|
||||
actionview (= 5.1.7)
|
||||
activejob (= 5.1.7)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.0.7.2)
|
||||
actionview (= 5.0.7.2)
|
||||
activesupport (= 5.0.7.2)
|
||||
actionpack (5.1.7)
|
||||
actionview (= 5.1.7)
|
||||
activesupport (= 5.1.7)
|
||||
rack (~> 2.0)
|
||||
rack-test (~> 0.6.3)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.0.7.2)
|
||||
activesupport (= 5.0.7.2)
|
||||
actionview (5.1.7)
|
||||
activesupport (= 5.1.7)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
activejob (5.0.7.2)
|
||||
activesupport (= 5.0.7.2)
|
||||
activejob (5.1.7)
|
||||
activesupport (= 5.1.7)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.0.7.2)
|
||||
activesupport (= 5.0.7.2)
|
||||
activerecord (5.0.7.2)
|
||||
activemodel (= 5.0.7.2)
|
||||
activesupport (= 5.0.7.2)
|
||||
arel (~> 7.0)
|
||||
activesupport (5.0.7.2)
|
||||
activemodel (5.1.7)
|
||||
activesupport (= 5.1.7)
|
||||
activerecord (5.1.7)
|
||||
activemodel (= 5.1.7)
|
||||
activesupport (= 5.1.7)
|
||||
arel (~> 8.0)
|
||||
activesupport (5.1.7)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
acts-as-taggable-on (5.0.0)
|
||||
activerecord (>= 4.2.8)
|
||||
acts-as-taggable-on (6.0.0)
|
||||
activerecord (~> 5.0)
|
||||
acts_as_votable (0.11.1)
|
||||
addressable (2.7.0)
|
||||
public_suffix (>= 2.0.2, < 5.0)
|
||||
@@ -70,7 +70,7 @@ GEM
|
||||
nokogiri
|
||||
ancestry (3.0.7)
|
||||
activerecord (>= 3.2.0)
|
||||
arel (7.1.4)
|
||||
arel (8.0.0)
|
||||
ast (2.4.0)
|
||||
audited (4.9.0)
|
||||
activerecord (>= 4.2, < 6.1)
|
||||
@@ -91,10 +91,10 @@ GEM
|
||||
smart_properties
|
||||
browser (2.5.3)
|
||||
builder (3.2.4)
|
||||
bullet (5.7.1)
|
||||
bullet (5.9.0)
|
||||
activesupport (>= 3.0.0)
|
||||
uniform_notifier (~> 1.11.0)
|
||||
byebug (10.0.0)
|
||||
uniform_notifier (~> 1.11)
|
||||
byebug (11.1.1)
|
||||
cancancan (2.3.0)
|
||||
capistrano (3.10.1)
|
||||
airbrussh (>= 1.0.0)
|
||||
@@ -144,7 +144,7 @@ GEM
|
||||
coffee-script-source
|
||||
execjs
|
||||
coffee-script-source (1.12.2)
|
||||
concurrent-ruby (1.1.5)
|
||||
concurrent-ruby (1.1.6)
|
||||
coveralls (0.8.22)
|
||||
json (>= 1.8, < 3)
|
||||
simplecov (~> 0.16.1)
|
||||
@@ -210,7 +210,6 @@ GEM
|
||||
smart_properties
|
||||
errbase (0.0.3)
|
||||
erubi (1.8.0)
|
||||
erubis (2.7.0)
|
||||
execjs (2.7.0)
|
||||
factory_bot (4.8.2)
|
||||
activesupport (>= 3.0.0)
|
||||
@@ -332,7 +331,7 @@ GEM
|
||||
kramdown (~> 1.12, >= 1.12.0)
|
||||
mixlib-cli (~> 1.7, >= 1.7.0)
|
||||
mixlib-config (~> 2.2, >= 2.2.1)
|
||||
method_source (0.9.2)
|
||||
method_source (1.0.0)
|
||||
mime-types (3.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2016.0521)
|
||||
@@ -351,7 +350,7 @@ GEM
|
||||
net-ssh (5.0.2)
|
||||
newrelic_rpm (4.1.0.333)
|
||||
nio4r (2.5.2)
|
||||
nokogiri (1.10.8)
|
||||
nokogiri (1.10.9)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
nori (2.6.0)
|
||||
oauth (0.5.4)
|
||||
@@ -405,26 +404,26 @@ GEM
|
||||
public_suffix (4.0.1)
|
||||
puma (4.3.3)
|
||||
nio4r (~> 2.0)
|
||||
rack (2.1.1)
|
||||
rack (2.2.2)
|
||||
rack-accept (0.4.5)
|
||||
rack (>= 0.4)
|
||||
rack-attack (5.0.1)
|
||||
rack
|
||||
rack-proxy (0.6.5)
|
||||
rack
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rails (5.0.7.2)
|
||||
actioncable (= 5.0.7.2)
|
||||
actionmailer (= 5.0.7.2)
|
||||
actionpack (= 5.0.7.2)
|
||||
actionview (= 5.0.7.2)
|
||||
activejob (= 5.0.7.2)
|
||||
activemodel (= 5.0.7.2)
|
||||
activerecord (= 5.0.7.2)
|
||||
activesupport (= 5.0.7.2)
|
||||
rack-test (1.1.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails (5.1.7)
|
||||
actioncable (= 5.1.7)
|
||||
actionmailer (= 5.1.7)
|
||||
actionpack (= 5.1.7)
|
||||
actionview (= 5.1.7)
|
||||
activejob (= 5.1.7)
|
||||
activemodel (= 5.1.7)
|
||||
activerecord (= 5.1.7)
|
||||
activesupport (= 5.1.7)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 5.0.7.2)
|
||||
railties (= 5.1.7)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-assets-leaflet (1.2.0)
|
||||
rails-assets-markdown-it (8.2.2)
|
||||
@@ -436,9 +435,9 @@ GEM
|
||||
rails-i18n (5.1.3)
|
||||
i18n (>= 0.7, < 2)
|
||||
railties (>= 5.0, < 6)
|
||||
railties (5.0.7.2)
|
||||
actionpack (= 5.0.7.2)
|
||||
activesupport (= 5.0.7.2)
|
||||
railties (5.1.7)
|
||||
actionpack (= 5.1.7)
|
||||
activesupport (= 5.1.7)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
@@ -577,7 +576,7 @@ GEM
|
||||
uglifier (4.1.19)
|
||||
execjs (>= 0.3.0, < 3)
|
||||
unicode-display_width (1.6.0)
|
||||
uniform_notifier (1.11.0)
|
||||
uniform_notifier (1.13.0)
|
||||
user_agent_parser (2.6.0)
|
||||
uuidtools (2.1.5)
|
||||
warden (1.2.8)
|
||||
@@ -591,7 +590,7 @@ GEM
|
||||
railties (>= 4.2)
|
||||
websocket-driver (0.6.5)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.3)
|
||||
websocket-extensions (0.1.4)
|
||||
whenever (0.10.0)
|
||||
chronic (>= 0.6.3)
|
||||
wicked_pdf (1.1.0)
|
||||
@@ -603,14 +602,14 @@ PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
acts-as-taggable-on (~> 5.0.0)
|
||||
acts-as-taggable-on (~> 6.0.0)
|
||||
acts_as_votable (~> 0.11.1)
|
||||
ahoy_matey (~> 1.6.0)
|
||||
ancestry (~> 3.0.7)
|
||||
audited (~> 4.9.0)
|
||||
autoprefixer-rails (~> 8.2.0)
|
||||
bullet (~> 5.7.0)
|
||||
byebug (~> 10.0.0)
|
||||
bullet (~> 5.9.0)
|
||||
byebug (~> 11.1.1)
|
||||
cancancan (~> 2.3.0)
|
||||
capistrano (~> 3.10.1)
|
||||
capistrano-bundler (~> 1.2)
|
||||
@@ -664,7 +663,7 @@ DEPENDENCIES
|
||||
pg (~> 0.21.0)
|
||||
pg_search (~> 2.0.1)
|
||||
puma (~> 4.3.3)
|
||||
rails (= 5.0.7.2)
|
||||
rails (= 5.1.7)
|
||||
rails-assets-leaflet!
|
||||
rails-assets-markdown-it (~> 8.2.1)!
|
||||
recipient_interceptor (~> 0.2.0)
|
||||
|
||||
@@ -44,7 +44,7 @@ class Admin::Poll::Questions::AnswersController < Admin::Poll::BaseController
|
||||
|
||||
def order_answers
|
||||
::Poll::Question::Answer.order_answers(params[:ordered_list])
|
||||
render nothing: true
|
||||
head :ok
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -319,7 +319,7 @@ class Budget
|
||||
end
|
||||
|
||||
def recalculate_heading_winners
|
||||
Budget::Result.new(budget, heading).calculate_winners if incompatible_changed?
|
||||
Budget::Result.new(budget, heading).calculate_winners if saved_change_to_incompatible?
|
||||
end
|
||||
|
||||
def set_responsible_name
|
||||
@@ -396,7 +396,7 @@ class Budget
|
||||
private
|
||||
|
||||
def set_denormalized_ids
|
||||
self.group_id = heading&.group_id if heading_id_changed?
|
||||
self.group_id = heading&.group_id if will_save_change_to_heading_id?
|
||||
self.budget_id ||= heading&.group&.budget_id
|
||||
end
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class Budget
|
||||
if enabled?
|
||||
next_enabled_phase&.update_column(:starts_at, ends_at)
|
||||
prev_enabled_phase&.update_column(:ends_at, starts_at)
|
||||
elsif enabled_changed?
|
||||
elsif saved_change_to_enabled?
|
||||
next_enabled_phase&.update_column(:starts_at, starts_at)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@ class Budget
|
||||
end
|
||||
|
||||
def check_for_reclassification
|
||||
if heading_changed?
|
||||
if saved_change_to_heading?
|
||||
log_heading_change
|
||||
store_reclassified_votes("heading_changed")
|
||||
remove_reclassified_votes
|
||||
@@ -17,16 +17,16 @@ class Budget
|
||||
end
|
||||
end
|
||||
|
||||
def heading_changed?
|
||||
budget.balloting? && heading_id_changed?
|
||||
def saved_change_to_heading?
|
||||
budget.balloting? && saved_change_to_heading_id?
|
||||
end
|
||||
|
||||
def marked_as_unfeasible?
|
||||
budget.balloting? && feasibility_changed? && unfeasible?
|
||||
budget.balloting? && saved_change_to_feasibility? && unfeasible?
|
||||
end
|
||||
|
||||
def log_heading_change
|
||||
update_column(:previous_heading_id, heading_id_was)
|
||||
update_column(:previous_heading_id, heading_id_before_last_save)
|
||||
end
|
||||
|
||||
def store_reclassified_votes(reason)
|
||||
|
||||
@@ -19,10 +19,10 @@ class Poll::PartialResult < ApplicationRecord
|
||||
before_save :update_logs
|
||||
|
||||
def update_logs
|
||||
if amount_changed? && amount_was.present?
|
||||
self.amount_log += ":#{amount_was}"
|
||||
self.officer_assignment_id_log += ":#{officer_assignment_id_was}"
|
||||
self.author_id_log += ":#{author_id_was}"
|
||||
if will_save_change_to_amount? && amount_in_database.present?
|
||||
self.amount_log += ":#{amount_in_database}"
|
||||
self.officer_assignment_id_log += ":#{officer_assignment_id_in_database}"
|
||||
self.author_id_log += ":#{author_id_in_database}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -20,9 +20,9 @@ class Poll::Recount < ApplicationRecord
|
||||
amounts_changed = false
|
||||
|
||||
[:white, :null, :total].each do |amount|
|
||||
next unless send("#{amount}_amount_changed?") && send("#{amount}_amount_was").present?
|
||||
next unless send("will_save_change_to_#{amount}_amount?") && send("#{amount}_amount_in_database").present?
|
||||
|
||||
self["#{amount}_amount_log"] += ":#{send("#{amount}_amount_was")}"
|
||||
self["#{amount}_amount_log"] += ":#{send("#{amount}_amount_in_database")}"
|
||||
amounts_changed = true
|
||||
end
|
||||
|
||||
@@ -30,7 +30,7 @@ class Poll::Recount < ApplicationRecord
|
||||
end
|
||||
|
||||
def update_officer_author
|
||||
self.officer_assignment_id_log += ":#{officer_assignment_id_was}"
|
||||
self.author_id_log += ":#{author_id_was}"
|
||||
self.officer_assignment_id_log += ":#{officer_assignment_id_in_database}"
|
||||
self.author_id_log += ":#{author_id_in_database}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
ActiveSupport.halt_callback_chains_on_return_false = false
|
||||
@@ -1,5 +1,7 @@
|
||||
require "database_cleaner"
|
||||
DatabaseCleaner.clean_with :truncation
|
||||
unless Rails.env.test?
|
||||
require "database_cleaner"
|
||||
DatabaseCleaner.clean_with :truncation
|
||||
end
|
||||
@logger = Logger.new(STDOUT)
|
||||
@logger.formatter = proc do |_severity, _datetime, _progname, msg|
|
||||
msg unless @avoid_log
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
class MakeInvestmentMilestonesPolymorphic < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :milestones do |t|
|
||||
t.references :milestoneable, polymorphic: true
|
||||
create_table :milestones, id: :serial do |t|
|
||||
t.string :milestoneable_type
|
||||
t.integer :milestoneable_id
|
||||
t.string "title", limit: 80
|
||||
t.text "description"
|
||||
t.datetime "publication_date"
|
||||
|
||||
t.references :status, index: true
|
||||
t.integer :status_id, index: true
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
reversible do |change|
|
||||
change.up do
|
||||
Milestone.create_translation_table!({
|
||||
title: :string,
|
||||
description: :text
|
||||
})
|
||||
end
|
||||
create_table :milestone_translations do |t|
|
||||
t.integer :milestone_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
change.down do
|
||||
Milestone.drop_translation_table!
|
||||
end
|
||||
t.string :title
|
||||
t.text :description
|
||||
|
||||
t.index :locale
|
||||
t.index :milestone_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
class CreateI18nContentTranslations < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :i18n_contents do |t|
|
||||
create_table :i18n_contents, id: :serial do |t|
|
||||
t.string :key
|
||||
end
|
||||
|
||||
reversible do |dir|
|
||||
dir.up do
|
||||
I18nContent.create_translation_table!(
|
||||
{ value: :text },
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
create_table :i18n_content_translations do |t|
|
||||
t.integer :i18n_content_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
dir.down do
|
||||
I18nContent.drop_translation_table!
|
||||
end
|
||||
t.text :value
|
||||
|
||||
t.index :i18n_content_id
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
class AddBannerTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Banner.create_translation_table!(
|
||||
{
|
||||
title: :string,
|
||||
description: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :banner_translations do |t|
|
||||
t.integer :banner_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Banner.drop_translation_table!
|
||||
t.string :title
|
||||
t.text :description
|
||||
|
||||
t.index :banner_id
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
class AddHomepageContentTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Widget::Card.create_translation_table!(
|
||||
{
|
||||
label: :string,
|
||||
title: :string,
|
||||
description: :text,
|
||||
link_text: :string
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :widget_card_translations do |t|
|
||||
t.integer :widget_card_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Widget::Card.drop_translation_table!
|
||||
t.string :label
|
||||
t.string :title
|
||||
t.text :description
|
||||
t.string :link_text
|
||||
|
||||
t.index :locale
|
||||
t.index :widget_card_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
class AddPollTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Poll.create_translation_table!(
|
||||
{
|
||||
name: :string,
|
||||
summary: :text,
|
||||
description: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :poll_translations do |t|
|
||||
t.integer :poll_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Poll.drop_translation_table!
|
||||
t.string :name
|
||||
t.text :summary
|
||||
t.text :description
|
||||
|
||||
t.index :locale
|
||||
t.index :poll_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
class AddAdminNotificationTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
AdminNotification.create_translation_table!(
|
||||
{
|
||||
title: :string,
|
||||
body: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :admin_notification_translations do |t|
|
||||
t.integer :admin_notification_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
AdminNotification.drop_translation_table!
|
||||
t.string :title
|
||||
t.text :body
|
||||
|
||||
t.index :admin_notification_id
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
class AddPollQuestionTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Poll::Question.create_translation_table!(
|
||||
{ title: :string },
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :poll_question_translations do |t|
|
||||
t.integer :poll_question_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Poll::Question.drop_translation_table!
|
||||
t.string :title
|
||||
|
||||
t.index :locale
|
||||
t.index :poll_question_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
class AddPollQuestionAnswerTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Poll::Question::Answer.create_translation_table!(
|
||||
{
|
||||
title: :string,
|
||||
description: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :poll_question_answer_translations do |t|
|
||||
t.integer :poll_question_answer_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Poll::Question::Answer.drop_translation_table!
|
||||
t.string :title
|
||||
t.text :description
|
||||
|
||||
t.index :locale
|
||||
t.index :poll_question_answer_id, name: "index_85270fa85f62081a3a227186b4c95fe4f7fa94b9"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,42 +1,54 @@
|
||||
class AddCollaborativeLegislationTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Legislation::Process.create_translation_table!(
|
||||
{
|
||||
title: :string,
|
||||
summary: :text,
|
||||
description: :text,
|
||||
additional_info: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
def change
|
||||
create_table :legislation_process_translations do |t|
|
||||
t.integer :legislation_process_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
Legislation::Question.create_translation_table!(
|
||||
{ title: :text },
|
||||
{ migrate_data: true }
|
||||
)
|
||||
t.string :title
|
||||
t.text :summary
|
||||
t.text :description
|
||||
t.text :additional_info
|
||||
|
||||
Legislation::DraftVersion.create_translation_table!(
|
||||
{
|
||||
title: :string,
|
||||
changelog: :text,
|
||||
body: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
t.index :legislation_process_id, name: "index_199e5fed0aca73302243f6a1fca885ce10cdbb55"
|
||||
t.index :locale
|
||||
end
|
||||
|
||||
add_column :legislation_draft_version_translations, :body_html, :text
|
||||
add_column :legislation_draft_version_translations, :toc_html, :text
|
||||
create_table :legislation_question_translations do |t|
|
||||
t.integer :legislation_question_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
Legislation::QuestionOption.create_translation_table!(
|
||||
{ value: :string },
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
t.text :title
|
||||
|
||||
def self.down
|
||||
Legislation::Process.drop_translation_table!
|
||||
Legislation::DraftVersion.drop_translation_table!
|
||||
Legislation::Question.drop_translation_table!
|
||||
Legislation::QuestionOption.drop_translation_table!
|
||||
t.index :legislation_question_id, name: "index_d34cc1e1fe6d5162210c41ce56533c5afabcdbd3"
|
||||
t.index :locale
|
||||
end
|
||||
|
||||
create_table :legislation_draft_version_translations do |t|
|
||||
t.integer :legislation_draft_version_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
t.string :title
|
||||
t.text :changelog
|
||||
t.text :body
|
||||
t.text :body_html
|
||||
t.text :toc_html
|
||||
|
||||
t.index :legislation_draft_version_id, name: "index_900e5ba94457606e69e89193db426e8ddff809bc"
|
||||
t.index :locale
|
||||
end
|
||||
|
||||
create_table :legislation_question_option_translations do |t|
|
||||
t.integer :legislation_question_option_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
t.string :value
|
||||
|
||||
t.index :legislation_question_option_id, name: "index_61bcec8729110b7f8e1e9e5ce08780878597a209"
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
class AddTranslatePages < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
SiteCustomization::Page.create_translation_table!(
|
||||
{
|
||||
title: :string,
|
||||
subtitle: :string,
|
||||
content: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
def change
|
||||
create_table :site_customization_page_translations do |t|
|
||||
t.integer :site_customization_page_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
change_column :site_customization_pages, :title, :string, null: true
|
||||
end
|
||||
t.string :title
|
||||
t.string :subtitle
|
||||
t.text :content
|
||||
|
||||
def self.down
|
||||
SiteCustomization::Page.drop_translation_table!
|
||||
change_column :site_customization_pages, :title, :string, null: false
|
||||
t.index :locale
|
||||
t.index :site_customization_page_id, name: "index_7fa0f9505738cb31a31f11fb2f4c4531fed7178b"
|
||||
end
|
||||
|
||||
change_column_null :site_customization_pages, :title, from: false, to: true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
class AddProposalsTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Proposal.create_translation_table!(
|
||||
{
|
||||
title: :string,
|
||||
description: :text,
|
||||
summary: :text,
|
||||
retired_explanation: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :proposal_translations do |t|
|
||||
t.integer :proposal_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Proposal.drop_translation_table!
|
||||
t.string :title
|
||||
t.text :description
|
||||
t.text :summary
|
||||
t.text :retired_explanation
|
||||
|
||||
t.index :locale
|
||||
t.index :proposal_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
class AddDebatesTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Debate.create_translation_table!(
|
||||
{
|
||||
title: :string,
|
||||
description: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :debate_translations do |t|
|
||||
t.integer :debate_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Debate.drop_translation_table!
|
||||
t.string :title
|
||||
t.text :description
|
||||
|
||||
t.index :debate_id
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
class AddCommentsTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Comment.create_translation_table!(
|
||||
{
|
||||
body: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :comment_translations do |t|
|
||||
t.integer :comment_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Comment.drop_translation_table!
|
||||
t.text :body
|
||||
|
||||
t.index :comment_id
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,15 +1,6 @@
|
||||
class AddHomePageToLegislationProcesses < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_column :legislation_processes, :homepage_enabled, :boolean, default: false
|
||||
|
||||
reversible do |dir|
|
||||
dir.up do
|
||||
Legislation::Process.add_translation_fields! homepage: :text
|
||||
end
|
||||
|
||||
dir.down do
|
||||
remove_column :legislation_process_translations, :homepage
|
||||
end
|
||||
end
|
||||
add_column :legislation_process_translations, :homepage, :text
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
class AddBudgetInvestmentTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Budget::Investment::Translation.without_auditing do
|
||||
Budget::Investment.create_translation_table!(
|
||||
{
|
||||
title: :string,
|
||||
description: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
def change
|
||||
create_table :budget_investment_translations do |t|
|
||||
t.integer :budget_investment_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
t.string :title
|
||||
t.text :description
|
||||
|
||||
t.index :budget_investment_id
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
Budget::Investment.drop_translation_table!
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
class CreateProgressBars < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :progress_bars do |t|
|
||||
create_table :progress_bars, id: :serial do |t|
|
||||
t.integer :kind
|
||||
t.integer :percentage
|
||||
t.references :progressable, polymorphic: true
|
||||
t.string :progressable_type
|
||||
t.integer :progressable_id
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
reversible do |change|
|
||||
change.up do
|
||||
ProgressBar.create_translation_table!({
|
||||
title: :string
|
||||
})
|
||||
end
|
||||
create_table :progress_bar_translations do |t|
|
||||
t.integer :progress_bar_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
change.down do
|
||||
ProgressBar.drop_translation_table!
|
||||
end
|
||||
t.string :title
|
||||
|
||||
t.index :locale
|
||||
t.index :progress_bar_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
class AddActivePollsTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
ActivePoll.create_translation_table!(
|
||||
{
|
||||
description: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :active_poll_translations do |t|
|
||||
t.integer :active_poll_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
ActivePollPoll.drop_translation_table!
|
||||
t.text "description"
|
||||
|
||||
t.index :active_poll_id
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
class AddBudgetTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Budget.create_translation_table!(
|
||||
{
|
||||
name: :string
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :budget_translations do |t|
|
||||
t.integer :budget_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Budget.drop_translation_table!
|
||||
t.string :name
|
||||
|
||||
t.index :budget_id
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
class AddBudgetPhaseTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Budget::Phase.create_translation_table!(
|
||||
{
|
||||
description: :text,
|
||||
summary: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :budget_phase_translations do |t|
|
||||
t.integer :budget_phase_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Budget::Phase.drop_translation_table!
|
||||
t.text :description
|
||||
t.text :summary
|
||||
|
||||
t.index :budget_phase_id
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
class AddBudgetGroupTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Budget::Group.create_translation_table!(
|
||||
{
|
||||
name: :string
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :budget_group_translations do |t|
|
||||
t.integer :budget_group_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Budget::Group.drop_translation_table!
|
||||
t.string :name
|
||||
|
||||
t.index :budget_group_id
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
class AddBudgetHeadingTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
Budget::Heading.create_translation_table!(
|
||||
{
|
||||
name: :string
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
end
|
||||
def change
|
||||
create_table :budget_heading_translations do |t|
|
||||
t.integer :budget_heading_id, null: false
|
||||
t.string :locale, null: false
|
||||
t.timestamps null: false
|
||||
|
||||
def self.down
|
||||
Budget::Heading.drop_translation_table!
|
||||
t.string :name
|
||||
|
||||
t.index :budget_heading_id
|
||||
t.index :locale
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# This migration comes from acts_as_taggable_on_engine (originally 2)
|
||||
if ActiveRecord.gem_version >= Gem::Version.new("5.0")
|
||||
class AddMissingUniqueIndices < ActiveRecord::Migration[4.2]; end
|
||||
else
|
||||
class AddMissingUniqueIndices < ActiveRecord::Migration; end
|
||||
end
|
||||
AddMissingUniqueIndices.class_eval do
|
||||
def self.up
|
||||
add_index :taggings,
|
||||
[:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type],
|
||||
unique: true, name: "taggings_idx"
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_index :taggings, name: "taggings_idx"
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,22 @@
|
||||
# This migration comes from acts_as_taggable_on_engine (originally 6)
|
||||
if ActiveRecord.gem_version >= Gem::Version.new("5.0")
|
||||
class AddMissingIndexesOnTaggings < ActiveRecord::Migration[4.2]; end
|
||||
else
|
||||
class AddMissingIndexesOnTaggings < ActiveRecord::Migration; end
|
||||
end
|
||||
AddMissingIndexesOnTaggings.class_eval do
|
||||
def change
|
||||
add_index :taggings, :taggable_id unless index_exists? :taggings, :taggable_id
|
||||
add_index :taggings, :taggable_type unless index_exists? :taggings, :taggable_type
|
||||
add_index :taggings, :tagger_id unless index_exists? :taggings, :tagger_id
|
||||
add_index :taggings, :context unless index_exists? :taggings, :context
|
||||
|
||||
unless index_exists? :taggings, [:tagger_id, :tagger_type]
|
||||
add_index :taggings, [:tagger_id, :tagger_type]
|
||||
end
|
||||
|
||||
unless index_exists? :taggings, [:taggable_id, :taggable_type, :tagger_id, :context], name: "taggings_idy"
|
||||
add_index :taggings, [:taggable_id, :taggable_type, :tagger_id, :context], name: "taggings_idy"
|
||||
end
|
||||
end
|
||||
end
|
||||
2569
db/schema.rb
2569
db/schema.rb
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe "rake sitemap:create", type: :feature do
|
||||
describe "rake sitemap:create", type: :system do
|
||||
let(:file) { Rails.root.join("public", "sitemap.xml") }
|
||||
|
||||
before do
|
||||
|
||||
@@ -1096,29 +1096,29 @@ describe Budget::Investment do
|
||||
let(:heading1) { create(:budget_heading, group: group) }
|
||||
let(:heading2) { create(:budget_heading, group: group) }
|
||||
|
||||
describe "heading_changed?" do
|
||||
describe "saved_change_to_heading?" do
|
||||
it "returns true if budget is in balloting phase and heading has changed" do
|
||||
investment = create(:budget_investment, heading: heading1)
|
||||
investment.heading = heading2
|
||||
investment.update!(heading: heading2)
|
||||
|
||||
expect(investment.heading_changed?).to eq(true)
|
||||
expect(investment.saved_change_to_heading?).to eq(true)
|
||||
end
|
||||
|
||||
it "returns false if heading has not changed" do
|
||||
investment = create(:budget_investment)
|
||||
investment.heading = investment.heading
|
||||
investment = create(:budget_investment, heading: heading1)
|
||||
investment.update!(heading: heading1)
|
||||
|
||||
expect(investment.heading_changed?).to eq(false)
|
||||
expect(investment.saved_change_to_heading?).to eq(false)
|
||||
end
|
||||
|
||||
it "returns false if budget is not balloting phase" do
|
||||
Budget::Phase::PHASE_KINDS.reject { |phase| phase == "balloting" }.each do |phase|
|
||||
budget.update!(phase: phase)
|
||||
investment = create(:budget_investment, budget: budget)
|
||||
investment = create(:budget_investment, heading: heading1)
|
||||
|
||||
investment.heading = heading2
|
||||
investment.update!(heading: heading2)
|
||||
|
||||
expect(investment.heading_changed?).to eq(false)
|
||||
expect(investment.saved_change_to_heading?).to eq(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1327,7 +1327,7 @@ describe Budget::Investment do
|
||||
let(:investment) { create(:budget_investment, :with_milestone_tags) }
|
||||
|
||||
it "has milestone_tags" do
|
||||
expect(investment.milestone_tag_list.count).to eq(1)
|
||||
expect(investment.reload.milestone_tag_list.count).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -218,7 +218,7 @@ describe Legislation::Process do
|
||||
let(:process) { create(:legislation_process, :with_milestone_tags) }
|
||||
|
||||
it "has milestone_tags" do
|
||||
expect(process.milestone_tag_list.count).to eq(1)
|
||||
expect(process.reload.milestone_tag_list.count).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1045,7 +1045,7 @@ describe Proposal do
|
||||
let(:proposal) { create(:proposal, :with_milestone_tags) }
|
||||
|
||||
it "has milestone_tags" do
|
||||
expect(proposal.milestone_tag_list.count).to eq(1)
|
||||
expect(proposal.reload.milestone_tag_list.count).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,6 +19,18 @@ Warden.test_mode!
|
||||
|
||||
ActiveRecord::Migration.maintain_test_schema!
|
||||
|
||||
# Monkey patch from https://github.com/rails/rails/pull/32293
|
||||
# Remove when we upgrade to Rails 5.2
|
||||
require "action_dispatch/system_testing/test_helpers/setup_and_teardown"
|
||||
module ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown
|
||||
def after_teardown
|
||||
take_failed_screenshot
|
||||
Capybara.reset_sessions!
|
||||
ensure
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.infer_spec_type_from_file_location!
|
||||
config.after do
|
||||
@@ -26,10 +38,6 @@ RSpec.configure do |config|
|
||||
end
|
||||
end
|
||||
|
||||
Capybara.register_driver :chrome do |app|
|
||||
Capybara::Selenium::Driver.new(app, browser: :chrome)
|
||||
end
|
||||
|
||||
Capybara.register_driver :headless_chrome do |app|
|
||||
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
|
||||
"goog:chromeOptions" => {
|
||||
@@ -44,8 +52,6 @@ Capybara.register_driver :headless_chrome do |app|
|
||||
)
|
||||
end
|
||||
|
||||
Capybara.javascript_driver = :headless_chrome
|
||||
|
||||
Capybara.exact = true
|
||||
|
||||
OmniAuth.config.test_mode = true
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
require "factory_bot_rails"
|
||||
require "database_cleaner"
|
||||
require "email_spec"
|
||||
require "devise"
|
||||
require "knapsack_pro"
|
||||
@@ -9,7 +8,7 @@ Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
|
||||
Dir["./spec/shared/**/*.rb"].sort.each { |f| require f }
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.use_transactional_fixtures = false
|
||||
config.use_transactional_fixtures = true
|
||||
|
||||
config.filter_run :focus
|
||||
config.run_all_when_everything_filtered = true
|
||||
@@ -22,49 +21,17 @@ RSpec.configure do |config|
|
||||
config.include(ActiveSupport::Testing::TimeHelpers)
|
||||
|
||||
config.before(:suite) do
|
||||
DatabaseCleaner.clean_with :truncation
|
||||
end
|
||||
|
||||
config.before(:suite) do
|
||||
if config.use_transactional_fixtures?
|
||||
raise(<<-MSG)
|
||||
Delete line `config.use_transactional_fixtures = true` from rails_helper.rb
|
||||
(or set it to false) to prevent uncommitted transactions being used in
|
||||
JavaScript-dependent specs.
|
||||
|
||||
During testing, the app-under-test that the browser driver connects to
|
||||
uses a different database connection to the database connection used by
|
||||
the spec. The app's database connection would not be able to access
|
||||
uncommitted transaction data setup over the spec's database connection.
|
||||
MSG
|
||||
end
|
||||
|
||||
DatabaseCleaner.clean_with(:truncation)
|
||||
Rails.application.load_seed
|
||||
end
|
||||
|
||||
config.before do |example|
|
||||
DatabaseCleaner.strategy = :transaction
|
||||
I18n.locale = :en
|
||||
Globalize.locale = nil
|
||||
Globalize.set_fallbacks_to_all_available_locales
|
||||
load Rails.root.join("db", "seeds.rb").to_s
|
||||
Setting["feature.user.skip_verification"] = nil
|
||||
end
|
||||
|
||||
config.before(:each, type: :feature) do
|
||||
# :rack_test driver's Rack app under test shares database connection
|
||||
# with the specs, so continue to use transaction strategy for speed.
|
||||
driver_shares_db_connection_with_specs = Capybara.current_driver == :rack_test
|
||||
|
||||
unless driver_shares_db_connection_with_specs
|
||||
# Driver is probably for an external browser with an app
|
||||
# under test that does *not* share a database connection with the
|
||||
# specs, so use truncation strategy.
|
||||
DatabaseCleaner.strategy = :truncation
|
||||
end
|
||||
end
|
||||
|
||||
config.before(:each, type: :feature) do
|
||||
config.before(:each, type: :system) do
|
||||
Capybara::Webmock.start
|
||||
end
|
||||
|
||||
@@ -76,20 +43,20 @@ RSpec.configure do |config|
|
||||
page.driver.reset!
|
||||
end
|
||||
|
||||
config.before do
|
||||
DatabaseCleaner.start
|
||||
config.before(:each, type: :system) do |example|
|
||||
driven_by :rack_test
|
||||
end
|
||||
|
||||
config.append_after do
|
||||
DatabaseCleaner.clean
|
||||
config.before(:each, type: :system, js: true) do
|
||||
driven_by :headless_chrome
|
||||
end
|
||||
|
||||
config.before(:each, type: :feature) do
|
||||
config.before(:each, type: :system) do
|
||||
Bullet.start_request
|
||||
allow(InvisibleCaptcha).to receive(:timestamp_threshold).and_return(0)
|
||||
end
|
||||
|
||||
config.after(:each, type: :feature) do
|
||||
config.after(:each, type: :system) do
|
||||
Bullet.perform_out_of_channel_notifications if Bullet.notification?
|
||||
Bullet.end_request
|
||||
end
|
||||
|
||||
@@ -44,17 +44,21 @@ module Verifications
|
||||
end
|
||||
end
|
||||
|
||||
def fill_in_ckeditor(text, params = {})
|
||||
locator = find("label", text: text)[:for]
|
||||
def fill_in_ckeditor(label, with:)
|
||||
locator = find("label", text: label)[:for]
|
||||
|
||||
until page.execute_script("return CKEDITOR.instances.#{locator}.status === 'ready';") do
|
||||
sleep 0.01
|
||||
end
|
||||
|
||||
# Fill the editor content
|
||||
page.execute_script <<-SCRIPT
|
||||
var ckeditor = CKEDITOR.instances.#{locator}
|
||||
ckeditor.setData("#{params[:with]}")
|
||||
ckeditor.setData("#{with}")
|
||||
ckeditor.focus()
|
||||
ckeditor.updateElement()
|
||||
SCRIPT
|
||||
|
||||
expect(page).to have_ckeditor text, with: params[:with]
|
||||
expect(page).to have_ckeditor label, with: with
|
||||
end
|
||||
end
|
||||
|
||||
@@ -58,4 +58,20 @@ describe "Answers" do
|
||||
|
||||
expect("Another title").to appear_before("New title")
|
||||
end
|
||||
|
||||
scenario "Reorder", :js do
|
||||
question = create(:poll_question)
|
||||
create(:poll_question_answer, question: question, title: "First", given_order: 1)
|
||||
create(:poll_question_answer, question: question, title: "Last", given_order: 2)
|
||||
|
||||
visit admin_question_path(question)
|
||||
|
||||
within("tbody.sortable") do
|
||||
expect("First").to appear_before("Last")
|
||||
|
||||
find("tr", text: "Last").drag_to(find("tr", text: "First"))
|
||||
|
||||
expect("Last").to appear_before("First")
|
||||
end
|
||||
end
|
||||
end
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user