diff --git a/config.ru b/config.ru
index 193e5fed8..846e1c70a 100644
--- a/config.ru
+++ b/config.ru
@@ -1,4 +1,4 @@
# This file is used by Rack-based servers to start the application.
-require ::File.expand_path("../config/environment", __FILE__)
+require ::File.expand_path("config/environment", __dir__)
run Rails.application
diff --git a/config/application.rb b/config/application.rb
index b4a336198..d544fae19 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -23,9 +23,8 @@ class Application < Rails::Application
config.eager_load_paths += %W(#{config.root}/lib)
config.assets.paths << Rails.root.join('node_modules')
- #config.logger = ActiveSupport::Logger.new(STDOUT)
config.to_prepare do
- Devise::Mailer.layout "email" # email.haml or email.erb
+ Devise::Mailer.layout "email" # email.haml or email.erb
end
config.exceptions_app = ->(env) { ExceptionsController.action(:show).call(env) }
@@ -51,7 +50,6 @@ class Application < Rails::Application
config.call_tool_url = Rails.application.secrets.call_tool_url
config.congress_forms_url = Rails.application.secrets.congress_forms_url
config.time_zone = Rails.application.secrets.time_zone || "Eastern Time (US & Canada)"
- config.active_record.raise_in_transactional_callbacks = true
# fix file attachment:
# https://github.com/EFForg/action-center-platform/pull/408#issuecomment-381269915
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 450d29783..e73100d1c 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -58,7 +58,9 @@
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
- config.logger = Logger.new STDOUT
+ logger = ActiveSupport::Logger.new STDOUT
+ logger.formatter = config.log_formatter
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
diff --git a/config/environments/test.rb b/config/environments/test.rb
index c5f1c3ace..04116d57a 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -13,8 +13,8 @@
config.eager_load = false
# Configure static asset server for tests with Cache-Control for performance.
- config.serve_static_files = true
- config.static_cache_control = "public, max-age=3600"
+ config.public_file_server.enabled = true
+ config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
# Show full error reports and disable caching.
config.consider_all_requests_local = true
diff --git a/db/migrate/20140300000000_enable_extension_ossd.rb b/db/migrate/20140300000000_enable_extension_ossd.rb
index 1c8465707..c1408e09c 100644
--- a/db/migrate/20140300000000_enable_extension_ossd.rb
+++ b/db/migrate/20140300000000_enable_extension_ossd.rb
@@ -1,4 +1,4 @@
-class EnableExtensionOssd < ActiveRecord::Migration
+class EnableExtensionOssd < ActiveRecord::Migration[5.0]
def change
enable_extension "uuid-ossp"
end
diff --git a/db/migrate/20140311235111_create_activities.rb b/db/migrate/20140311235111_create_activities.rb
index db93d1e52..933e66123 100644
--- a/db/migrate/20140311235111_create_activities.rb
+++ b/db/migrate/20140311235111_create_activities.rb
@@ -1,4 +1,4 @@
-class CreateActivities < ActiveRecord::Migration
+class CreateActivities < ActiveRecord::Migration[5.0]
def change
create_table :activities do |t|
t.string :description
diff --git a/db/migrate/20140313144408_create_action_pages.rb b/db/migrate/20140313144408_create_action_pages.rb
index 42c353562..5672f55e5 100644
--- a/db/migrate/20140313144408_create_action_pages.rb
+++ b/db/migrate/20140313144408_create_action_pages.rb
@@ -1,4 +1,4 @@
-class CreateActionPages < ActiveRecord::Migration
+class CreateActionPages < ActiveRecord::Migration[5.0]
def change
create_table :action_pages do |t|
t.string :title
diff --git a/db/migrate/20140314020630_devise_create_users.rb b/db/migrate/20140314020630_devise_create_users.rb
index ab71c3d1b..12f29a418 100644
--- a/db/migrate/20140314020630_devise_create_users.rb
+++ b/db/migrate/20140314020630_devise_create_users.rb
@@ -1,4 +1,4 @@
-class DeviseCreateUsers < ActiveRecord::Migration
+class DeviseCreateUsers < ActiveRecord::Migration[5.0]
def change
create_table(:users) do |t|
## Database authenticatable
diff --git a/db/migrate/20140317070243_add_userid_to_activities.rb b/db/migrate/20140317070243_add_userid_to_activities.rb
index b3b60e2eb..051ad72ce 100644
--- a/db/migrate/20140317070243_add_userid_to_activities.rb
+++ b/db/migrate/20140317070243_add_userid_to_activities.rb
@@ -1,4 +1,4 @@
-class AddUseridToActivities < ActiveRecord::Migration
+class AddUseridToActivities < ActiveRecord::Migration[5.0]
def change
add_column :activities, :user_id, :integer
end
diff --git a/db/migrate/20140317084144_add_action_pageid_to_activities.rb b/db/migrate/20140317084144_add_action_pageid_to_activities.rb
index c57569cf2..56769d63d 100644
--- a/db/migrate/20140317084144_add_action_pageid_to_activities.rb
+++ b/db/migrate/20140317084144_add_action_pageid_to_activities.rb
@@ -1,4 +1,4 @@
-class AddActionPageidToActivities < ActiveRecord::Migration
+class AddActionPageidToActivities < ActiveRecord::Migration[5.0]
def change
add_column :activities, :action_page_id, :integer
end
diff --git a/db/migrate/20140325050528_create_petitions.rb b/db/migrate/20140325050528_create_petitions.rb
index c44dc85e5..c5350323d 100644
--- a/db/migrate/20140325050528_create_petitions.rb
+++ b/db/migrate/20140325050528_create_petitions.rb
@@ -1,4 +1,4 @@
-class CreatePetitions < ActiveRecord::Migration
+class CreatePetitions < ActiveRecord::Migration[5.0]
def change
create_table :petitions do |t|
t.string :title
diff --git a/db/migrate/20140325050602_create_signatures.rb b/db/migrate/20140325050602_create_signatures.rb
index ea6eef268..a6b333ab1 100644
--- a/db/migrate/20140325050602_create_signatures.rb
+++ b/db/migrate/20140325050602_create_signatures.rb
@@ -1,4 +1,4 @@
-class CreateSignatures < ActiveRecord::Migration
+class CreateSignatures < ActiveRecord::Migration[5.0]
def change
create_table :signatures do |t|
t.integer :petition_id
diff --git a/db/migrate/20140327210422_create_featured_action_pages.rb b/db/migrate/20140327210422_create_featured_action_pages.rb
index 967089c57..69f4b90ca 100644
--- a/db/migrate/20140327210422_create_featured_action_pages.rb
+++ b/db/migrate/20140327210422_create_featured_action_pages.rb
@@ -1,4 +1,4 @@
-class CreateFeaturedActionPages < ActiveRecord::Migration
+class CreateFeaturedActionPages < ActiveRecord::Migration[5.0]
def change
create_table :featured_action_pages do |t|
t.integer :action_page_id
diff --git a/db/migrate/20140328161752_add_details_to_user.rb b/db/migrate/20140328161752_add_details_to_user.rb
index d93bbfe44..2d5901725 100644
--- a/db/migrate/20140328161752_add_details_to_user.rb
+++ b/db/migrate/20140328161752_add_details_to_user.rb
@@ -1,4 +1,4 @@
-class AddDetailsToUser < ActiveRecord::Migration
+class AddDetailsToUser < ActiveRecord::Migration[5.0]
def change
add_column :users, :first_name, :string
add_column :users, :last_name, :string
diff --git a/db/migrate/20140402190943_add_fields_to_signatures.rb b/db/migrate/20140402190943_add_fields_to_signatures.rb
index d0fd311d6..4fabb36fb 100644
--- a/db/migrate/20140402190943_add_fields_to_signatures.rb
+++ b/db/migrate/20140402190943_add_fields_to_signatures.rb
@@ -1,4 +1,4 @@
-class AddFieldsToSignatures < ActiveRecord::Migration
+class AddFieldsToSignatures < ActiveRecord::Migration[5.0]
def change
add_column :signatures, :first_name, :string
add_column :signatures, :last_name, :string
diff --git a/db/migrate/20140402192811_add_petition_id_to_action_pages.rb b/db/migrate/20140402192811_add_petition_id_to_action_pages.rb
index 5f6154720..1ec5114ef 100644
--- a/db/migrate/20140402192811_add_petition_id_to_action_pages.rb
+++ b/db/migrate/20140402192811_add_petition_id_to_action_pages.rb
@@ -1,4 +1,4 @@
-class AddPetitionIdToActionPages < ActiveRecord::Migration
+class AddPetitionIdToActionPages < ActiveRecord::Migration[5.0]
def change
add_column :action_pages, :petition_id, :integer
end
diff --git a/db/migrate/20140403002100_add_photo_url_to_action_pages.rb b/db/migrate/20140403002100_add_photo_url_to_action_pages.rb
index 3ed6d3ad8..7052cfcaa 100644
--- a/db/migrate/20140403002100_add_photo_url_to_action_pages.rb
+++ b/db/migrate/20140403002100_add_photo_url_to_action_pages.rb
@@ -1,4 +1,4 @@
-class AddPhotoUrlToActionPages < ActiveRecord::Migration
+class AddPhotoUrlToActionPages < ActiveRecord::Migration[5.0]
def change
add_column :action_pages, :photo_url, :string
end
diff --git a/db/migrate/20140403183138_add_admin_to_users.rb b/db/migrate/20140403183138_add_admin_to_users.rb
index e386d33dd..0e2407641 100644
--- a/db/migrate/20140403183138_add_admin_to_users.rb
+++ b/db/migrate/20140403183138_add_admin_to_users.rb
@@ -1,4 +1,4 @@
-class AddAdminToUsers < ActiveRecord::Migration
+class AddAdminToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :admin, :boolean, default: false
end
diff --git a/db/migrate/20140404223839_add_fields_for_tools_to_action_pages.rb b/db/migrate/20140404223839_add_fields_for_tools_to_action_pages.rb
index 1f72afa47..82edad478 100644
--- a/db/migrate/20140404223839_add_fields_for_tools_to_action_pages.rb
+++ b/db/migrate/20140404223839_add_fields_for_tools_to_action_pages.rb
@@ -1,4 +1,4 @@
-class AddFieldsForToolsToActionPages < ActiveRecord::Migration
+class AddFieldsForToolsToActionPages < ActiveRecord::Migration[5.0]
def change
add_column :action_pages, :enable_call, :boolean, default: false
add_column :action_pages, :enable_petition, :boolean, default: false
diff --git a/db/migrate/20140409105241_add_slug_to_actionpage.rb b/db/migrate/20140409105241_add_slug_to_actionpage.rb
index d9f5dfda7..a9f8af8e7 100644
--- a/db/migrate/20140409105241_add_slug_to_actionpage.rb
+++ b/db/migrate/20140409105241_add_slug_to_actionpage.rb
@@ -1,4 +1,4 @@
-class AddSlugToActionpage < ActiveRecord::Migration
+class AddSlugToActionpage < ActiveRecord::Migration[5.0]
def change
add_column :action_pages, :slug, :string
add_index :action_pages, :slug
diff --git a/db/migrate/20140409105530_create_friendly_id_slugs.rb b/db/migrate/20140409105530_create_friendly_id_slugs.rb
index 770f62644..c95692d56 100644
--- a/db/migrate/20140409105530_create_friendly_id_slugs.rb
+++ b/db/migrate/20140409105530_create_friendly_id_slugs.rb
@@ -1,4 +1,4 @@
-class CreateFriendlyIdSlugs < ActiveRecord::Migration
+class CreateFriendlyIdSlugs < ActiveRecord::Migration[5.0]
def change
create_table :friendly_id_slugs do |t|
t.string :slug, :null => false
diff --git a/db/migrate/20140410025404_add_address_to_signatures.rb b/db/migrate/20140410025404_add_address_to_signatures.rb
index caabbe849..73f73e622 100644
--- a/db/migrate/20140410025404_add_address_to_signatures.rb
+++ b/db/migrate/20140410025404_add_address_to_signatures.rb
@@ -1,4 +1,4 @@
-class AddAddressToSignatures < ActiveRecord::Migration
+class AddAddressToSignatures < ActiveRecord::Migration[5.0]
def change
add_column :signatures, :street_address, :string
add_column :signatures, :city, :string
diff --git a/db/migrate/20140410030958_add_address_to_users.rb b/db/migrate/20140410030958_add_address_to_users.rb
index 5550eacd3..6b8445614 100644
--- a/db/migrate/20140410030958_add_address_to_users.rb
+++ b/db/migrate/20140410030958_add_address_to_users.rb
@@ -1,4 +1,4 @@
-class AddAddressToUsers < ActiveRecord::Migration
+class AddAddressToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :street_address, :string
add_column :users, :city, :string
diff --git a/db/migrate/20140410033413_add_goal_to_petition.rb b/db/migrate/20140410033413_add_goal_to_petition.rb
index d643d66e7..d2b75bf2b 100644
--- a/db/migrate/20140410033413_add_goal_to_petition.rb
+++ b/db/migrate/20140410033413_add_goal_to_petition.rb
@@ -1,4 +1,4 @@
-class AddGoalToPetition < ActiveRecord::Migration
+class AddGoalToPetition < ActiveRecord::Migration[5.0]
def change
add_column :petitions, :goal, :integer
end
diff --git a/db/migrate/20140416002624_add_anonymous_to_signatures.rb b/db/migrate/20140416002624_add_anonymous_to_signatures.rb
index 9f5283fec..f10f7542e 100644
--- a/db/migrate/20140416002624_add_anonymous_to_signatures.rb
+++ b/db/migrate/20140416002624_add_anonymous_to_signatures.rb
@@ -1,4 +1,4 @@
-class AddAnonymousToSignatures < ActiveRecord::Migration
+class AddAnonymousToSignatures < ActiveRecord::Migration[5.0]
def change
add_column :signatures, :anonymous, :boolean, default: false
end
diff --git a/db/migrate/20140417021005_add_share_message_to_action_pages.rb b/db/migrate/20140417021005_add_share_message_to_action_pages.rb
index fdb328655..51e2a3a16 100644
--- a/db/migrate/20140417021005_add_share_message_to_action_pages.rb
+++ b/db/migrate/20140417021005_add_share_message_to_action_pages.rb
@@ -1,4 +1,4 @@
-class AddShareMessageToActionPages < ActiveRecord::Migration
+class AddShareMessageToActionPages < ActiveRecord::Migration[5.0]
def change
add_column :action_pages, :share_message, :string
end
diff --git a/db/migrate/20140423002336_create_tweets.rb b/db/migrate/20140423002336_create_tweets.rb
index ca50e509e..40a65062d 100644
--- a/db/migrate/20140423002336_create_tweets.rb
+++ b/db/migrate/20140423002336_create_tweets.rb
@@ -1,4 +1,4 @@
-class CreateTweets < ActiveRecord::Migration
+class CreateTweets < ActiveRecord::Migration[5.0]
def change
create_table :tweets do |t|
t.string :target
diff --git a/db/migrate/20140423002432_add_tweets_to_action_pages.rb b/db/migrate/20140423002432_add_tweets_to_action_pages.rb
index aad68f7f1..70a354c98 100644
--- a/db/migrate/20140423002432_add_tweets_to_action_pages.rb
+++ b/db/migrate/20140423002432_add_tweets_to_action_pages.rb
@@ -1,4 +1,4 @@
-class AddTweetsToActionPages < ActiveRecord::Migration
+class AddTweetsToActionPages < ActiveRecord::Migration[5.0]
def change
add_column :action_pages, :tweet_id, :integer
end
diff --git a/db/migrate/20140423202256_add_cta_to_tweet.rb b/db/migrate/20140423202256_add_cta_to_tweet.rb
index 0bf1f7888..78689b5a1 100644
--- a/db/migrate/20140423202256_add_cta_to_tweet.rb
+++ b/db/migrate/20140423202256_add_cta_to_tweet.rb
@@ -1,4 +1,4 @@
-class AddCtaToTweet < ActiveRecord::Migration
+class AddCtaToTweet < ActiveRecord::Migration[5.0]
def change
add_column :tweets, :cta, :string
end
diff --git a/db/migrate/20140424232842_add_bioguide_id_to_tweets.rb b/db/migrate/20140424232842_add_bioguide_id_to_tweets.rb
index f5a556436..3ea14e8f9 100644
--- a/db/migrate/20140424232842_add_bioguide_id_to_tweets.rb
+++ b/db/migrate/20140424232842_add_bioguide_id_to_tweets.rb
@@ -1,4 +1,4 @@
-class AddBioguideIdToTweets < ActiveRecord::Migration
+class AddBioguideIdToTweets < ActiveRecord::Migration[5.0]
def change
add_column :tweets, :bioguide_id, :string
end
diff --git a/db/migrate/20140425215725_add_target_flags_to_tweets.rb b/db/migrate/20140425215725_add_target_flags_to_tweets.rb
index d0c7d99a5..f69dd0c2e 100644
--- a/db/migrate/20140425215725_add_target_flags_to_tweets.rb
+++ b/db/migrate/20140425215725_add_target_flags_to_tweets.rb
@@ -1,4 +1,4 @@
-class AddTargetFlagsToTweets < ActiveRecord::Migration
+class AddTargetFlagsToTweets < ActiveRecord::Migration[5.0]
def change
add_column :tweets, :target_house, :boolean, default: true
add_column :tweets, :target_senate, :boolean, default: true
diff --git a/db/migrate/20140429015127_add_published_to_action_pages.rb b/db/migrate/20140429015127_add_published_to_action_pages.rb
index d819d70bf..a88bec1e9 100644
--- a/db/migrate/20140429015127_add_published_to_action_pages.rb
+++ b/db/migrate/20140429015127_add_published_to_action_pages.rb
@@ -1,4 +1,4 @@
-class AddPublishedToActionPages < ActiveRecord::Migration
+class AddPublishedToActionPages < ActiveRecord::Migration[5.0]
def change
add_column :action_pages, :published, :boolean, default: false
end
diff --git a/db/migrate/20140430110906_add_type_to_activities.rb b/db/migrate/20140430110906_add_type_to_activities.rb
index cdb77ec7b..de7bd3035 100644
--- a/db/migrate/20140430110906_add_type_to_activities.rb
+++ b/db/migrate/20140430110906_add_type_to_activities.rb
@@ -1,4 +1,4 @@
-class AddTypeToActivities < ActiveRecord::Migration
+class AddTypeToActivities < ActiveRecord::Migration[5.0]
def change
add_column :activities, :action_type, :string
end
diff --git a/db/migrate/20140501160413_create_call_tool_configs.rb b/db/migrate/20140501160413_create_call_tool_configs.rb
index d7ba2b483..89c6f8a13 100644
--- a/db/migrate/20140501160413_create_call_tool_configs.rb
+++ b/db/migrate/20140501160413_create_call_tool_configs.rb
@@ -1,4 +1,4 @@
-class CreateCallToolConfigs < ActiveRecord::Migration
+class CreateCallToolConfigs < ActiveRecord::Migration[5.0]
def change
create_table :call_tool_configs do |t|
diff --git a/db/migrate/20140502162820_add_call_campaign_id_to_action_pages.rb b/db/migrate/20140502162820_add_call_campaign_id_to_action_pages.rb
index ce71b7574..21766002c 100644
--- a/db/migrate/20140502162820_add_call_campaign_id_to_action_pages.rb
+++ b/db/migrate/20140502162820_add_call_campaign_id_to_action_pages.rb
@@ -1,4 +1,4 @@
-class AddCallCampaignIdToActionPages < ActiveRecord::Migration
+class AddCallCampaignIdToActionPages < ActiveRecord::Migration[5.0]
def change
add_column :action_pages, :call_campaign_id, :string
end
diff --git a/db/migrate/20140504080222_add_attachment_featured_image_to_action_pages.rb b/db/migrate/20140504080222_add_attachment_featured_image_to_action_pages.rb
index 0be5afc50..dc3dacef3 100644
--- a/db/migrate/20140504080222_add_attachment_featured_image_to_action_pages.rb
+++ b/db/migrate/20140504080222_add_attachment_featured_image_to_action_pages.rb
@@ -1,4 +1,4 @@
-class AddAttachmentFeaturedImageToActionPages < ActiveRecord::Migration
+class AddAttachmentFeaturedImageToActionPages < ActiveRecord::Migration[5.0]
def self.up
change_table :action_pages do |t|
t.attachment :featured_image
diff --git a/db/migrate/20140505142843_add_what_to_say_to_action_pages.rb b/db/migrate/20140505142843_add_what_to_say_to_action_pages.rb
index 048402d09..01841ea42 100644
--- a/db/migrate/20140505142843_add_what_to_say_to_action_pages.rb
+++ b/db/migrate/20140505142843_add_what_to_say_to_action_pages.rb
@@ -1,4 +1,4 @@
-class AddWhatToSayToActionPages < ActiveRecord::Migration
+class AddWhatToSayToActionPages < ActiveRecord::Migration[5.0]
def change
add_column :action_pages, :what_to_say, :text
end
diff --git a/db/migrate/20140506161533_create_email_campaigns.rb b/db/migrate/20140506161533_create_email_campaigns.rb
index 6b2e7465f..330b48089 100644
--- a/db/migrate/20140506161533_create_email_campaigns.rb
+++ b/db/migrate/20140506161533_create_email_campaigns.rb
@@ -1,4 +1,4 @@
-class CreateEmailCampaigns < ActiveRecord::Migration
+class CreateEmailCampaigns < ActiveRecord::Migration[5.0]
def change
create_table :email_campaigns do |t|
t.text :message
diff --git a/db/migrate/20140506173759_add_email_campaign_id_to_action_pages.rb b/db/migrate/20140506173759_add_email_campaign_id_to_action_pages.rb
index 50836b0bd..26001649b 100644
--- a/db/migrate/20140506173759_add_email_campaign_id_to_action_pages.rb
+++ b/db/migrate/20140506173759_add_email_campaign_id_to_action_pages.rb
@@ -1,4 +1,4 @@
-class AddEmailCampaignIdToActionPages < ActiveRecord::Migration
+class AddEmailCampaignIdToActionPages < ActiveRecord::Migration[5.0]
def change
add_column :action_pages, :email_campaign_id, :integer
end
diff --git a/db/migrate/20140506214830_create_user_preferences.rb b/db/migrate/20140506214830_create_user_preferences.rb
index 94d602632..34fb70cf1 100644
--- a/db/migrate/20140506214830_create_user_preferences.rb
+++ b/db/migrate/20140506214830_create_user_preferences.rb
@@ -1,4 +1,4 @@
-class CreateUserPreferences < ActiveRecord::Migration
+class CreateUserPreferences < ActiveRecord::Migration[5.0]
def change
create_table :user_preferences do |t|
t.integer :user_id, null: false
diff --git a/db/migrate/20140507002622_create_tweet_targets.rb b/db/migrate/20140507002622_create_tweet_targets.rb
index ae4a5056b..bd52f1db5 100644
--- a/db/migrate/20140507002622_create_tweet_targets.rb
+++ b/db/migrate/20140507002622_create_tweet_targets.rb
@@ -1,4 +1,4 @@
-class CreateTweetTargets < ActiveRecord::Migration
+class CreateTweetTargets < ActiveRecord::Migration[5.0]
def change
create_table :tweet_targets do |t|
t.integer :tweet_id, null: false
diff --git a/db/migrate/20140508122428_fix_column_name.rb b/db/migrate/20140508122428_fix_column_name.rb
index 1d69d81cd..a8765ef96 100644
--- a/db/migrate/20140508122428_fix_column_name.rb
+++ b/db/migrate/20140508122428_fix_column_name.rb
@@ -1,4 +1,4 @@
-class FixColumnName < ActiveRecord::Migration
+class FixColumnName < ActiveRecord::Migration[5.0]
def change
rename_column :action_pages, :email_campaign_id, :email_campaigns_id
end
diff --git a/db/migrate/20140509130356_add_subject_to_email_campaigns.rb b/db/migrate/20140509130356_add_subject_to_email_campaigns.rb
index 7d7d897bc..4432031e5 100644
--- a/db/migrate/20140509130356_add_subject_to_email_campaigns.rb
+++ b/db/migrate/20140509130356_add_subject_to_email_campaigns.rb
@@ -1,4 +1,4 @@
-class AddSubjectToEmailCampaigns < ActiveRecord::Migration
+class AddSubjectToEmailCampaigns < ActiveRecord::Migration[5.0]
def change
add_column :email_campaigns, :subject, :string
end
diff --git a/db/migrate/20140509200631_rename_column_enable_share_to_enable_tweet_on_action_pages.rb b/db/migrate/20140509200631_rename_column_enable_share_to_enable_tweet_on_action_pages.rb
index c1dffa460..5cbd836a7 100644
--- a/db/migrate/20140509200631_rename_column_enable_share_to_enable_tweet_on_action_pages.rb
+++ b/db/migrate/20140509200631_rename_column_enable_share_to_enable_tweet_on_action_pages.rb
@@ -1,4 +1,4 @@
-class RenameColumnEnableShareToEnableTweetOnActionPages < ActiveRecord::Migration
+class RenameColumnEnableShareToEnableTweetOnActionPages < ActiveRecord::Migration[5.0]
def change
change_table :action_pages do |t|
t.rename :enable_share, :enable_tweet
diff --git a/db/migrate/20140513164825_create_call_campaigns.rb b/db/migrate/20140513164825_create_call_campaigns.rb
index 48c736543..9fbd261a5 100644
--- a/db/migrate/20140513164825_create_call_campaigns.rb
+++ b/db/migrate/20140513164825_create_call_campaigns.rb
@@ -1,4 +1,4 @@
-class CreateCallCampaigns < ActiveRecord::Migration
+class CreateCallCampaigns < ActiveRecord::Migration[5.0]
def change
create_table :call_campaigns do |t|
diff --git a/db/migrate/20140513165018_change_call_campaign_id.rb b/db/migrate/20140513165018_change_call_campaign_id.rb
index 327c2a253..491e723a7 100644
--- a/db/migrate/20140513165018_change_call_campaign_id.rb
+++ b/db/migrate/20140513165018_change_call_campaign_id.rb
@@ -1,4 +1,4 @@
-class ChangeCallCampaignId < ActiveRecord::Migration
+class ChangeCallCampaignId < ActiveRecord::Migration[5.0]
def change
remove_column :action_pages, :call_campaign_id
add_column :action_pages, :call_campaign_id, :integer
diff --git a/db/migrate/20140513170430_add_data_to_call_campaign.rb b/db/migrate/20140513170430_add_data_to_call_campaign.rb
index 67c7eb59e..36ccda399 100644
--- a/db/migrate/20140513170430_add_data_to_call_campaign.rb
+++ b/db/migrate/20140513170430_add_data_to_call_campaign.rb
@@ -1,4 +1,4 @@
-class AddDataToCallCampaign < ActiveRecord::Migration
+class AddDataToCallCampaign < ActiveRecord::Migration[5.0]
def change
add_column :call_campaigns, :title, :string
add_column :call_campaigns, :message, :text
diff --git a/db/migrate/20140513211548_add_phone_to_users.rb b/db/migrate/20140513211548_add_phone_to_users.rb
index 7f94bae93..75ff77b1d 100644
--- a/db/migrate/20140513211548_add_phone_to_users.rb
+++ b/db/migrate/20140513211548_add_phone_to_users.rb
@@ -1,4 +1,4 @@
-class AddPhoneToUsers < ActiveRecord::Migration
+class AddPhoneToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :phone, :string
end
diff --git a/db/migrate/20140514191109_add_summary_to_action_pages.rb b/db/migrate/20140514191109_add_summary_to_action_pages.rb
index 20b873e51..5587bd0b7 100644
--- a/db/migrate/20140514191109_add_summary_to_action_pages.rb
+++ b/db/migrate/20140514191109_add_summary_to_action_pages.rb
@@ -1,4 +1,4 @@
-class AddSummaryToActionPages < ActiveRecord::Migration
+class AddSummaryToActionPages < ActiveRecord::Migration[5.0]
def change
add_column :action_pages, :summary, :string
end
diff --git a/db/migrate/20140515192334_add_attachment_background_image_to_action_pages.rb b/db/migrate/20140515192334_add_attachment_background_image_to_action_pages.rb
index 76b7505f9..448c2453d 100644
--- a/db/migrate/20140515192334_add_attachment_background_image_to_action_pages.rb
+++ b/db/migrate/20140515192334_add_attachment_background_image_to_action_pages.rb
@@ -1,4 +1,4 @@
-class AddAttachmentBackgroundImageToActionPages < ActiveRecord::Migration
+class AddAttachmentBackgroundImageToActionPages < ActiveRecord::Migration[5.0]
def self.up
change_table :action_pages do |t|
t.attachment :background_image
diff --git a/db/migrate/20140515204831_add_template_and_layout_to_action_pages.rb b/db/migrate/20140515204831_add_template_and_layout_to_action_pages.rb
index fcac78b93..ec78584cd 100644
--- a/db/migrate/20140515204831_add_template_and_layout_to_action_pages.rb
+++ b/db/migrate/20140515204831_add_template_and_layout_to_action_pages.rb
@@ -1,4 +1,4 @@
-class AddTemplateAndLayoutToActionPages < ActiveRecord::Migration
+class AddTemplateAndLayoutToActionPages < ActiveRecord::Migration[5.0]
def change
add_column :action_pages, :template, :string
add_column :action_pages, :layout, :string
diff --git a/db/migrate/20140522234821_add_activity_option_to_users.rb b/db/migrate/20140522234821_add_activity_option_to_users.rb
index db391750d..1026c3286 100644
--- a/db/migrate/20140522234821_add_activity_option_to_users.rb
+++ b/db/migrate/20140522234821_add_activity_option_to_users.rb
@@ -1,4 +1,4 @@
-class AddActivityOptionToUsers < ActiveRecord::Migration
+class AddActivityOptionToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :record_activity, :boolean, default: true
end
diff --git a/db/migrate/20140529051541_add_confirmable_to_devise.rb b/db/migrate/20140529051541_add_confirmable_to_devise.rb
index 29224d69e..9fe852a38 100644
--- a/db/migrate/20140529051541_add_confirmable_to_devise.rb
+++ b/db/migrate/20140529051541_add_confirmable_to_devise.rb
@@ -1,4 +1,4 @@
-class AddConfirmableToDevise < ActiveRecord::Migration
+class AddConfirmableToDevise < ActiveRecord::Migration[5.0]
# Note: You can't use change, as User.update_all with fail in the down migration
def self.up
add_column :users, :confirmation_token, :string
diff --git a/db/migrate/20140529215543_add_og_title_to_action_pages.rb b/db/migrate/20140529215543_add_og_title_to_action_pages.rb
index e72016958..d39bbcdb4 100644
--- a/db/migrate/20140529215543_add_og_title_to_action_pages.rb
+++ b/db/migrate/20140529215543_add_og_title_to_action_pages.rb
@@ -1,4 +1,4 @@
-class AddOgTitleToActionPages < ActiveRecord::Migration
+class AddOgTitleToActionPages < ActiveRecord::Migration[5.0]
def change
add_column :action_pages, :og_title, :string
end
diff --git a/db/migrate/20140529220025_add_og_image_to_action_pages.rb b/db/migrate/20140529220025_add_og_image_to_action_pages.rb
index 9f89fdca7..bef964ffc 100644
--- a/db/migrate/20140529220025_add_og_image_to_action_pages.rb
+++ b/db/migrate/20140529220025_add_og_image_to_action_pages.rb
@@ -1,4 +1,4 @@
-class AddOgImageToActionPages < ActiveRecord::Migration
+class AddOgImageToActionPages < ActiveRecord::Migration[5.0]
def self.up
change_table :action_pages do |t|
t.attachment :og_image
diff --git a/db/migrate/20140530232720_add_targets_to_email_campaigns.rb b/db/migrate/20140530232720_add_targets_to_email_campaigns.rb
index 87fa99074..0b6349be8 100644
--- a/db/migrate/20140530232720_add_targets_to_email_campaigns.rb
+++ b/db/migrate/20140530232720_add_targets_to_email_campaigns.rb
@@ -1,4 +1,4 @@
-class AddTargetsToEmailCampaigns < ActiveRecord::Migration
+class AddTargetsToEmailCampaigns < ActiveRecord::Migration[5.0]
def change
add_column :email_campaigns, :target_house, :boolean, default: true
add_column :email_campaigns, :target_senate, :boolean, default: true
diff --git a/db/migrate/20140531140633_create_source_files.rb b/db/migrate/20140531140633_create_source_files.rb
index ca47a1cce..4c3b3989d 100644
--- a/db/migrate/20140531140633_create_source_files.rb
+++ b/db/migrate/20140531140633_create_source_files.rb
@@ -1,4 +1,4 @@
-class CreateSourceFiles < ActiveRecord::Migration
+class CreateSourceFiles < ActiveRecord::Migration[5.0]
def change
create_table :source_files do |t|
t.string :file_name
diff --git a/db/migrate/20140602020057_change_summary_to_text_blog.rb b/db/migrate/20140602020057_change_summary_to_text_blog.rb
index 45f099011..63026cdcd 100644
--- a/db/migrate/20140602020057_change_summary_to_text_blog.rb
+++ b/db/migrate/20140602020057_change_summary_to_text_blog.rb
@@ -1,4 +1,4 @@
-class ChangeSummaryToTextBlog < ActiveRecord::Migration
+class ChangeSummaryToTextBlog < ActiveRecord::Migration[5.0]
def change
change_column :action_pages, :summary, :text, :limit => nil
end
diff --git a/db/migrate/20140602041107_add_enable_redirect_to_action_pages.rb b/db/migrate/20140602041107_add_enable_redirect_to_action_pages.rb
index c1c519b96..14f3a41b4 100644
--- a/db/migrate/20140602041107_add_enable_redirect_to_action_pages.rb
+++ b/db/migrate/20140602041107_add_enable_redirect_to_action_pages.rb
@@ -1,4 +1,4 @@
-class AddEnableRedirectToActionPages < ActiveRecord::Migration
+class AddEnableRedirectToActionPages < ActiveRecord::Migration[5.0]
def change
add_column :action_pages, :enable_redirect, :boolean, :default=>false
end
diff --git a/db/migrate/20140602041535_add_redirect_url_to_action_pages.rb b/db/migrate/20140602041535_add_redirect_url_to_action_pages.rb
index 22f94159e..706e56503 100644
--- a/db/migrate/20140602041535_add_redirect_url_to_action_pages.rb
+++ b/db/migrate/20140602041535_add_redirect_url_to_action_pages.rb
@@ -1,4 +1,4 @@
-class AddRedirectUrlToActionPages < ActiveRecord::Migration
+class AddRedirectUrlToActionPages < ActiveRecord::Migration[5.0]
def change
add_column :action_pages, :redirect_url, :string
end
diff --git a/db/migrate/20140611015322_add_email_text_to_action_pages.rb b/db/migrate/20140611015322_add_email_text_to_action_pages.rb
index e22cad80d..2ccaf7c6a 100644
--- a/db/migrate/20140611015322_add_email_text_to_action_pages.rb
+++ b/db/migrate/20140611015322_add_email_text_to_action_pages.rb
@@ -1,4 +1,4 @@
-class AddEmailTextToActionPages < ActiveRecord::Migration
+class AddEmailTextToActionPages < ActiveRecord::Migration[5.0]
def change
add_column :action_pages, :email_text, :string
end
diff --git a/db/migrate/20140611030851_change_email_text_to_text.rb b/db/migrate/20140611030851_change_email_text_to_text.rb
index c855d9c31..3017fcfc7 100644
--- a/db/migrate/20140611030851_change_email_text_to_text.rb
+++ b/db/migrate/20140611030851_change_email_text_to_text.rb
@@ -1,4 +1,4 @@
-class ChangeEmailTextToText < ActiveRecord::Migration
+class ChangeEmailTextToText < ActiveRecord::Migration[5.0]
def up
change_column :action_pages, :email_text, :text
end
diff --git a/db/migrate/20140611190909_add_missing_indexes.rb b/db/migrate/20140611190909_add_missing_indexes.rb
index 308a51ef7..aef068567 100644
--- a/db/migrate/20140611190909_add_missing_indexes.rb
+++ b/db/migrate/20140611190909_add_missing_indexes.rb
@@ -1,4 +1,4 @@
-class AddMissingIndexes < ActiveRecord::Migration
+class AddMissingIndexes < ActiveRecord::Migration[5.0]
def change
add_index :activities, :user_id
add_index :activities, :action_page_id
diff --git a/db/migrate/20140613203758_add_contact_id_to_users.rb b/db/migrate/20140613203758_add_contact_id_to_users.rb
index b7c5a441d..481d55bb9 100644
--- a/db/migrate/20140613203758_add_contact_id_to_users.rb
+++ b/db/migrate/20140613203758_add_contact_id_to_users.rb
@@ -1,4 +1,4 @@
-class AddContactIdToUsers < ActiveRecord::Migration
+class AddContactIdToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :contact_id, :integer
end
diff --git a/db/migrate/20140616203409_add_subscribe_to_users.rb b/db/migrate/20140616203409_add_subscribe_to_users.rb
index a0c54fc61..2d85249ad 100644
--- a/db/migrate/20140616203409_add_subscribe_to_users.rb
+++ b/db/migrate/20140616203409_add_subscribe_to_users.rb
@@ -1,4 +1,4 @@
-class AddSubscribeToUsers < ActiveRecord::Migration
+class AddSubscribeToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :subscribe, :boolean, default: true
end
diff --git a/db/migrate/20140623235101_create_partners.rb b/db/migrate/20140623235101_create_partners.rb
index 3b30d8bb7..0fa765704 100644
--- a/db/migrate/20140623235101_create_partners.rb
+++ b/db/migrate/20140623235101_create_partners.rb
@@ -1,4 +1,4 @@
-class CreatePartners < ActiveRecord::Migration
+class CreatePartners < ActiveRecord::Migration[5.0]
def change
create_table :partners do |t|
t.string :code
diff --git a/db/migrate/20140624000606_create_subscriptions.rb b/db/migrate/20140624000606_create_subscriptions.rb
index 1d084af7e..ceb4f53de 100644
--- a/db/migrate/20140624000606_create_subscriptions.rb
+++ b/db/migrate/20140624000606_create_subscriptions.rb
@@ -1,4 +1,4 @@
-class CreateSubscriptions < ActiveRecord::Migration
+class CreateSubscriptions < ActiveRecord::Migration[5.0]
def change
create_table :subscriptions do |t|
t.string :first_name
diff --git a/db/migrate/20140626191214_add_image_to_tweet_targets.rb b/db/migrate/20140626191214_add_image_to_tweet_targets.rb
index 0cf96d489..337e9b232 100644
--- a/db/migrate/20140626191214_add_image_to_tweet_targets.rb
+++ b/db/migrate/20140626191214_add_image_to_tweet_targets.rb
@@ -1,4 +1,4 @@
-class AddImageToTweetTargets < ActiveRecord::Migration
+class AddImageToTweetTargets < ActiveRecord::Migration[5.0]
def self.up
add_attachment :tweet_targets, :image
end
diff --git a/db/migrate/20140702113432_create_visits.rb b/db/migrate/20140702113432_create_visits.rb
index 4da9a5a23..36d52cf09 100644
--- a/db/migrate/20140702113432_create_visits.rb
+++ b/db/migrate/20140702113432_create_visits.rb
@@ -1,4 +1,4 @@
-class CreateVisits < ActiveRecord::Migration
+class CreateVisits < ActiveRecord::Migration[5.0]
def change
create_table :visits, id: false do |t|
t.uuid :id, primary_key: true, default: 'uuid_generate_v4()'
diff --git a/db/migrate/20140702113433_create_ahoy_events.rb b/db/migrate/20140702113433_create_ahoy_events.rb
index c488dbfcf..946b18910 100644
--- a/db/migrate/20140702113433_create_ahoy_events.rb
+++ b/db/migrate/20140702113433_create_ahoy_events.rb
@@ -1,4 +1,4 @@
-class CreateAhoyEvents < ActiveRecord::Migration
+class CreateAhoyEvents < ActiveRecord::Migration[5.0]
def change
create_table :ahoy_events, id: false do |t|
t.uuid :id, primary_key: true, default: 'uuid_generate_v4()'
diff --git a/db/migrate/20140703200958_add_victory_to_action_pages.rb b/db/migrate/20140703200958_add_victory_to_action_pages.rb
index a7e686562..e859b60d6 100644
--- a/db/migrate/20140703200958_add_victory_to_action_pages.rb
+++ b/db/migrate/20140703200958_add_victory_to_action_pages.rb
@@ -1,4 +1,4 @@
-class AddVictoryToActionPages < ActiveRecord::Migration
+class AddVictoryToActionPages < ActiveRecord::Migration[5.0]
def change
add_column :action_pages, :victory, :boolean, default: false
add_column :action_pages, :victory_message, :text
diff --git a/db/migrate/20140703211713_add_parnters_to_users.rb b/db/migrate/20140703211713_add_parnters_to_users.rb
index ca1e5d0e0..0ff4ae3c1 100644
--- a/db/migrate/20140703211713_add_parnters_to_users.rb
+++ b/db/migrate/20140703211713_add_parnters_to_users.rb
@@ -1,4 +1,4 @@
-class AddParntersToUsers < ActiveRecord::Migration
+class AddParntersToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :partner_id, :integer
end
diff --git a/db/migrate/20140805020122_add_unconfirmed_email_to_users.rb b/db/migrate/20140805020122_add_unconfirmed_email_to_users.rb
index 6dcb7eea1..95c3b05d0 100644
--- a/db/migrate/20140805020122_add_unconfirmed_email_to_users.rb
+++ b/db/migrate/20140805020122_add_unconfirmed_email_to_users.rb
@@ -1,4 +1,4 @@
-class AddUnconfirmedEmailToUsers < ActiveRecord::Migration
+class AddUnconfirmedEmailToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :unconfirmed_email, :string
end
diff --git a/db/migrate/20140808233806_create_topic_category.rb b/db/migrate/20140808233806_create_topic_category.rb
index 2a7e4c477..fa84e4a3a 100644
--- a/db/migrate/20140808233806_create_topic_category.rb
+++ b/db/migrate/20140808233806_create_topic_category.rb
@@ -1,4 +1,4 @@
-class CreateTopicCategory < ActiveRecord::Migration
+class CreateTopicCategory < ActiveRecord::Migration[5.0]
def change
create_table :topic_categories do |t|
t.string :name
diff --git a/db/migrate/20140808233946_create_topic_set.rb b/db/migrate/20140808233946_create_topic_set.rb
index 79a9e645f..df6e04373 100644
--- a/db/migrate/20140808233946_create_topic_set.rb
+++ b/db/migrate/20140808233946_create_topic_set.rb
@@ -1,4 +1,4 @@
-class CreateTopicSet < ActiveRecord::Migration
+class CreateTopicSet < ActiveRecord::Migration[5.0]
def change
create_table :topic_sets do |t|
t.integer :tier
diff --git a/db/migrate/20140808234311_create_topic.rb b/db/migrate/20140808234311_create_topic.rb
index 5eec51d22..4bcd2ec2e 100644
--- a/db/migrate/20140808234311_create_topic.rb
+++ b/db/migrate/20140808234311_create_topic.rb
@@ -1,4 +1,4 @@
-class CreateTopic < ActiveRecord::Migration
+class CreateTopic < ActiveRecord::Migration[5.0]
def change
create_table :topics do |t|
t.string :name
diff --git a/db/migrate/20140811233646_rename_action_pages_email_campaigns_id.rb b/db/migrate/20140811233646_rename_action_pages_email_campaigns_id.rb
index 65c515ff0..ee08cf685 100644
--- a/db/migrate/20140811233646_rename_action_pages_email_campaigns_id.rb
+++ b/db/migrate/20140811233646_rename_action_pages_email_campaigns_id.rb
@@ -1,4 +1,4 @@
-class RenameActionPagesEmailCampaignsId < ActiveRecord::Migration
+class RenameActionPagesEmailCampaignsId < ActiveRecord::Migration[5.0]
def change
rename_column :action_pages, :email_campaigns_id, :email_campaign_id
end
diff --git a/db/migrate/20140819182202_add_topic_category_id_to_email_campaigns.rb b/db/migrate/20140819182202_add_topic_category_id_to_email_campaigns.rb
index ea4a5d6c5..978a81302 100644
--- a/db/migrate/20140819182202_add_topic_category_id_to_email_campaigns.rb
+++ b/db/migrate/20140819182202_add_topic_category_id_to_email_campaigns.rb
@@ -1,4 +1,4 @@
-class AddTopicCategoryIdToEmailCampaigns < ActiveRecord::Migration
+class AddTopicCategoryIdToEmailCampaigns < ActiveRecord::Migration[5.0]
def change
add_column :email_campaigns, :topic_category_id, :integer
end
diff --git a/db/migrate/20140820002514_add_action_page_id_to_ahoy_events.rb b/db/migrate/20140820002514_add_action_page_id_to_ahoy_events.rb
index 296f64584..0368f082d 100644
--- a/db/migrate/20140820002514_add_action_page_id_to_ahoy_events.rb
+++ b/db/migrate/20140820002514_add_action_page_id_to_ahoy_events.rb
@@ -1,4 +1,4 @@
-class AddActionPageIdToAhoyEvents < ActiveRecord::Migration
+class AddActionPageIdToAhoyEvents < ActiveRecord::Migration[5.0]
def change
add_column :ahoy_events, :action_page_id, :integer
end
diff --git a/db/migrate/20140820021820_add_index_on_action_page_id_to_events.rb b/db/migrate/20140820021820_add_index_on_action_page_id_to_events.rb
index b8c4975fd..0f4472515 100644
--- a/db/migrate/20140820021820_add_index_on_action_page_id_to_events.rb
+++ b/db/migrate/20140820021820_add_index_on_action_page_id_to_events.rb
@@ -1,4 +1,4 @@
-class AddIndexOnActionPageIdToEvents < ActiveRecord::Migration
+class AddIndexOnActionPageIdToEvents < ActiveRecord::Migration[5.0]
def change
add_index :ahoy_events, :action_page_id
end
diff --git a/db/migrate/20140820223448_create_congress_scorecards.rb b/db/migrate/20140820223448_create_congress_scorecards.rb
index 02c8f3e8a..69e302d06 100644
--- a/db/migrate/20140820223448_create_congress_scorecards.rb
+++ b/db/migrate/20140820223448_create_congress_scorecards.rb
@@ -1,4 +1,4 @@
-class CreateCongressScorecards < ActiveRecord::Migration
+class CreateCongressScorecards < ActiveRecord::Migration[5.0]
def change
create_table :congress_scorecards do |t|
t.string :bioguide_id, required: true
diff --git a/db/migrate/20140905205137_add_partner_id_to_action_pages.rb b/db/migrate/20140905205137_add_partner_id_to_action_pages.rb
index e982c3a22..f18eca026 100644
--- a/db/migrate/20140905205137_add_partner_id_to_action_pages.rb
+++ b/db/migrate/20140905205137_add_partner_id_to_action_pages.rb
@@ -1,4 +1,4 @@
-class AddPartnerIdToActionPages < ActiveRecord::Migration
+class AddPartnerIdToActionPages < ActiveRecord::Migration[5.0]
def change
add_column :action_pages, :partner_id, :integer
end
diff --git a/db/migrate/20140911224314_add_campaign_tag_to_email_campaigns.rb b/db/migrate/20140911224314_add_campaign_tag_to_email_campaigns.rb
index 375f86c2d..adb677083 100644
--- a/db/migrate/20140911224314_add_campaign_tag_to_email_campaigns.rb
+++ b/db/migrate/20140911224314_add_campaign_tag_to_email_campaigns.rb
@@ -1,4 +1,4 @@
-class AddCampaignTagToEmailCampaigns < ActiveRecord::Migration
+class AddCampaignTagToEmailCampaigns < ActiveRecord::Migration[5.0]
def change
add_column :email_campaigns, :campaign_tag, :string
end
diff --git a/db/migrate/20140922235029_add_archived_to_action_pages.rb b/db/migrate/20140922235029_add_archived_to_action_pages.rb
index 326bf5af1..7eb6090ed 100644
--- a/db/migrate/20140922235029_add_archived_to_action_pages.rb
+++ b/db/migrate/20140922235029_add_archived_to_action_pages.rb
@@ -1,4 +1,4 @@
-class AddArchivedToActionPages < ActiveRecord::Migration
+class AddArchivedToActionPages < ActiveRecord::Migration[5.0]
def change
add_column :action_pages, :archived, :boolean, default: false
add_column :action_pages, :redirect_action_page_id, :integer
diff --git a/db/migrate/20140924174611_add_deleted_at_to_partners.rb b/db/migrate/20140924174611_add_deleted_at_to_partners.rb
index 306531c00..4e4f2d6b0 100644
--- a/db/migrate/20140924174611_add_deleted_at_to_partners.rb
+++ b/db/migrate/20140924174611_add_deleted_at_to_partners.rb
@@ -1,4 +1,4 @@
-class AddDeletedAtToPartners < ActiveRecord::Migration
+class AddDeletedAtToPartners < ActiveRecord::Migration[5.0]
def change
add_column :partners, :deleted_at, :time
end
diff --git a/db/migrate/20140930223312_rename_redirect_action_page_id.rb b/db/migrate/20140930223312_rename_redirect_action_page_id.rb
index cb6fd9b54..91d08d8e2 100644
--- a/db/migrate/20140930223312_rename_redirect_action_page_id.rb
+++ b/db/migrate/20140930223312_rename_redirect_action_page_id.rb
@@ -1,4 +1,4 @@
-class RenameRedirectActionPageId < ActiveRecord::Migration
+class RenameRedirectActionPageId < ActiveRecord::Migration[5.0]
def change
rename_column :action_pages, :redirect_action_page_id, :archived_redirect_action_page_id
end
diff --git a/db/migrate/20141006223048_remove_activities_table.rb b/db/migrate/20141006223048_remove_activities_table.rb
index 40a65eadf..89065b2f1 100644
--- a/db/migrate/20141006223048_remove_activities_table.rb
+++ b/db/migrate/20141006223048_remove_activities_table.rb
@@ -1,4 +1,4 @@
-class RemoveActivitiesTable < ActiveRecord::Migration
+class RemoveActivitiesTable < ActiveRecord::Migration[5.0]
def change
drop_table :activities
end
diff --git a/db/migrate/20141009185436_add_email_addresses_and_target_email_to_email_campaigns.rb b/db/migrate/20141009185436_add_email_addresses_and_target_email_to_email_campaigns.rb
index 10795ed67..bc15cea17 100644
--- a/db/migrate/20141009185436_add_email_addresses_and_target_email_to_email_campaigns.rb
+++ b/db/migrate/20141009185436_add_email_addresses_and_target_email_to_email_campaigns.rb
@@ -1,4 +1,4 @@
-class AddEmailAddressesAndTargetEmailToEmailCampaigns < ActiveRecord::Migration
+class AddEmailAddressesAndTargetEmailToEmailCampaigns < ActiveRecord::Migration[5.0]
def change
add_column :email_campaigns, :email_addresses, :string
add_column :email_campaigns, :target_email, :boolean
diff --git a/db/migrate/20150108212457_add_target_bioguide_id_to_email_campaigns.rb b/db/migrate/20150108212457_add_target_bioguide_id_to_email_campaigns.rb
index f7ca45b83..a765ba756 100644
--- a/db/migrate/20150108212457_add_target_bioguide_id_to_email_campaigns.rb
+++ b/db/migrate/20150108212457_add_target_bioguide_id_to_email_campaigns.rb
@@ -1,4 +1,4 @@
-class AddTargetBioguideIdToEmailCampaigns < ActiveRecord::Migration
+class AddTargetBioguideIdToEmailCampaigns < ActiveRecord::Migration[5.0]
def change
add_column :email_campaigns, :target_bioguide_id, :boolean, default: false
add_column :email_campaigns, :bioguide_id, :string
diff --git a/db/migrate/20150110042803_add_alt_text_fields_to_email_campaign.rb b/db/migrate/20150110042803_add_alt_text_fields_to_email_campaign.rb
index 1dc4cb5a2..b0a379d67 100644
--- a/db/migrate/20150110042803_add_alt_text_fields_to_email_campaign.rb
+++ b/db/migrate/20150110042803_add_alt_text_fields_to_email_campaign.rb
@@ -1,4 +1,4 @@
-class AddAltTextFieldsToEmailCampaign < ActiveRecord::Migration
+class AddAltTextFieldsToEmailCampaign < ActiveRecord::Migration[5.0]
def change
add_column :email_campaigns, :alt_text_email_your_rep, :string
add_column :email_campaigns, :alt_text_look_up_your_rep, :string
diff --git a/db/migrate/20150113014921_add_more_alt_text_fields_to_email_campaign.rb b/db/migrate/20150113014921_add_more_alt_text_fields_to_email_campaign.rb
index 293621dae..57bafbf3a 100644
--- a/db/migrate/20150113014921_add_more_alt_text_fields_to_email_campaign.rb
+++ b/db/migrate/20150113014921_add_more_alt_text_fields_to_email_campaign.rb
@@ -1,4 +1,4 @@
-class AddMoreAltTextFieldsToEmailCampaign < ActiveRecord::Migration
+class AddMoreAltTextFieldsToEmailCampaign < ActiveRecord::Migration[5.0]
def change
add_column :email_campaigns, :alt_text_look_up_helper, :string
add_column :email_campaigns, :alt_text_customize_message_helper, :string
diff --git a/db/migrate/20150123194715_create_delayed_jobs.rb b/db/migrate/20150123194715_create_delayed_jobs.rb
index 27fdcf6cc..130a8d570 100644
--- a/db/migrate/20150123194715_create_delayed_jobs.rb
+++ b/db/migrate/20150123194715_create_delayed_jobs.rb
@@ -1,4 +1,4 @@
-class CreateDelayedJobs < ActiveRecord::Migration
+class CreateDelayedJobs < ActiveRecord::Migration[5.0]
def self.up
create_table :delayed_jobs, force: true do |table|
table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue
diff --git a/db/migrate/20150625230944_create_bounces.rb b/db/migrate/20150625230944_create_bounces.rb
index e1aeb1995..f5f86ab65 100644
--- a/db/migrate/20150625230944_create_bounces.rb
+++ b/db/migrate/20150625230944_create_bounces.rb
@@ -1,4 +1,4 @@
-class CreateBounces < ActiveRecord::Migration
+class CreateBounces < ActiveRecord::Migration[5.0]
def change
create_table :bounces do |t|
t.string :email
diff --git a/db/migrate/20151026192811_add_lockable_to_users.rb b/db/migrate/20151026192811_add_lockable_to_users.rb
index f1f006645..fb71adba6 100644
--- a/db/migrate/20151026192811_add_lockable_to_users.rb
+++ b/db/migrate/20151026192811_add_lockable_to_users.rb
@@ -1,4 +1,4 @@
-class AddLockableToUsers < ActiveRecord::Migration
+class AddLockableToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :failed_attempts, :integer, default: 0
add_column :users, :unlock_token, :string
diff --git a/db/migrate/20151211200545_remove_call_tool_configs.rb b/db/migrate/20151211200545_remove_call_tool_configs.rb
index 0d8c7e77e..f9bb30999 100644
--- a/db/migrate/20151211200545_remove_call_tool_configs.rb
+++ b/db/migrate/20151211200545_remove_call_tool_configs.rb
@@ -1,4 +1,4 @@
-class RemoveCallToolConfigs < ActiveRecord::Migration
+class RemoveCallToolConfigs < ActiveRecord::Migration[5.0]
def change
drop_table :call_tool_configs
end
diff --git a/db/migrate/20151212031318_add_password_expired_to_users.rb b/db/migrate/20151212031318_add_password_expired_to_users.rb
index 7dd6e8f63..3a01ee3a2 100644
--- a/db/migrate/20151212031318_add_password_expired_to_users.rb
+++ b/db/migrate/20151212031318_add_password_expired_to_users.rb
@@ -1,4 +1,4 @@
-class AddPasswordExpiredToUsers < ActiveRecord::Migration
+class AddPasswordExpiredToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :password_expired, :boolean
end
diff --git a/db/migrate/20160107220954_remove_url_from_source_files.rb b/db/migrate/20160107220954_remove_url_from_source_files.rb
index 187bc2c19..410a3ea28 100644
--- a/db/migrate/20160107220954_remove_url_from_source_files.rb
+++ b/db/migrate/20160107220954_remove_url_from_source_files.rb
@@ -1,4 +1,4 @@
-class RemoveUrlFromSourceFiles < ActiveRecord::Migration
+class RemoveUrlFromSourceFiles < ActiveRecord::Migration[5.0]
def change
remove_column :source_files, :url, :string
end
diff --git a/db/migrate/20160520212818_add_show_all_signatures_to_petition.rb b/db/migrate/20160520212818_add_show_all_signatures_to_petition.rb
index aebeeffdf..705e312ca 100644
--- a/db/migrate/20160520212818_add_show_all_signatures_to_petition.rb
+++ b/db/migrate/20160520212818_add_show_all_signatures_to_petition.rb
@@ -1,4 +1,4 @@
-class AddShowAllSignaturesToPetition < ActiveRecord::Migration
+class AddShowAllSignaturesToPetition < ActiveRecord::Migration[5.0]
def change
add_column :petitions, :show_all_signatures, :boolean, default: false
end
diff --git a/db/migrate/20160601003317_create_institution_sets.rb b/db/migrate/20160601003317_create_institution_sets.rb
index 9ee61fbad..d00c9bc71 100644
--- a/db/migrate/20160601003317_create_institution_sets.rb
+++ b/db/migrate/20160601003317_create_institution_sets.rb
@@ -1,4 +1,4 @@
-class CreateInstitutionSets < ActiveRecord::Migration
+class CreateInstitutionSets < ActiveRecord::Migration[5.0]
def change
create_table :institution_sets do |t|
t.string :name
diff --git a/db/migrate/20160606202236_create_institutions.rb b/db/migrate/20160606202236_create_institutions.rb
index a8447c1f3..ab576418f 100644
--- a/db/migrate/20160606202236_create_institutions.rb
+++ b/db/migrate/20160606202236_create_institutions.rb
@@ -1,4 +1,4 @@
-class CreateInstitutions < ActiveRecord::Migration
+class CreateInstitutions < ActiveRecord::Migration[5.0]
def change
create_table :institutions do |t|
t.string :name
diff --git a/db/migrate/20160606222456_add_enable_affiliations_to_petitions.rb b/db/migrate/20160606222456_add_enable_affiliations_to_petitions.rb
index 7b357d44b..aafa9d242 100644
--- a/db/migrate/20160606222456_add_enable_affiliations_to_petitions.rb
+++ b/db/migrate/20160606222456_add_enable_affiliations_to_petitions.rb
@@ -1,4 +1,4 @@
-class AddEnableAffiliationsToPetitions < ActiveRecord::Migration
+class AddEnableAffiliationsToPetitions < ActiveRecord::Migration[5.0]
def change
add_column :petitions, :enable_affiliations, :boolean, default: false
add_column :petitions, :institution_set_id, :integer
diff --git a/db/migrate/20160610205339_create_action_allowed_institutions.rb b/db/migrate/20160610205339_create_action_allowed_institutions.rb
index 6fcafe5c5..fd43d414a 100644
--- a/db/migrate/20160610205339_create_action_allowed_institutions.rb
+++ b/db/migrate/20160610205339_create_action_allowed_institutions.rb
@@ -1,4 +1,4 @@
-class CreateActionAllowedInstitutions < ActiveRecord::Migration
+class CreateActionAllowedInstitutions < ActiveRecord::Migration[5.0]
def change
remove_column :institutions, :institution_set_id, :integer
remove_column :petitions, :institution_set_id, :integer
diff --git a/db/migrate/20160616000020_create_affiliations.rb b/db/migrate/20160616000020_create_affiliations.rb
index e0db95f34..8fe0e8a48 100644
--- a/db/migrate/20160616000020_create_affiliations.rb
+++ b/db/migrate/20160616000020_create_affiliations.rb
@@ -1,4 +1,4 @@
-class CreateAffiliations < ActiveRecord::Migration
+class CreateAffiliations < ActiveRecord::Migration[5.0]
def change
create_table :affiliations do |t|
t.string :name
diff --git a/db/migrate/20160629191322_create_affiliation_types.rb b/db/migrate/20160629191322_create_affiliation_types.rb
index 451eec67b..e916b4050 100644
--- a/db/migrate/20160629191322_create_affiliation_types.rb
+++ b/db/migrate/20160629191322_create_affiliation_types.rb
@@ -1,4 +1,4 @@
-class CreateAffiliationTypes < ActiveRecord::Migration
+class CreateAffiliationTypes < ActiveRecord::Migration[5.0]
def change
create_table :affiliation_types do |t|
t.string :name
diff --git a/db/migrate/20160718225646_add_slug_to_institution.rb b/db/migrate/20160718225646_add_slug_to_institution.rb
index 2a7ee1266..45b1a6527 100644
--- a/db/migrate/20160718225646_add_slug_to_institution.rb
+++ b/db/migrate/20160718225646_add_slug_to_institution.rb
@@ -1,4 +1,4 @@
-class AddSlugToInstitution < ActiveRecord::Migration
+class AddSlugToInstitution < ActiveRecord::Migration[5.0]
def change
add_column :institutions, :slug, :string
add_index :institutions, :slug, unique: true
diff --git a/db/migrate/20160719204420_remove_show_all_signatures_from_petition.rb b/db/migrate/20160719204420_remove_show_all_signatures_from_petition.rb
index edc0b98bb..6bbd5f5dc 100644
--- a/db/migrate/20160719204420_remove_show_all_signatures_from_petition.rb
+++ b/db/migrate/20160719204420_remove_show_all_signatures_from_petition.rb
@@ -1,4 +1,4 @@
-class RemoveShowAllSignaturesFromPetition < ActiveRecord::Migration
+class RemoveShowAllSignaturesFromPetition < ActiveRecord::Migration[5.0]
def change
remove_column :petitions, :show_all_signatures, :boolean, default: false
end
diff --git a/db/migrate/20160908225616_add_subscriptions_count_to_partners.rb b/db/migrate/20160908225616_add_subscriptions_count_to_partners.rb
index 04dc3e36c..c88d35803 100644
--- a/db/migrate/20160908225616_add_subscriptions_count_to_partners.rb
+++ b/db/migrate/20160908225616_add_subscriptions_count_to_partners.rb
@@ -1,4 +1,4 @@
-class AddSubscriptionsCountToPartners < ActiveRecord::Migration
+class AddSubscriptionsCountToPartners < ActiveRecord::Migration[5.0]
def up
add_column :partners, :subscriptions_count, :integer, null: false, default: 0
diff --git a/db/migrate/20161011172943_add_issue_to_action_pages.rb b/db/migrate/20161011172943_add_issue_to_action_pages.rb
index a40bf78ce..a0a071130 100644
--- a/db/migrate/20161011172943_add_issue_to_action_pages.rb
+++ b/db/migrate/20161011172943_add_issue_to_action_pages.rb
@@ -1,4 +1,4 @@
-class AddIssueToActionPages < ActiveRecord::Migration
+class AddIssueToActionPages < ActiveRecord::Migration[5.0]
def change
add_column :action_pages, :issue, :string
end
diff --git a/db/migrate/20161017180108_rename_action_pages_issue_to_action_pages_category.rb b/db/migrate/20161017180108_rename_action_pages_issue_to_action_pages_category.rb
index a525b2ac7..0653b9afa 100644
--- a/db/migrate/20161017180108_rename_action_pages_issue_to_action_pages_category.rb
+++ b/db/migrate/20161017180108_rename_action_pages_issue_to_action_pages_category.rb
@@ -1,4 +1,4 @@
-class RenameActionPagesIssueToActionPagesCategory < ActiveRecord::Migration
+class RenameActionPagesIssueToActionPagesCategory < ActiveRecord::Migration[5.0]
def change
rename_column :action_pages, :issue, :category
end
diff --git a/db/migrate/20161017233304_create_categories.rb b/db/migrate/20161017233304_create_categories.rb
index 9167ebb74..854d5bddc 100644
--- a/db/migrate/20161017233304_create_categories.rb
+++ b/db/migrate/20161017233304_create_categories.rb
@@ -1,4 +1,4 @@
-class CreateCategories < ActiveRecord::Migration
+class CreateCategories < ActiveRecord::Migration[5.0]
def change
create_table :categories do |t|
t.string :title, null: false
diff --git a/db/migrate/20161017233352_add_category_id_to_action_pages.rb b/db/migrate/20161017233352_add_category_id_to_action_pages.rb
index fbe80e580..21fd8a130 100644
--- a/db/migrate/20161017233352_add_category_id_to_action_pages.rb
+++ b/db/migrate/20161017233352_add_category_id_to_action_pages.rb
@@ -1,4 +1,4 @@
-class AddCategoryIdToActionPages < ActiveRecord::Migration
+class AddCategoryIdToActionPages < ActiveRecord::Migration[5.0]
def change
add_column :action_pages, :category_id, :integer
remove_column :action_pages, :category
diff --git a/db/migrate/20161018212449_create_congress_members.rb b/db/migrate/20161018212449_create_congress_members.rb
index 1d4bf9d97..11debb704 100644
--- a/db/migrate/20161018212449_create_congress_members.rb
+++ b/db/migrate/20161018212449_create_congress_members.rb
@@ -1,4 +1,4 @@
-class CreateCongressMembers < ActiveRecord::Migration
+class CreateCongressMembers < ActiveRecord::Migration[5.0]
def change
create_table :congress_members do |t|
t.string :full_name, null: false
diff --git a/db/migrate/20161025215124_add_collaborator_to_users.rb b/db/migrate/20161025215124_add_collaborator_to_users.rb
index 441bcb66c..05ee133fc 100644
--- a/db/migrate/20161025215124_add_collaborator_to_users.rb
+++ b/db/migrate/20161025215124_add_collaborator_to_users.rb
@@ -1,4 +1,4 @@
-class AddCollaboratorToUsers < ActiveRecord::Migration
+class AddCollaboratorToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :collaborator, :boolean, null: false, default: false
end
diff --git a/db/migrate/20161109191337_create_congress_message_campaigns.rb b/db/migrate/20161109191337_create_congress_message_campaigns.rb
index 43dc4a3b7..c459a0d02 100644
--- a/db/migrate/20161109191337_create_congress_message_campaigns.rb
+++ b/db/migrate/20161109191337_create_congress_message_campaigns.rb
@@ -1,4 +1,4 @@
-class CreateCongressMessageCampaigns < ActiveRecord::Migration
+class CreateCongressMessageCampaigns < ActiveRecord::Migration[5.0]
class CongressMessageCampaign < ActiveRecord::Base
has_one :action_page
end
diff --git a/db/migrate/20170721170625_create_complaints.rb b/db/migrate/20170721170625_create_complaints.rb
index affdfe15e..ae1e9981a 100644
--- a/db/migrate/20170721170625_create_complaints.rb
+++ b/db/migrate/20170721170625_create_complaints.rb
@@ -1,4 +1,4 @@
-class CreateComplaints < ActiveRecord::Migration
+class CreateComplaints < ActiveRecord::Migration[5.0]
def change
create_table :complaints do |t|
t.string :email
diff --git a/db/migrate/20170831214704_create_partnerships.rb b/db/migrate/20170831214704_create_partnerships.rb
index bd6e819bb..53985b739 100644
--- a/db/migrate/20170831214704_create_partnerships.rb
+++ b/db/migrate/20170831214704_create_partnerships.rb
@@ -1,4 +1,4 @@
-class CreatePartnerships < ActiveRecord::Migration
+class CreatePartnerships < ActiveRecord::Migration[5.0]
def up
create_table :partnerships do |t|
t.belongs_to :action_page, index: true
diff --git a/db/migrate/20180124013711_add_sessions_table.rb b/db/migrate/20180124013711_add_sessions_table.rb
index e0b41c7d7..4ebe4f6ea 100644
--- a/db/migrate/20180124013711_add_sessions_table.rb
+++ b/db/migrate/20180124013711_add_sessions_table.rb
@@ -1,4 +1,4 @@
-class AddSessionsTable < ActiveRecord::Migration
+class AddSessionsTable < ActiveRecord::Migration[5.0]
def change
create_table :sessions do |t|
t.string :session_id, :null => false
diff --git a/db/migrate/20180516215539_change_subscription_defaults.rb b/db/migrate/20180516215539_change_subscription_defaults.rb
index c6f6370f6..df1c71d96 100644
--- a/db/migrate/20180516215539_change_subscription_defaults.rb
+++ b/db/migrate/20180516215539_change_subscription_defaults.rb
@@ -1,4 +1,4 @@
-class ChangeSubscriptionDefaults < ActiveRecord::Migration
+class ChangeSubscriptionDefaults < ActiveRecord::Migration[5.0]
def up
change_column :users, :subscribe, :boolean, default: false
change_column :users, :record_activity, :boolean, default: false
diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh
index 19fae2f96..95b447ae3 100755
--- a/docker/entrypoint.sh
+++ b/docker/entrypoint.sh
@@ -10,7 +10,9 @@ if [ "$TEST_DB_AUTO_MIGRATE" == "true" ]; then
fi
# host ip needed by application for better_errors whitelisting to work
-export HOST_IP=`/sbin/ip route|awk '/default/ { print $3 }'`
+if [ "$RAILS_ENV" == "development" ]; then
+ export HOST_IP=`/sbin/ip route|awk '/default/ { print $3 }'`
+fi
printenv | sed "s/^\([[:alnum:]_]*\)=\(.*\)$/export \1='\2'/" >/var/www/.profile
diff --git a/features/step_definitions/action_page_steps.rb b/features/step_definitions/action_page_steps.rb
index fc0969dfa..fe1045692 100644
--- a/features/step_definitions/action_page_steps.rb
+++ b/features/step_definitions/action_page_steps.rb
@@ -1,6 +1,6 @@
Given(/^a congress message campaign exists$/) do
stub_legislators
- @action_page = FactoryGirl.create(:action_page_with_congress_message)
+ @action_page = FactoryBot.create(:action_page_with_congress_message)
end
When(/^I browse to an embedded action targetting Nancy Pelosi and Kamala Harris$/) do
@@ -49,7 +49,7 @@
end
Given(/^a petition action exists$/) do
- @action_page = FactoryGirl.create(:petition).action_page
+ @action_page = FactoryBot.create(:petition).action_page
end
Given(/^local affiliations are allowed$/) do
@@ -58,13 +58,13 @@
end
Given(/^a local organizing campaign/) do
- @action_page = FactoryGirl.create(:local_organizing_petition).action_page
+ @action_page = FactoryBot.create(:local_organizing_petition).action_page
end
Given(/^the petition has 100 signatures with affiliations/) do
100.times {
- signature = FactoryGirl.create(:signature, petition: @action_page.petition)
- signature.affiliations << FactoryGirl.create(:affiliation, institution: @action_page.institutions.first)
+ signature = FactoryBot.create(:signature, petition: @action_page.petition)
+ signature.affiliations << FactoryBot.create(:affiliation, institution: @action_page.institutions.first)
}
end
diff --git a/features/step_definitions/active_record_steps.rb b/features/step_definitions/active_record_steps.rb
index f1baf8f42..fd52b45f5 100644
--- a/features/step_definitions/active_record_steps.rb
+++ b/features/step_definitions/active_record_steps.rb
@@ -1,4 +1,3 @@
-
When /^there is a persisted ([\w:]+)$/ do |model|
@persisted_records ||= []
@persisted_records << Kernel.const_get(model).create!
diff --git a/features/step_definitions/admin/features_steps.rb b/features/step_definitions/admin/features_steps.rb
index 77a92cdb2..c6a708364 100644
--- a/features/step_definitions/admin/features_steps.rb
+++ b/features/step_definitions/admin/features_steps.rb
@@ -1,7 +1,5 @@
-
-
Given(/^a petition exists with many signatures$/) do
- @petition = FactoryGirl.create(:petition_complete_with_one_hundred_signatures)
+ @petition = FactoryBot.create(:petition_complete_with_one_hundred_signatures)
end
When(/^I visit the signatures list$/) do
diff --git a/features/step_definitions/congress_steps.rb b/features/step_definitions/congress_steps.rb
index b2f9d1938..1dfd9f06f 100644
--- a/features/step_definitions/congress_steps.rb
+++ b/features/step_definitions/congress_steps.rb
@@ -1,5 +1,5 @@
Given(/^a congress member exists$/) do
- member = FactoryGirl.create(:congress_member)
+ member = FactoryBot.create(:congress_member)
end
Given(/^a stubbed phantomdc$/) do
@@ -8,28 +8,32 @@
proxy.stub(
"#{Rails.application.config.congress_forms_url}/retrieve-form-elements", method: "post"
).and_return(
- Proc.new { |params, headers, body| {
- headers: { "Access-Control-Allow-Origin" => "*" },
- json: {
- :"#{body.last(7)}" => {
- defunct: false,
- contact_url: nil,
- required_actions: [
- { value: "$NAME_FIRST", maxlength: nil, options_hash: nil },
- { value: "$NAME_LAST", maxlength: nil, options_hash: nil },
- { value: "$EMAIL", maxlength: nil, options_hash: nil }
- ]
+ Proc.new { |params, headers, body|
+ {
+ headers: { "Access-Control-Allow-Origin" => "*" },
+ json: {
+ :"#{body.last(7)}" => {
+ defunct: false,
+ contact_url: nil,
+ required_actions: [
+ { value: "$NAME_FIRST", maxlength: nil, options_hash: nil },
+ { value: "$NAME_LAST", maxlength: nil, options_hash: nil },
+ { value: "$EMAIL", maxlength: nil, options_hash: nil }
+ ]
+ }
}
}
- } }
+ }
)
proxy.stub(
"#{Rails.application.config.congress_forms_url}/fill-out-form", method: "post"
).and_return(
- Proc.new { |params, headers, body| {
- headers: { "Access-Control-Allow-Origin" => "*" },
- json: { status: "success" }
- } }
+ Proc.new { |params, headers, body|
+ {
+ headers: { "Access-Control-Allow-Origin" => "*" },
+ json: { status: "success" }
+ }
+ }
)
end
diff --git a/features/step_definitions/debug_steps.rb b/features/step_definitions/debug_steps.rb
index a6ecd1371..be3d98837 100644
--- a/features/step_definitions/debug_steps.rb
+++ b/features/step_definitions/debug_steps.rb
@@ -1,4 +1,3 @@
-
When /^I byebug$/ do
byebug
end
diff --git a/features/step_definitions/partner_steps.rb b/features/step_definitions/partner_steps.rb
index a03056484..78b27f367 100644
--- a/features/step_definitions/partner_steps.rb
+++ b/features/step_definitions/partner_steps.rb
@@ -1,3 +1,3 @@
Given(/^a partner named "(.*?)" with the code "(.*?)" exists$/) do |name, code|
- @partner = FactoryGirl.create(:partner, name: name, code: code)
+ @partner = FactoryBot.create(:partner, name: name, code: code)
end
diff --git a/features/step_definitions/source_file_steps.rb b/features/step_definitions/source_file_steps.rb
index 74127f530..a7bad345b 100644
--- a/features/step_definitions/source_file_steps.rb
+++ b/features/step_definitions/source_file_steps.rb
@@ -1,4 +1,3 @@
-
When(/^there is an uploaded file named "([^\"]+)"$/) do |file_name|
step "there is a persisted SourceFile with:", table(%{
|file_name|#{file_name}|
diff --git a/features/step_definitions/topic_steps.rb b/features/step_definitions/topic_steps.rb
index 15e74c0c3..fa06ef395 100644
--- a/features/step_definitions/topic_steps.rb
+++ b/features/step_definitions/topic_steps.rb
@@ -1,4 +1,3 @@
-
Then /^the topic set containing "([^\"]+)" should be tier ([\d]+)$/ do |topic, tier|
topic_set = TopicSet.joins(:topics).where(topics: { name: topic }).take!
expect(topic_set.tier).to eq(tier.to_i)
diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb
index 62324726e..16b56e416 100644
--- a/features/step_definitions/user_steps.rb
+++ b/features/step_definitions/user_steps.rb
@@ -1,15 +1,15 @@
def setup_action
@action_info = { title: "this is an important call",
- summary: "blablabla",
- description: "such bla, such bla" }
+ summary: "blablabla",
+ description: "such bla, such bla" }
end
def create_visitor
@visitor ||= { name: "Test User",
- email: "me@example.com",
- zip_code: "94117",
- password: "strong passwords defeat lobsters covering wealth",
- password_confirmation: "strong passwords defeat lobsters covering wealth" }
+ email: "me@example.com",
+ zip_code: "94117",
+ password: "strong passwords defeat lobsters covering wealth",
+ password_confirmation: "strong passwords defeat lobsters covering wealth" }
end
def delete_user
@@ -20,13 +20,13 @@ def delete_user
def create_activist_user
create_visitor
delete_user
- @user = FactoryGirl.create(:activist_user, email: @visitor[:email], password: @visitor[:password])
+ @user = FactoryBot.create(:activist_user, email: @visitor[:email], password: @visitor[:password])
end
def create_community_member_user
create_visitor
delete_user
- @user = FactoryGirl.create(:user, email: @visitor[:email], password: @visitor[:password])
+ @user = FactoryBot.create(:user, email: @visitor[:email], password: @visitor[:password])
end
def sign_in
@@ -38,26 +38,26 @@ def sign_in
end
def create_an_action_page_petition_needing_one_more_signature
- @petition = FactoryGirl.create(:petition_with_99_signatures_needing_1_more)
+ @petition = FactoryBot.create(:petition_with_99_signatures_needing_1_more)
@action_page = @petition.action_page
end
def create_a_call_campaign
- @call_campaign = FactoryGirl.create(:call_campaign, call_campaign_id: senate_call_campaign_id)
+ @call_campaign = FactoryBot.create(:call_campaign, call_campaign_id: senate_call_campaign_id)
@action_page = @call_campaign.action_page
end
def create_an_email_campaign
- @email_campaign = FactoryGirl.create(:email_campaign)
+ @email_campaign = FactoryBot.create(:email_campaign)
@action_page = @email_campaign.action_page
end
Given(/^a user with the email "(.*?)"$/) do |email|
- FactoryGirl.create(:user, email: email)
+ FactoryBot.create(:user, email: email)
end
Given(/^an unconfirmed user with the email "(.*?)"$/) do |email|
- FactoryGirl.create(:unconfirmed_user, email: email)
+ FactoryBot.create(:unconfirmed_user, email: email)
end
Given(/^I exist as an activist$/) do
@@ -339,11 +339,11 @@ def import_file_into_editor(name, content)
Given(/^A tweet petition targeting senate exists$/) do
setup_action
- @tweet = FactoryGirl.create(:tweet_targeting_senate)
+ @tweet = FactoryBot.create(:tweet_targeting_senate)
@action_page = @tweet.action_page
@action_page.update_attributes(title: @action_info[:title],
- summary: @action_info[:summary],
- description: @action_info[:description])
+ summary: @action_info[:summary],
+ description: @action_info[:description])
end
Then(/^I see a button to lookup my reps$/) do
@@ -374,20 +374,20 @@ def import_file_into_editor(name, content)
Given(/^a call petition targeting senate exists$/) do
setup_action
- @call_campaign = FactoryGirl.create(:call_campaign, call_campaign_id: senate_call_campaign_id, message: "hey hey")
+ @call_campaign = FactoryBot.create(:call_campaign, call_campaign_id: senate_call_campaign_id, message: "hey hey")
@action_page = @call_campaign.action_page
@action_page.update_attributes(title: @action_info[:title],
- summary: @action_info[:summary],
- description: @action_info[:description])
+ summary: @action_info[:summary],
+ description: @action_info[:description])
end
Given(/^a call petition targeting a custom number exists$/) do
setup_action
- @call_campaign = FactoryGirl.create(:call_campaign, call_campaign_id: custom_call_campaign_id, message: "hey hey")
+ @call_campaign = FactoryBot.create(:call_campaign, call_campaign_id: custom_call_campaign_id, message: "hey hey")
@action_page = @call_campaign.action_page
@action_page.update_attributes(title: @action_info[:title],
- summary: @action_info[:summary],
- description: @action_info[:description])
+ summary: @action_info[:summary],
+ description: @action_info[:description])
end
Then(/^I see form fields for phone number, address, and zip code$/) do
@@ -452,8 +452,8 @@ def this_machine_offline?
wait_until {
WebMock::WebMockMatcher.new(:post, CiviCRM::supporters_api_url).matches?(nil)
}
- WebMock.should have_requested(:post, CiviCRM::supporters_api_url).
- with(body: /.*#{email}.*/)
+ WebMock.should have_requested(:post, CiviCRM::supporters_api_url)
+ .with(body: /.*#{email}.*/)
end
Then(/^I should not have signed up for mailings$/) do
diff --git a/lib/action_cloner.rb b/lib/action_cloner.rb
index 45a63f02b..253d73fb4 100644
--- a/lib/action_cloner.rb
+++ b/lib/action_cloner.rb
@@ -7,13 +7,9 @@ def self.run(original)
clone_tools(original, clone)
end
- private
-
def self.clone_tools(original, clone)
- %i(tweet email_campaign petition congress_message_campaign call_campaign).each do |tool_sym|
- if original.send("#{tool_sym}_id").present?
- clone.send("#{tool_sym}=", original.send(tool_sym).dup)
- end
+ %i[tweet email_campaign petition congress_message_campaign call_campaign].each do |tool_sym|
+ clone.send("#{tool_sym}=", original.send(tool_sym).dup) if original.send("#{tool_sym}_id").present?
end
clone
end
diff --git a/lib/amazon_credentials.rb b/lib/amazon_credentials.rb
index 17840b5cb..bec9750f7 100644
--- a/lib/amazon_credentials.rb
+++ b/lib/amazon_credentials.rb
@@ -2,11 +2,13 @@ module AmazonCredentials
# This module is primarily for paperclip config
def amazon_credentials
bucket_url_options = {}
- bucket_url_options = {
- s3_host_alias: Rails.application.secrets.amazon_bucket_url,
- url: ":s3_alias_url",
- path: "/:class/:attachment/:id_partition/:style/:filename"
- } unless Rails.application.secrets.amazon_bucket_url.nil?
+ unless Rails.application.secrets.amazon_bucket_url.nil?
+ bucket_url_options = {
+ s3_host_alias: Rails.application.secrets.amazon_bucket_url,
+ url: ":s3_alias_url",
+ path: "/:class/:attachment/:id_partition/:style/:filename"
+ }
+ end
{
storage: Rails.application.secrets.storage.to_sym,
@@ -27,6 +29,6 @@ def build_s3_host_name
end
def self.build_s3_host_name
- "s3-" + Rails.application.secrets.amazon_region + ".amazonaws.com"
+ "s3-#{Rails.application.secrets.amazon_region}.amazonaws.com"
end
end
diff --git a/lib/call_tool.rb b/lib/call_tool.rb
index 9bb969e40..685b446f0 100644
--- a/lib/call_tool.rb
+++ b/lib/call_tool.rb
@@ -2,23 +2,19 @@
module CallTool
def self.campaign_call(campaign, phone:, location:, user_id:, action_id:, callback_url:)
- unless [campaign, phone, location, action_id, callback_url].all?
- raise ArgumentError.new("required argument is nil")
- end
+ raise ArgumentError, "required argument is nil" unless [campaign, phone, location, action_id, callback_url].all?
get "/call/create", {
campaignId: campaign.to_param,
- userPhone: phone,
+ userPhone: phone,
userCountry: "US",
userLocation: location,
callback_url: callback_url,
-
- # TODO - Settle on the schema of the private meta data
meta: {
- user_id: user_id,
- action_id: action_id,
+ user_id: user_id,
+ action_id: action_id,
action_type: "call"
- }.to_json,
+ }.to_json
}
end
@@ -32,7 +28,7 @@ def self.campaigns
api_response = { "total_pages" => 1, "page" => 0 }
until api_response["page"] >= api_response["total_pages"]
- api_response = JSON.parse(get "/api/campaign", { api_key: api_key, page: api_response["page"] + 1 })
+ api_response = JSON.parse(get("/api/campaign", { api_key: api_key, page: api_response["page"] + 1 }))
campaigns.concat(api_response["objects"].map { |campaign| campaign.slice("id", "name", "allow_call_in", "phone_numbers", "status") })
end
@@ -44,19 +40,17 @@ def self.enabled?
Rails.application.secrets.fetch_values(:call_tool_url, :call_tool_api_key).all?
end
- private
-
def self.get(action, params = {})
RestClient.get endpoint(action), params: params
rescue RestClient::BadRequest => e
begin
error = JSON.parse(e.http_body)["error"]
- rescue
+ rescue StandardError
raise
end
# Don't raise for twilio error 13224: number invalid
- unless error.match(/^13224:/)
+ unless error.match?(/^13224:/)
if Rails.application.secrets.sentry_dsn.nil?
raise error
else
@@ -66,8 +60,8 @@ def self.get(action, params = {})
end
def self.endpoint(action)
- base = Rails.application.config.call_tool_url.sub(/\/$/, "")
- action = action.sub(/^\//, "")
+ base = Rails.application.config.call_tool_url.sub(%r{/$}, "")
+ action = action.sub(%r{^/}, "")
"#{base}/#{action}"
end
diff --git a/lib/civicrm.rb b/lib/civicrm.rb
index 7773669b7..95ee6ca6c 100644
--- a/lib/civicrm.rb
+++ b/lib/civicrm.rb
@@ -8,34 +8,39 @@ def contact_attributes
)
end
- def subscribe!(opt_in = false, source = "action center")
+ def subscribe!(opt_in: false, source: "action center")
return nil if CiviCRM.skip_crm?
- res = CiviCRM::subscribe contact_attributes.merge(opt_in: opt_in, source: source)
- update_attributes(contact_id: res["contact_id"]) if (res && res["contact_id"])
+
+ res = CiviCRM.subscribe contact_attributes.merge(opt_in: opt_in, source: source)
+ update(contact_id: res["contact_id"]) if res && res["contact_id"]
res || {}
end
def contact_id!
return nil if CiviCRM.skip_crm?
- res = CiviCRM::import_contact contact_attributes
- update_attributes(contact_id: res["contact_id"]) if (res && res["contact_id"])
+
+ res = CiviCRM.import_contact contact_attributes
+ update(contact_id: res["contact_id"]) if res && res["contact_id"]
contact_id
end
def add_civicrm_activity!(action_page_id)
return nil if CiviCRM.skip_crm?
- if contact_id && action_page = ActionPage.find_by_id(action_page_id)
- CiviCRM::add_activity(
- contact_id: contact_id,
- subject: "Took Action #{action_page.id}: #{action_page.title}"
- )
- end
+
+ action_page = ActionPage.find_by(id: action_page_id)
+ return unless contact_id && action_page
+
+ CiviCRM.add_activity(
+ contact_id: contact_id,
+ subject: "Took Action #{action_page.id}: #{action_page.title}"
+ )
end
def manage_subscription_url!
- checksum = CiviCRM::get_checksum(contact_id)
+ checksum = CiviCRM.get_checksum(contact_id)
return nil unless checksum
- "#{Rails.application.secrets.supporters['host']}/update-your-preferences?" + {
+
+ "#{Rails.application.secrets.supporters[:host]}/update-your-preferences?" + {
cid1: contact_id,
cs: checksum
}.to_param
@@ -43,16 +48,18 @@ def manage_subscription_url!
end
def self.skip_crm?
- Rails.application.secrets.supporters["api_key"].nil?
+ Rails.application.secrets.supporters[:api_key].nil?
end
def self.subscribe(params)
return {} if skip_crm?
- self.import_contact params.merge(subscribe: true)
+
+ import_contact params.merge(subscribe: true)
end
def self.import_contact(params)
return {} if skip_crm?
+
post base_params.merge(
method: "import_contact",
data: {
@@ -73,6 +80,7 @@ def self.import_contact(params)
def self.add_activity(params)
return nil if skip_crm?
+
post base_params.merge(
method: "add_activity",
data: params.slice(:contact_id, :subject, :activity_type_id).to_json
@@ -80,21 +88,18 @@ def self.add_activity(params)
end
def self.supporters_api_url
- "#{Rails.application.secrets.supporters['host']}/#{Rails.application.secrets.supporters['path']}"
+ "#{Rails.application.secrets.supporters[:host]}/#{Rails.application.secrets.supporters[:path]}"
end
- private
-
def self.post(params)
- begin
- res = JSON.parse RestClient.post(supporters_api_url, params)
- raise res["error_message"] if res["error"]
- return res
- rescue => e
- Raven.capture_exception(e)
- Rails.logger.error "#{ e } (#{ e.class })!"
- return false
- end
+ res = JSON.parse RestClient.post(supporters_api_url, params)
+ raise res["error_message"] if res["error"]
+
+ res
+ rescue StandardError => e
+ Raven.capture_exception(e)
+ Rails.logger.error "#{e} (#{e.class})!"
+ false
end
def self.send_email_template_data(params)
@@ -116,6 +121,7 @@ def self.find_contact_by_email_data(params)
def self.get_checksum(contact_id)
return nil if skip_crm?
+
# Valid for 24 hours
res = post base_params.merge(
method: "generate_checksum",
@@ -125,6 +131,6 @@ def self.get_checksum(contact_id)
end
def self.base_params
- { site_key: Rails.application.secrets.supporters["api_key"] }
+ { site_key: Rails.application.secrets.supporters[:api_key] }
end
end
diff --git a/lib/congress_forms.rb b/lib/congress_forms.rb
index a31c483cf..d99023830 100644
--- a/lib/congress_forms.rb
+++ b/lib/congress_forms.rb
@@ -7,7 +7,8 @@ class Form
def self.find(bioguide_ids)
raw_data = CongressForms.post("/retrieve-form-elements/", { bio_ids: bioguide_ids })
raise CongressForms::RequestFailed if raw_data.empty?
- links, forms = raw_data.partition { |id, raw| raw["defunct"] }
+
+ links, forms = raw_data.partition { |_id, raw| raw["defunct"] }
[
forms.map { |id, raw| Form.new(id, raw["required_actions"]) },
links.map { |id, raw| [id, raw["contact_url"]] }.to_h
@@ -21,11 +22,11 @@ def initialize(bioguide_id, fields)
end
def order_fields
- order = %w($NAME_PREFIX $NAME_FIRST $NAME_LAST $PHONE $EMAIL $SUBJECT $TOPIC)
+ order = %w[$NAME_PREFIX $NAME_FIRST $NAME_LAST $PHONE $EMAIL $SUBJECT $TOPIC]
@fields = @fields.sort_by { |f| order.index(f.value) || Float::INFINITY }
end
- def fill(input, campaign_tag, test = false)
+ def fill(input, campaign_tag, test: false)
params = { bio_id: @bioguide_id, campaign_tag: campaign_tag, fields: input }
params[:test] = 1 if test
CongressForms.post("/fill-out-form/", params)
@@ -46,6 +47,7 @@ def validate(input)
return false if input.nil?
return false if max_length && input.length > max_length
return false unless options.nil? || options.include?(input)
+
true
end
@@ -53,7 +55,7 @@ def label
I18n.t value, scope: :congress_forms, default: value.sub("$", "").humanize
end
- def is_select?
+ def is_select? # rubocop:todo Naming/PredicateName
options_hash != nil
end
@@ -72,9 +74,10 @@ def hash
end
def options_hash
- if @value == "$ADDRESS_STATE_POSTAL_ABBREV"
+ case @value
+ when "$ADDRESS_STATE_POSTAL_ABBREV"
Places.us_state_codes
- elsif @value == "$ADDRESS_STATE_FULL"
+ when "$ADDRESS_STATE_FULL"
Places.us_states
else
@options_hash
@@ -83,6 +86,7 @@ def options_hash
def options
return options_hash.values if options_hash.is_a?(Hash)
+
options_hash
end
end
@@ -95,7 +99,7 @@ def self.date_fills_path(campaign_tag = nil, start_date = nil, end_date = nil, b
params = {
date_start: start_date,
date_end: end_date,
- campaign_tag: campaign_tag,
+ campaign_tag: campaign_tag
}.compact
data_path("/successful-fills-by-date/", params, bioguide_id)
end
@@ -110,30 +114,26 @@ def self.date_fills(*args)
def self.data_path(base_path, params = {}, bioguide_id = nil)
base_path += bioguide_id unless bioguide_id.nil?
- base_path += "?" + {
- debug_key: Rails.application.secrets.congress_forms_debug_key,
+ "#{base_path}?" + {
+ debug_key: Rails.application.secrets.congress_forms_debug_key
}.merge(params).to_query
end
def self.get(path)
- begin
- JSON.parse RestClient.get(base_url + path)
- rescue RestClient::ExceptionWithResponse => e
- Raven.capture_exception(e)
- Rails.logger.error e
- return {}
- end
+ JSON.parse RestClient.get(base_url + path)
+ rescue RestClient::ExceptionWithResponse => e
+ Raven.capture_exception(e)
+ Rails.logger.error e
+ {}
end
def self.post(path, body = {})
- begin
- JSON.parse RestClient.post(base_url + path, body.to_json,
- { content_type: :json, accept: :json })
- rescue RestClient::ExceptionWithResponse => e
- Raven.capture_exception(e)
- Rails.logger.error e
- raise RequestFailed
- end
+ JSON.parse RestClient.post(base_url + path, body.to_json,
+ { content_type: :json, accept: :json })
+ rescue RestClient::ExceptionWithResponse => e
+ Raven.capture_exception(e)
+ Rails.logger.error e
+ raise RequestFailed
end
def self.base_url
diff --git a/lib/monkey_patches/octet_stream_override.rb b/lib/monkey_patches/octet_stream_override.rb
index f8a95ffa8..e2e5c9d24 100644
--- a/lib/monkey_patches/octet_stream_override.rb
+++ b/lib/monkey_patches/octet_stream_override.rb
@@ -8,11 +8,11 @@
# Additionally, this only allows paperclip to interact with image files
#
# The class we're patching is here: https://github.com/thoughtbot/paperclip/blob/fbdcbe8da30138dac5500e4291e7b279491d1316/lib/paperclip/media_type_spoof_detector.rb
-
module MonkeyPatches
module OctetStreamOverride
def spoofed?
- return true unless is_image?
+ return true unless image?
+
override_header_type if supplied_content_type == "binary/octet-stream"
if has_name? && has_extension? && media_type_mismatch? && mapping_override_mismatch?
Paperclip.log("Content Type Spoof: Filename #{File.basename(@name)} (#{supplied_content_type} from Headers, #{content_types_from_name.map(&:to_s)} from Extension), content type discovered from file command: #{calculated_content_type}. See documentation to allow this combination.")
@@ -24,8 +24,9 @@ def spoofed?
private
- def is_image?
- return true if /\Aimage\/.*\Z/.match? calculated_content_type
+ def image?
+ return true if %r{\Aimage/.*\Z}.match? calculated_content_type
+
Paperclip.log("Attempted non-image upload: Filename #{File.basename(@name)} (#{supplied_content_type}")
false
end
diff --git a/lib/places.rb b/lib/places.rb
index 7b387fc15..6841aa41d 100644
--- a/lib/places.rb
+++ b/lib/places.rb
@@ -69,193 +69,193 @@ def self.us_states
def self.country_codes
[
- ["Afghanistan", "AF"],
+ %w[Afghanistan AF],
["Aland Islands", "AX"],
- ["Albania", "AL"],
- ["Algeria", "DZ"],
+ %w[Albania AL],
+ %w[Algeria DZ],
["American Samoa", "AS"],
- ["Andorra", "AD"],
- ["Angola", "AO"],
- ["Anguilla", "AI"],
- ["Antarctica", "AQ"],
+ %w[Andorra AD],
+ %w[Angola AO],
+ %w[Anguilla AI],
+ %w[Antarctica AQ],
["Antigua and Barbuda", "AG"],
- ["Argentina", "AR"],
- ["Armenia", "AM"],
- ["Aruba", "AW"],
+ %w[Argentina AR],
+ %w[Armenia AM],
+ %w[Aruba AW],
["Ascension Island", "AC"],
- ["Australia", "AU"],
- ["Austria", "AT"],
- ["Azerbaijan", "AZ"],
- ["Bahamas", "BS"],
- ["Bahrain", "BH"],
- ["Bangladesh", "BD"],
- ["Barbados", "BB"],
- ["Belarus", "BY"],
- ["Belgium", "BE"],
- ["Belize", "BZ"],
- ["Benin", "BJ"],
- ["Bermuda", "BM"],
- ["Bhutan", "BT"],
+ %w[Australia AU],
+ %w[Austria AT],
+ %w[Azerbaijan AZ],
+ %w[Bahamas BS],
+ %w[Bahrain BH],
+ %w[Bangladesh BD],
+ %w[Barbados BB],
+ %w[Belarus BY],
+ %w[Belgium BE],
+ %w[Belize BZ],
+ %w[Benin BJ],
+ %w[Bermuda BM],
+ %w[Bhutan BT],
["Bolivia, Plurinational State of", "BO"],
["Bonaire, Sint Eustatius and Saba", "BQ"],
["Bosnia and Herzegovina", "BA"],
- ["Botswana", "BW"],
+ %w[Botswana BW],
["Bouvet Island", "BV"],
- ["Brazil", "BR"],
+ %w[Brazil BR],
["British Indian Ocean Territory", "IO"],
["Brunei Darussalam", "BN"],
- ["Bulgaria", "BG"],
+ %w[Bulgaria BG],
["Burkina Faso", "BF"],
- ["Burundi", "BI"],
- ["Cambodia", "KH"],
- ["Cameroon", "CM"],
- ["Canada", "CA"],
+ %w[Burundi BI],
+ %w[Cambodia KH],
+ %w[Cameroon CM],
+ %w[Canada CA],
["Cape Verde", "CV"],
["Cayman Islands", "KY"],
["Central African Republic", "CF"],
- ["Chad", "TD"],
- ["Chile", "CL"],
- ["China", "CN"],
+ %w[Chad TD],
+ %w[Chile CL],
+ %w[China CN],
["Christmas Island", "CX"],
["Cocos (Keeling) Islands", "CC"],
- ["Colombia", "CO"],
- ["Comoros", "KM"],
- ["Congo", "CG"],
+ %w[Colombia CO],
+ %w[Comoros KM],
+ %w[Congo CG],
["Congo, the Democratic Republic of the", "CD"],
["Cook Islands", "CK"],
["Costa Rica", "CR"],
["Cote d'Ivoire", "CI"],
- ["Croatia", "HR"],
- ["Cuba", "CU"],
- ["Curacao", "CW"],
- ["Cyprus", "CY"],
+ %w[Croatia HR],
+ %w[Cuba CU],
+ %w[Curacao CW],
+ %w[Cyprus CY],
["Czech Republic", "CZ"],
- ["Denmark", "DK"],
- ["Djibouti", "DJ"],
- ["Dominica", "DM"],
+ %w[Denmark DK],
+ %w[Djibouti DJ],
+ %w[Dominica DM],
["Dominican Republic", "DO"],
- ["Ecuador", "EC"],
- ["Egypt", "EG"],
+ %w[Ecuador EC],
+ %w[Egypt EG],
["El Salvador", "SV"],
["Equatorial Guinea", "GQ"],
- ["Eritrea", "ER"],
- ["Estonia", "EE"],
- ["Ethiopia", "ET"],
+ %w[Eritrea ER],
+ %w[Estonia EE],
+ %w[Ethiopia ET],
["Falkland Islands (Malvinas)", "FK"],
["Faroe Islands", "FO"],
- ["Fiji", "FJ"],
- ["Finland", "FI"],
- ["France", "FR"],
+ %w[Fiji FJ],
+ %w[Finland FI],
+ %w[France FR],
["French Guiana", "GF"],
["French Polynesia", "PF"],
["French Southern Territories", "TF"],
- ["Gabon", "GA"],
- ["Gambia", "GM"],
- ["Georgia", "GE"],
- ["Germany", "DE"],
- ["Ghana", "GH"],
- ["Gibraltar", "GI"],
- ["Greece", "GR"],
- ["Greenland", "GL"],
- ["Grenada", "GD"],
- ["Guadeloupe", "GP"],
- ["Guam", "GU"],
- ["Guatemala", "GT"],
- ["Guernsey", "GG"],
- ["Guinea", "GN"],
- ["Guinea-Bissau", "GW"],
- ["Guyana", "GY"],
- ["Haiti", "HT"],
+ %w[Gabon GA],
+ %w[Gambia GM],
+ %w[Georgia GE],
+ %w[Germany DE],
+ %w[Ghana GH],
+ %w[Gibraltar GI],
+ %w[Greece GR],
+ %w[Greenland GL],
+ %w[Grenada GD],
+ %w[Guadeloupe GP],
+ %w[Guam GU],
+ %w[Guatemala GT],
+ %w[Guernsey GG],
+ %w[Guinea GN],
+ %w[Guinea-Bissau GW],
+ %w[Guyana GY],
+ %w[Haiti HT],
["Heard Island and McDonald Islands", "HM"],
["Holy See (Vatican City State)", "VA"],
- ["Honduras", "HN"],
+ %w[Honduras HN],
["Hong Kong", "HK"],
- ["Hungary", "HU"],
- ["Iceland", "IS"],
- ["India", "IN"],
- ["Indonesia", "ID"],
+ %w[Hungary HU],
+ %w[Iceland IS],
+ %w[India IN],
+ %w[Indonesia ID],
["Iran, Islamic Republic of", "IR"],
- ["Iraq", "IQ"],
- ["Ireland", "IE"],
+ %w[Iraq IQ],
+ %w[Ireland IE],
["Isle of Man", "IM"],
- ["Israel", "IL"],
- ["Italy", "IT"],
- ["Jamaica", "JM"],
- ["Japan", "JP"],
- ["Jersey", "JE"],
- ["Jordan", "JO"],
- ["Kazakhstan", "KZ"],
- ["Kenya", "KE"],
- ["Kiribati", "KI"],
+ %w[Israel IL],
+ %w[Italy IT],
+ %w[Jamaica JM],
+ %w[Japan JP],
+ %w[Jersey JE],
+ %w[Jordan JO],
+ %w[Kazakhstan KZ],
+ %w[Kenya KE],
+ %w[Kiribati KI],
["Korea, Democratic People's Republic of", "KP"],
["Korea, Republic of", "KR"],
- ["Kosovo", "KV"],
- ["Kuwait", "KW"],
- ["Kyrgyzstan", "KG"],
+ %w[Kosovo KV],
+ %w[Kuwait KW],
+ %w[Kyrgyzstan KG],
["Lao People's Democratic Republic", "LA"],
- ["Latvia", "LV"],
- ["Lebanon", "LB"],
- ["Lesotho", "LS"],
- ["Liberia", "LR"],
- ["Libya", "LY"],
- ["Liechtenstein", "LI"],
- ["Lithuania", "LT"],
- ["Luxembourg", "LU"],
- ["Macao", "MO"],
+ %w[Latvia LV],
+ %w[Lebanon LB],
+ %w[Lesotho LS],
+ %w[Liberia LR],
+ %w[Libya LY],
+ %w[Liechtenstein LI],
+ %w[Lithuania LT],
+ %w[Luxembourg LU],
+ %w[Macao MO],
["Macedonia, The Former Yugoslav Republic Of", "MK"],
- ["Madagascar", "MG"],
- ["Malawi", "MW"],
- ["Malaysia", "MY"],
- ["Maldives", "MV"],
- ["Mali", "ML"],
- ["Malta", "MT"],
+ %w[Madagascar MG],
+ %w[Malawi MW],
+ %w[Malaysia MY],
+ %w[Maldives MV],
+ %w[Mali ML],
+ %w[Malta MT],
["Marshall Islands", "MH"],
- ["Martinique", "MQ"],
- ["Mauritania", "MR"],
- ["Mauritius", "MU"],
- ["Mayotte", "YT"],
- ["Mexico", "MX"],
+ %w[Martinique MQ],
+ %w[Mauritania MR],
+ %w[Mauritius MU],
+ %w[Mayotte YT],
+ %w[Mexico MX],
["Micronesia, Federated States of", "FM"],
["Moldova, Republic of", "MD"],
- ["Monaco", "MC"],
- ["Mongolia", "MN"],
- ["Montenegro", "ME"],
- ["Montserrat", "MS"],
- ["Morocco", "MA"],
- ["Mozambique", "MZ"],
- ["Myanmar", "MM"],
- ["Namibia", "NA"],
- ["Nauru", "NR"],
- ["Nepal", "NP"],
- ["Netherlands", "NL"],
+ %w[Monaco MC],
+ %w[Mongolia MN],
+ %w[Montenegro ME],
+ %w[Montserrat MS],
+ %w[Morocco MA],
+ %w[Mozambique MZ],
+ %w[Myanmar MM],
+ %w[Namibia NA],
+ %w[Nauru NR],
+ %w[Nepal NP],
+ %w[Netherlands NL],
["Netherlands Antilles", "AN"],
["New Caledonia", "NC"],
["New Zealand", "NZ"],
- ["Nicaragua", "NI"],
- ["Niger", "NE"],
- ["Nigeria", "NG"],
- ["Niue", "NU"],
+ %w[Nicaragua NI],
+ %w[Niger NE],
+ %w[Nigeria NG],
+ %w[Niue NU],
["Norfolk Island", "NF"],
["Northern Mariana Islands", "MP"],
- ["Norway", "NO"],
- ["Oman", "OM"],
- ["Pakistan", "PK"],
- ["Palau", "PW"],
+ %w[Norway NO],
+ %w[Oman OM],
+ %w[Pakistan PK],
+ %w[Palau PW],
["Palestinian Territory, Occupied", "PS"],
- ["Panama", "PA"],
+ %w[Panama PA],
["Papua New Guinea", "PG"],
- ["Paraguay", "PY"],
- ["Peru", "PE"],
- ["Philippines", "PH"],
- ["Pitcairn", "PN"],
- ["Poland", "PL"],
- ["Portugal", "PT"],
+ %w[Paraguay PY],
+ %w[Peru PE],
+ %w[Philippines PH],
+ %w[Pitcairn PN],
+ %w[Poland PL],
+ %w[Portugal PT],
["Puerto Rico", "PR"],
- ["Qatar", "QA"],
- ["Reunion", "RE"],
- ["Romania", "RO"],
+ %w[Qatar QA],
+ %w[Reunion RE],
+ %w[Romania RO],
["Russian Federation", "RU"],
- ["Rwanda", "RW"],
+ %w[Rwanda RW],
["Saint Barthelemy", "BL"],
["Saint Helena, Ascension and Tristan da Cunha", "SH"],
["Saint Kitts and Nevis", "KN"],
@@ -263,66 +263,65 @@ def self.country_codes
["Saint Martin (French part)", "MF"],
["Saint Pierre and Miquelon", "PM"],
["Saint Vincent and the Grenadines", "VC"],
- ["Samoa", "WS"],
+ %w[Samoa WS],
["San Marino", "SM"],
["Sao Tome and Principe", "ST"],
["Saudi Arabia", "SA"],
- ["Senegal", "SN"],
- ["Serbia", "RS"],
- ["Seychelles", "SC"],
+ %w[Senegal SN],
+ %w[Serbia RS],
+ %w[Seychelles SC],
["Sierra Leone", "SL"],
- ["Singapore", "SG"],
+ %w[Singapore SG],
["Sint Maarten (Dutch part)", "SX"],
- ["Slovakia", "SK"],
- ["Slovenia", "SI"],
+ %w[Slovakia SK],
+ %w[Slovenia SI],
["Solomon Islands", "SB"],
- ["Somalia", "SO"],
+ %w[Somalia SO],
["South Africa", "ZA"],
["South Georgia and the South Sandwich Islands", "GS"],
["South Sudan, Republic of", "SS"],
- ["Spain", "ES"],
+ %w[Spain ES],
["Sri Lanka", "LK"],
- ["Sudan", "SD"],
- ["Suriname", "SR"],
+ %w[Sudan SD],
+ %w[Suriname SR],
["Svalbard and Jan Mayen", "SJ"],
- ["Swaziland", "SZ"],
- ["Sweden", "SE"],
- ["Switzerland", "CH"],
+ %w[Swaziland SZ],
+ %w[Sweden SE],
+ %w[Switzerland CH],
["Syrian Arab Republic", "SY"],
- ["Taiwan", "TW"],
- ["Tajikistan", "TJ"],
+ %w[Taiwan TW],
+ %w[Tajikistan TJ],
["Tanzania, United Republic of", "TZ"],
- ["Thailand", "TH"],
- ["Timor-Leste", "TL"],
- ["Togo", "TG"],
- ["Tokelau", "TK"],
- ["Tonga", "TO"],
+ %w[Thailand TH],
+ %w[Timor-Leste TL],
+ %w[Togo TG],
+ %w[Tokelau TK],
+ %w[Tonga TO],
["Trinidad and Tobago", "TT"],
["Tristan da Cunha", "TA"],
- ["Tunisia", "TN"],
- ["Turkey", "TR"],
- ["Turkmenistan", "TM"],
+ %w[Tunisia TN],
+ %w[Turkey TR],
+ %w[Turkmenistan TM],
["Turks and Caicos Islands", "TC"],
- ["Tuvalu", "TV"],
- ["Uganda", "UG"],
- ["Ukraine", "UA"],
+ %w[Tuvalu TV],
+ %w[Uganda UG],
+ %w[Ukraine UA],
["United Arab Emirates", "AE"],
["United Kingdom", "GB"],
["United States", "US"],
["United States Minor Outlying Islands", "UM"],
- ["Uruguay", "UY"],
- ["Uzbekistan", "UZ"],
- ["Vanuatu", "VU"],
+ %w[Uruguay UY],
+ %w[Uzbekistan UZ],
+ %w[Vanuatu VU],
["Venezuela, Bolivarian Republic of", "VE"],
["Viet Nam", "VN"],
["Virgin Islands, British", "VG"],
["Virgin Islands, U.S.", "VI"],
["Wallis and Futuna", "WF"],
["Western Sahara", "EH"],
- ["Yemen", "YE"],
- ["Zambia", "ZM"],
- ["Zimbabwe", "ZW"]
+ %w[Yemen YE],
+ %w[Zambia ZM],
+ %w[Zimbabwe ZW]
].freeze
end
-
end
diff --git a/lib/quotes.rb b/lib/quotes.rb
index 1ac906603..fff4641d2 100644
--- a/lib/quotes.rb
+++ b/lib/quotes.rb
@@ -3,13 +3,9 @@ def self.get
quotes.sample
end
- private
-
def self.quotes
- begin
- @quotes ||= YAML.load_file("config/custom_quotes.yml")
- rescue Errno::ENOENT
- @quotes ||= YAML.load_file("config/quotes.yml")
- end
+ @quotes ||= YAML.load_file("config/custom_quotes.yml")
+ rescue Errno::ENOENT
+ @quotes ||= YAML.load_file("config/quotes.yml")
end
end
diff --git a/lib/related_content.rb b/lib/related_content.rb
index ab5cd05a6..28fb671f6 100644
--- a/lib/related_content.rb
+++ b/lib/related_content.rb
@@ -5,11 +5,12 @@ def initialize(url)
def load
return if url.blank?
+
begin
open_page
@loaded_successfully = true
rescue OpenURI::HTTPError
- return
+ nil
end
end
@@ -23,6 +24,7 @@ def title
def image
return @image if @image
+
og_url = page.css("meta[property='og:image']")
@image = if og_url.blank?
""
@@ -35,7 +37,9 @@ def image
attr_reader :url, :page, :loaded_successfully
+ # rubocop:todo Naming/MemoizedInstanceVariableName
def open_page
@page ||= Nokogiri::HTML(open(url))
end
+ # rubocop:enable Naming/MemoizedInstanceVariableName
end
diff --git a/lib/smarty_streets.rb b/lib/smarty_streets.rb
index b7d004434..a9a65d283 100644
--- a/lib/smarty_streets.rb
+++ b/lib/smarty_streets.rb
@@ -3,15 +3,13 @@ module SmartyStreets
def self.get_city_state(zipcode)
url = "https://us-zipcode.api.smartystreets.com/lookup"
res = post(url, base_params.merge(zipcode: zipcode))
- if res && !res.empty?
- res.first["city_states"].try :first
- end
+ res.first["city_states"].try :first if res.present?
end
def self.get_location(street, zipcode)
url = "https://api.smartystreets.com/street-address"
res = post(url, base_params.merge(street: street, zipcode: zipcode))
- raise AddressNotFound if !res || res.empty?
+ raise AddressNotFound if res.blank?
location = OpenStruct.new
location.street = street
@@ -21,7 +19,7 @@ def self.get_location(street, zipcode)
location.state = res[0]["components"]["state_abbreviation"]
location.district = res[0]["metadata"]["congressional_district"]
location.district = "0" if location.district == "AL"
- return location
+ location
end
def self.get_congressional_district(street, zipcode)
@@ -31,17 +29,12 @@ def self.get_congressional_district(street, zipcode)
class AddressNotFound < StandardError; end
- private
-
def self.post(url, params)
- begin
- res = JSON.parse RestClient.get("#{url}?#{params.to_query}")
- return res
- rescue => e
- Raven.capture_exception(e)
- Rails.logger.error "#{ e } (#{ e.class })!"
- return false
- end
+ JSON.parse RestClient.get("#{url}?#{params.to_query}")
+ rescue StandardError => e
+ Raven.capture_exception(e)
+ Rails.logger.error "#{e} (#{e.class})!"
+ false
end
def self.base_params
diff --git a/lib/tasks/ahoy.rake b/lib/tasks/ahoy.rake
index dad99d536..f63df1997 100644
--- a/lib/tasks/ahoy.rake
+++ b/lib/tasks/ahoy.rake
@@ -1,7 +1,9 @@
namespace :ahoy do
desc "Fix name for view events"
task fix_views: :environment do
+ # rubocop:todo Rails/SkipsModelValidations
Ahoy::Event.where("properties ->> 'actionType' = 'view'").update_all(name: "View")
+ # rubocop:enable Rails/SkipsModelValidations
end
task fix_action_page_ids: :environment do
diff --git a/lib/tasks/congress.rake b/lib/tasks/congress.rake
index cbf8b5967..fb942835a 100644
--- a/lib/tasks/congress.rake
+++ b/lib/tasks/congress.rake
@@ -1,4 +1,3 @@
-
namespace :congress do
desc "Create/update records of Congress members and their contact info"
task update: :environment do
@@ -15,36 +14,40 @@ namespace :congress do
legislator_sources.each do |repo|
data = RestClient.get(repo)
- YAML.load(data).each do |info|
+ YAML.safe_load(data).each do |info|
term = info["terms"].last
next if term["start"] < "2011-01-01" # don't get too historical
full_name = info["name"]["official_full"] || "#{info['name']['first']} #{info['name']['last']}"
attributes = {
- full_name: full_name,
- first_name: info["name"]["first"],
- last_name: info["name"]["last"],
+ full_name: full_name,
+ first_name: info["name"]["first"],
+ last_name: info["name"]["last"],
bioguide_id: info["id"]["bioguide"],
- phone: term["phone"],
- term_end: term["end"],
- chamber: term["type"] == "sen" ? "senate" : "house",
- state: term["state"],
- district: term["district"].try(:to_s)
+ phone: term["phone"],
+ term_end: term["end"],
+ chamber: term["type"] == "sen" ? "senate" : "house",
+ state: term["state"],
+ district: term["district"].try(:to_s)
}
- CongressMember.
- find_or_initialize_by(bioguide_id: info["id"]["bioguide"]).
- update_attributes!(attributes)
+ CongressMember
+ .find_or_initialize_by(bioguide_id: info["id"]["bioguide"])
+ .update!(attributes)
end
- legislator_social_media_sources.each do |repo|
- data = RestClient.get(repo)
- YAML.load(data).each do |info|
- next unless twitter_id = info["social"]["twitter"]
- CongressMember.
- where(bioguide_id: info["id"]["bioguide"]).
- update_all(twitter_id: twitter_id)
+ legislator_social_media_sources.each do |s_repo|
+ data = RestClient.get(s_repo)
+ YAML.safe_load(data).each do |info|
+ twitter_id = info["social"]["twitter"]
+ next unless twitter_id
+
+ # rubocop:todo Rails/SkipsModelValidations
+ CongressMember
+ .where(bioguide_id: info["id"]["bioguide"])
+ .update_all(twitter_id: twitter_id)
+ # rubocop:enable Rails/SkipsModelValidations
end
end
end
diff --git a/lib/tasks/cucumber.rake b/lib/tasks/cucumber.rake
deleted file mode 100644
index 8387e041b..000000000
--- a/lib/tasks/cucumber.rake
+++ /dev/null
@@ -1,63 +0,0 @@
-# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
-# It is recommended to regenerate this file in the future when you upgrade to a
-# newer version of cucumber-rails. Consider adding your own code to a new file
-# instead of editing this one. Cucumber will automatically load all features/**/*.rb
-# files.
-
-unless ARGV.any? { |a| a =~ /^gems/ } # Don't load anything when running the gems:* tasks
-
-vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
-$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + "/../lib") unless vendored_cucumber_bin.nil?
-
-begin
- require "cucumber/rake/task"
-
- namespace :cucumber do
- Cucumber::Rake::Task.new({ ok: "test:prepare" }, "Run features that should pass") do |t|
- t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
- t.fork = true # You may get faster startup if you set this to false
- t.profile = "default"
- end
-
- Cucumber::Rake::Task.new({ wip: "test:prepare" }, "Run features that are being worked on") do |t|
- t.binary = vendored_cucumber_bin
- t.fork = true # You may get faster startup if you set this to false
- t.profile = "wip"
- end
-
- Cucumber::Rake::Task.new({ rerun: "test:prepare" }, "Record failing features and run only them if any exist") do |t|
- t.binary = vendored_cucumber_bin
- t.fork = true # You may get faster startup if you set this to false
- t.profile = "rerun"
- end
-
- desc "Run all features"
- task all: [:ok, :wip]
-
- task :statsetup do
- require "rails/code_statistics"
- ::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?("features")
- ::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?("features")
- end
- end
- desc "Alias for cucumber:ok"
- task cucumber: "cucumber:ok"
-
- task default: :cucumber
-
- task features: :cucumber do
- STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
- end
-
- # In case we don't have the generic Rails test:prepare hook, append a no-op task that we can depend upon.
- task "test:prepare" do
- end
-
- task stats: "cucumber:statsetup"
-rescue LoadError
- desc "cucumber rake task not available (cucumber not installed)"
- task :cucumber do
- abort "Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin"
- end
-end
-end
diff --git a/lib/tasks/petition.rake b/lib/tasks/petition.rake
index 2575f6ec9..2c8e3ca84 100644
--- a/lib/tasks/petition.rake
+++ b/lib/tasks/petition.rake
@@ -22,11 +22,11 @@ end
namespace :petition do
desc "Create a local organizing petition with 99 signatures"
task create_local: :environment do
- petition = FactoryGirl.create(:local_organizing_petition)
+ petition = FactoryBot.create(:local_organizing_petition)
(0..98).each do |i|
- petition.signatures << FactoryGirl.build(:signature, petition: petition)
- petition.signatures.last.affiliations << FactoryGirl.build(
+ petition.signatures << FactoryBot.build(:signature, petition: petition)
+ petition.signatures.last.affiliations << FactoryBot.build(
:affiliation,
institution: petition.action_page.institutions[i % 10],
affiliation_type: petition.action_page.affiliation_types[i % 5]
@@ -39,19 +39,19 @@ namespace :petition do
Petition.all.each do |petition|
goal = petition.goal
count = petition.signatures.count
- if count > goal
- if goal == goals.last
- petition.goal = 100000 if count > 70000
- elsif goal < goals.last
- petition.goal = next_goal(petition.goal)
- end
+ next unless count > goal
- if petition.changed?
- petition.save
- print "Petition #{petition.id} updated. Goal: #{petition.goal}\n"
- # TODO: email admins
- end
+ if goal == goals.last
+ petition.goal = 100_000 if count > 70000
+ elsif goal < goals.last
+ petition.goal = next_goal(petition.goal)
end
+
+ next unless petition.changed?
+
+ petition.save
+ print "Petition #{petition.id} updated. Goal: #{petition.goal}\n"
+ # TODO: email admins
end
end
end
diff --git a/lib/tasks/signatures.rake b/lib/tasks/signatures.rake
index b16f22c47..b8eebb6c2 100644
--- a/lib/tasks/signatures.rake
+++ b/lib/tasks/signatures.rake
@@ -2,17 +2,18 @@ namespace :signatures do
desc "Fill in US States from zipcodes"
task fill_us_states: :environment do
Signature.where(country_code: "US").where("zipcode is not NULL").each do |sig|
- if sig.city.blank? and sig.state.blank? and GoingPostal.valid_zipcode?(sig.zipcode, "US")
- begin
- if city_state = SmartyStreets.get_city_state(sig.zipcode)
- sig.city = city_state["city"]
- sig.state = city_state["state"]
- sig.save
- puts "Updated: #{sig.inspect}"
- end
- rescue
- puts "Lookup failed for signature #{sig.id}"
- end
+ next unless sig.city.blank? && sig.state.blank? && GoingPostal.valid_zipcode?(sig.zipcode, "US")
+
+ begin
+ city_state = SmartyStreets.get_city_state(sig.zipcode)
+ next unless city_state
+
+ sig.city = city_state["city"]
+ sig.state = city_state["state"]
+ sig.save
+ puts "Updated: #{sig.inspect}"
+ rescue StandardError
+ puts "Lookup failed for signature #{sig.id}"
end
end
end
@@ -24,7 +25,7 @@ namespace :signatures do
end.compact
sig_dups.each do |email, petition_id|
Signature.where(petition_id: petition_id, email: email)
- .order(:created_at).drop(1).map(&:delete)
+ .order(:created_at).drop(1).map(&:delete)
end
sub_dups = Subscription.group(:email, :partner_id).count.map do |data, count|
diff --git a/lib/tasks/test.rake b/lib/tasks/test.rake
deleted file mode 100644
index 049ca5093..000000000
--- a/lib/tasks/test.rake
+++ /dev/null
@@ -1,4 +0,0 @@
-desc "Run sass-lint"
-task :sass_lint do
- system("node_modules/.bin/sass-lint -vq") && puts("No sass linting errors! Woo!")
-end
diff --git a/lib/tasks/users.rake b/lib/tasks/users.rake
index f186adbc1..21825e07d 100644
--- a/lib/tasks/users.rake
+++ b/lib/tasks/users.rake
@@ -1,15 +1,13 @@
namespace :users do
desc "List the emails of all admin accounts"
task list_admins: :environment do
- admins = User.where(admin: true).map do |u|
- u.email
- end.sort
+ admins = User.where(admin: true).map(&:email).sort
puts admins.empty? ? "No Admin Users" : admins
end
desc "Remove admin status from an account, given an email"
- task :remove_admin, [:email] => :environment do |t, args|
- u = User.find_by_email(args[:email])
+ task :remove_admin, [:email] => :environment do |_t, args|
+ u = User.find_by(email: args[:email])
abort("I couldn't find a user with the email '#{args[:email]}'.") unless u
u.admin = false
@@ -17,9 +15,9 @@ namespace :users do
end
desc "Add admin status from an account, given an email"
- task :add_admin, [:email] => :environment do |t, args|
+ task :add_admin, [:email] => :environment do |_t, args|
email = args[:email]
- u = User.find_by_email(email)
+ u = User.find_by(email: email)
abort("I couldn't find a user with the email '#{email}'.") unless u
u.admin = true
diff --git a/lib/tasks/webshims_asset_compile.rake b/lib/tasks/webshims_asset_compile.rake
deleted file mode 100644
index f6ddb9fce..000000000
--- a/lib/tasks/webshims_asset_compile.rake
+++ /dev/null
@@ -1,40 +0,0 @@
-# Rails4 doesn't create un-fingerprinted assets anymore, but we
-# need a couple for webshims inclusion. Let's try to hook in and make
-# symlinks.
-
-require "pathname"
-
-# Every time assets:precompile is called, trigger webshims:create_non_digest_assets afterwards.
-Rake::Task["assets:precompile"].enhance do
- Rake::Task["webshims:create_non_digest_assets"].invoke
-end
-
-namespace :webshims do
- # This seems to be basically how ordinary asset precompile
- # is logging, ugh.
- logger = Logger.new($stderr)
-
- # Based on suggestion at https://github.com/rails/sprockets-rails/issues/49#issuecomment-20535134
- # but limited to files in webshims namespaced asset directories.
- task create_non_digest_assets: :"assets:environment" do
- manifest_path = Dir.glob(File.join(Rails.root, "public/assets/.sprockets-manifest-*.json")).first
- manifest_data = JSON.load(File.new(manifest_path)) # rubocop:disable Security/JSONLoad
-
- manifest_data["assets"].each do |logical_path, digested_path|
- logical_pathname = Pathname.new logical_path
-
- if ["webshims/**/*"].any? { |testpath| logical_pathname.fnmatch?(testpath, File::FNM_PATHNAME) }
- full_digested_path = Rails.root.join("public/assets", digested_path)
- full_nondigested_path = Rails.root.join("public/assets", logical_path)
-
- logger.info "(Webshims) Copying to #{full_nondigested_path}"
-
- # Use FileUtils.copy_file with true third argument to copy
- # file attributes (eg mtime) too, as opposed to FileUtils.cp
- # Making symlnks with FileUtils.ln_s would be another option, not
- # sure if it would have unexpected issues.
- FileUtils.copy_file full_digested_path, full_nondigested_path, true
- end
- end
- end
-end
diff --git a/spec/controllers/action_page_controller_spec.rb b/spec/controllers/action_page_controller_spec.rb
index a4b51b512..fc112c341 100644
--- a/spec/controllers/action_page_controller_spec.rb
+++ b/spec/controllers/action_page_controller_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe ActionPageController, type: :controller do
include Devise::Test::ControllerHelpers
- let(:action_page) { FactoryGirl.create :action_page }
+ let(:action_page) { FactoryBot.create :action_page }
let(:admin) { login_as_admin }
let(:collaborator) { login_as_collaborator }
@@ -12,8 +12,8 @@
it "filters by category" do
action_page
- category = FactoryGirl.create(:category, title: "Privacy")
- privacy_action_page = FactoryGirl.create(:action_page, category: category)
+ category = FactoryBot.create(:category, title: "Privacy")
+ privacy_action_page = FactoryBot.create(:action_page, category: category)
get :index, params: { category: "Privacy" }
expect(assigns(:actionPages)).to contain_exactly(privacy_action_page)
end
@@ -42,19 +42,19 @@
end
it "redirects to an admin specified url if redirect is enabled" do
- action_page = FactoryGirl.create :action_page,
- enable_redirect: true,
- redirect_url: "https://example.com"
+ action_page = FactoryBot.create :action_page,
+ enable_redirect: true,
+ redirect_url: "https://example.com"
get :show, params: { id: action_page }
expect(response).to redirect_to "https://example.com"
end
context "archived" do
- let(:active_action_page) { FactoryGirl.create :action_page }
- let(:archived_action_page) {
- FactoryGirl.create :archived_action_page,
- active_action_page_for_redirect: active_action_page
- }
+ let(:active_action_page) { FactoryBot.create :action_page }
+ let(:archived_action_page) do
+ FactoryBot.create :archived_action_page,
+ active_action_page_for_redirect: active_action_page
+ end
it "redirects archived actions to active actions" do
get :show, params: { id: archived_action_page }
@@ -62,19 +62,19 @@
end
it "doesn't redirect away from victories" do
- archived_action_page.update_attributes(victory: true)
+ archived_action_page.update(victory: true)
get :show, params: { id: archived_action_page }
expect(response.status).to eq(200)
end
end
context "unpublished" do
- let(:unpublished_action_page) { FactoryGirl.create :action_page, published: false }
+ let(:unpublished_action_page) { FactoryBot.create :action_page, published: false }
it "hides unpublished pages from unprivileged users" do
- expect {
+ expect do
get :show, params: { id: unpublished_action_page }
- }.to raise_error ActiveRecord::RecordNotFound
+ end.to raise_error ActiveRecord::RecordNotFound
end
it "notifies admin users that a page is unpublished" do
@@ -94,30 +94,30 @@
describe "GET #show_by_institution" do
before(:each) do
# Petition with two institutions
- @petition = FactoryGirl.create(:local_organizing_petition)
+ @petition = FactoryBot.create(:local_organizing_petition)
@actionPage = @petition.action_page
- @actionPage.institutions << FactoryGirl.create(:institution)
+ @actionPage.institutions << FactoryBot.create(:institution)
# Signature with affiliations to two different institutions
- signature = FactoryGirl.create(:signature,
- petition: @petition)
- signature.affiliations << FactoryGirl.create(:affiliation,
- institution: @actionPage.institutions.first)
- signature.affiliations << FactoryGirl.create(:affiliation,
- institution: @actionPage.institutions.last)
+ signature = FactoryBot.create(:signature,
+ petition: @petition)
+ signature.affiliations << FactoryBot.create(:affiliation,
+ institution: @actionPage.institutions.first)
+ signature.affiliations << FactoryBot.create(:affiliation,
+ institution: @actionPage.institutions.last)
# Signature with an affiliation to the second institutions
- signature = FactoryGirl.create(:signature,
- petition: @petition)
- signature.affiliations << FactoryGirl.create(:affiliation,
- institution: @actionPage.institutions.last,
- affiliation_type: @actionPage.affiliation_types.first)
+ signature = FactoryBot.create(:signature,
+ petition: @petition)
+ signature.affiliations << FactoryBot.create(:affiliation,
+ institution: @actionPage.institutions.last,
+ affiliation_type: @actionPage.affiliation_types.first)
end
context "html" do
it "assigns signatures filtered by institution" do
get :show_by_institution, params: { id: @actionPage.id,
- institution_id: @actionPage.institutions.first.id }
+ institution_id: @actionPage.institutions.first.id }
expect(assigns(:institution)).to eq(@actionPage.institutions.first)
# it should assign signatures associated with the institution
diff --git a/spec/controllers/admin/institutions_controller_spec.rb b/spec/controllers/admin/institutions_controller_spec.rb
index 36fbbc72e..aea96fb17 100644
--- a/spec/controllers/admin/institutions_controller_spec.rb
+++ b/spec/controllers/admin/institutions_controller_spec.rb
@@ -6,17 +6,17 @@
# This should return the minimal set of attributes required to create a valid
# Admin::Institution. As you add validations to Admin::InstitutionSet, be sure to
# adjust the attributes here as well.
- let(:valid_attributes) {
+ let(:valid_attributes) do
{ name: "San Francisco State University", category: "University" }
- }
+ end
before(:each) do
# Admin login
@request.env["devise.mapping"] = Devise.mappings[:admin]
- sign_in FactoryGirl.create(:admin_user)
+ sign_in FactoryBot.create(:admin_user)
# Set parent action
- @actionPage = FactoryGirl.create(:action_page_with_petition)
+ @actionPage = FactoryBot.create(:action_page_with_petition)
end
describe "GET #index" do
@@ -30,18 +30,18 @@
describe "POST #create" do
context "with valid params" do
it "creates a new institution" do
- expect {
+ expect do
post :create, params: { action_page_id: @actionPage.id,
- institution: valid_attributes }
- }.to change(Institution, :count).by(1)
+ institution: valid_attributes }
+ end.to change(Institution, :count).by(1)
end
it "does not create duplicate institutions" do
- institution = Institution.create! valid_attributes
- expect {
+ Institution.create! valid_attributes
+ expect do
post :create, params: { action_page_id: @actionPage.id,
- institution: valid_attributes }
- }.to_not change(Institution, :count)
+ institution: valid_attributes }
+ end.to_not change(Institution, :count)
end
end
end
@@ -64,13 +64,13 @@
end
it "uploads institutions" do
- expect(Institution).
- to receive(:import).with(
- "University",
- ["University of California, Berkeley",
- "University of California, Davis",
- "University of California, Santa Cruz"]
- )
+ expect(Institution)
+ .to receive(:import).with(
+ "University",
+ ["University of California, Berkeley",
+ "University of California, Davis",
+ "University of California, Santa Cruz"]
+ )
import_and_work_off
end
end
@@ -92,9 +92,9 @@
describe "DELETE #destroy" do
it "deletes the institution" do
institution = Institution.create! valid_attributes
- expect {
+ expect do
delete :destroy, params: { id: institution.to_param }
- }.to change(Institution, :count).by(-1)
+ end.to change(Institution, :count).by(-1)
end
end
end
diff --git a/spec/controllers/admin/petitions_controller_spec.rb b/spec/controllers/admin/petitions_controller_spec.rb
index 86788eb7a..89592e07e 100644
--- a/spec/controllers/admin/petitions_controller_spec.rb
+++ b/spec/controllers/admin/petitions_controller_spec.rb
@@ -5,11 +5,11 @@
before(:each) do
@request.env["devise.mapping"] = Devise.mappings[:admin]
- sign_in FactoryGirl.create(:admin_user)
+ sign_in FactoryBot.create(:admin_user)
end
describe "GET #show" do
- let(:petition) { FactoryGirl.create(:petition) }
+ let(:petition) { FactoryBot.create(:petition) }
it "assigns @signatures" do
get :show, params: { id: petition.id, action_page_id: petition.action_page.id }
@@ -17,11 +17,11 @@
expect(response.status).to eq(200)
end
- it "passes the 'query' param through Signature.filter" do
+ it "passes the 'query' param through Signature.search" do
query = "jo@example.com"
expect(Petition).to receive(:find) { petition }
- expect(petition.signatures).to receive(:filter) do |q|
+ expect(petition.signatures).to receive(:search) do |q|
expect(q).to eq(query)
Signature.all
end
@@ -32,13 +32,13 @@
end
describe "DELETE #destroy_signatures" do
- let(:petition) { FactoryGirl.create(:petition) }
+ let(:petition) { FactoryBot.create(:petition) }
let(:signatures) do
- 30.times.map { FactoryGirl.create(:signature, petition: petition) }
+ 30.times.map { FactoryBot.create(:signature, petition: petition) }
end
it "should delete signatures from the signature_ids param" do
- delete :destroy_signatures, params: { id: petition.id, signature_ids: signatures[10..-1].map(&:id) }
+ delete :destroy_signatures, params: { id: petition.id, signature_ids: signatures[10..].map(&:id) }
expect(petition.signatures.reload).to contain_exactly(*signatures[0..9])
expect(response).to redirect_to(admin_action_page_petition_path(petition.action_page, petition))
end
diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb
index 419152a63..14655f69b 100644
--- a/spec/controllers/admin/users_controller_spec.rb
+++ b/spec/controllers/admin/users_controller_spec.rb
@@ -14,7 +14,7 @@
describe "PATCH #update" do
it "redirects" do
- patch :update, params: { id: FactoryGirl.create(:collaborator_user), user: { collaborator: "1" } }
+ patch :update, params: { id: FactoryBot.create(:collaborator_user), user: { collaborator: "1" } }
expect(response).to have_http_status(:found)
end
end
diff --git a/spec/controllers/concerns/logged_invisible_captcha_spec.rb b/spec/controllers/concerns/logged_invisible_captcha_spec.rb
index 7af02623c..bcbbd5d20 100644
--- a/spec/controllers/concerns/logged_invisible_captcha_spec.rb
+++ b/spec/controllers/concerns/logged_invisible_captcha_spec.rb
@@ -9,11 +9,11 @@ def create; end
it "blocks requests that fill the honeypot" do
expect(controller).not_to receive(:create)
- post :create, foo: "bar"
+ post :create, params: { foo: "bar" }
end
it "logs spammy requests to Sentry" do
expect(Raven).to receive(:capture_message)
- post :create, foo: "bar"
+ post :create, params: { foo: "bar" }
end
end
diff --git a/spec/controllers/concerns/request_origin_validation_spec.rb b/spec/controllers/concerns/request_origin_validation_spec.rb
index 64361b79f..842d22e8f 100644
--- a/spec/controllers/concerns/request_origin_validation_spec.rb
+++ b/spec/controllers/concerns/request_origin_validation_spec.rb
@@ -58,8 +58,8 @@
it "should raise an error for POST requests" do
request["post?"] = true
- expect { controller.verify_request_origin }.
- to raise_error(ActionController::InvalidCrossOriginRequest)
+ expect { controller.verify_request_origin }
+ .to raise_error(ActionController::InvalidCrossOriginRequest)
end
end
end
diff --git a/spec/controllers/subscriptions_controller_spec.rb b/spec/controllers/subscriptions_controller_spec.rb
index 384937958..2cbeb6646 100644
--- a/spec/controllers/subscriptions_controller_spec.rb
+++ b/spec/controllers/subscriptions_controller_spec.rb
@@ -31,26 +31,25 @@
end
describe "#edit" do
- let(:subscription) { FactoryGirl.create(:subscription) }
+ let(:subscription) { FactoryBot.create(:subscription) }
subject { get :edit, params: { id: subscription } }
it "redirects to supporters" do
- sign_in FactoryGirl.create(:user)
- expect(subject).to redirect_to(/#{Rails.application.secrets.supporters["host"]}/)
+ sign_in FactoryBot.create(:user)
+ expect(subject).to redirect_to(/#{Rails.application.secrets.supporters[:host]}/)
end
describe "without a successful connection to civicrm" do
before do
- stub_request(:post, CiviCRM::supporters_api_url).
- and_return(status: 400, body: "{}", headers: {})
+ stub_request(:post, CiviCRM.supporters_api_url)
+ .and_return(status: 400, body: "{}", headers: {})
end
it "fails gracefully" do
- sign_in FactoryGirl.create(:user)
+ sign_in FactoryBot.create(:user)
expect(subject).to redirect_to("/account")
expect(flash[:error]).to be_present
end
end
end
-
end
diff --git a/spec/controllers/tools_controller_spec.rb b/spec/controllers/tools_controller_spec.rb
index 4379d151b..03385f3e0 100644
--- a/spec/controllers/tools_controller_spec.rb
+++ b/spec/controllers/tools_controller_spec.rb
@@ -1,17 +1,19 @@
require "rails_helper"
RSpec.describe ToolsController, type: :controller do
- let(:valid_attributes) { {
- signature: {
- "petition_id" => "1",
- "email" => "rob@eff.org",
- "first_name" => "adsf",
- "last_name" => "asdf",
- "zipcode" => "94109",
- "city" => "",
- "country_code" => ""
+ let(:valid_attributes) do
+ {
+ signature: {
+ "petition_id" => "1",
+ "email" => "rob@eff.org",
+ "first_name" => "adsf",
+ "last_name" => "asdf",
+ "zipcode" => "94109",
+ "city" => "",
+ "country_code" => ""
+ }
}
- } }
+ end
before(:each) do
stub_smarty_streets
@@ -45,24 +47,26 @@
describe "#call" do
it "should CallTool#campaign_call, passing parameters in" do
- call_campaign = FactoryGirl.create(:call_campaign)
+ call_campaign = FactoryBot.create(:call_campaign)
expect(CallTool).to receive(:campaign_call)
post :call, params: {
- phone: "000-000-0000",
- location: "00000",
- call_campaign_id: call_campaign.id,
- action_id: call_campaign.action_page.id
- }
+ phone: "000-000-0000",
+ location: "00000",
+ call_campaign_id: call_campaign.id,
+ action_id: call_campaign.action_page.id
+ }
end
end
describe "#email" do
- let(:email_campaign) { FactoryGirl.create(:email_campaign) }
+ let(:email_campaign) { FactoryBot.create(:email_campaign) }
it "should redirect to ActionPage#service_uri(service)" do
- service, uri = "gmail", "https://composeurl.example.com"
- expect(ActionPage).to receive(:find_by_id) { email_campaign.action_page }
+ action_page = email_campaign.action_page
+ service = "gmail"
+ uri = "https://composeurl.example.com"
+ expect(ActionPage).to receive(:find_by).with(id: action_page.id.to_s) { action_page }
expect(email_campaign).to receive(:service_uri).with(service) { uri }
get :email, params: { action_id: email_campaign.action_page.id, service: service }
expect(response).to redirect_to(uri)
@@ -71,7 +75,7 @@
end
def create_signature_and_have_user_sign
- @petition = FactoryGirl.create(:petition_with_99_signatures_needing_1_more)
+ @petition = FactoryBot.create(:petition_with_99_signatures_needing_1_more)
post :petition, params: { signature: valid_attributes[:signature].merge({ "petition_id" => @petition.id.to_s }) }
end
diff --git a/spec/factories/action_page.rb b/spec/factories/action_page.rb
index 1ef32505e..f79f03795 100644
--- a/spec/factories/action_page.rb
+++ b/spec/factories/action_page.rb
@@ -1,52 +1,52 @@
-FactoryGirl.define do
+FactoryBot.define do
factory :action_page do
- title "Sample Action Page"
- summary "not filling in summary"
- description "not filling desc in"
- published true
- email_text "$NAME, thanks for taking action!"
- victory_message "We won"
+ title { "Sample Action Page" }
+ summary { "not filling in summary" }
+ description { "not filling desc in" }
+ published { true }
+ email_text { "$NAME, thanks for taking action!" }
+ victory_message { "We won" }
trait :with_partner do
- after(:create) do |action_page, evaluator|
- action_page.partners << FactoryGirl.create(:partner)
+ after(:create) do |action_page, _evaluator|
+ action_page.partners << FactoryBot.create(:partner)
end
end
end
factory :action_page_with_petition, parent: :action_page do
- enable_petition true
+ enable_petition { true }
end
factory :action_page_with_tweet, parent: :action_page do
- enable_tweet true
+ enable_tweet { true }
end
factory :action_page_with_call, parent: :action_page do
- enable_call true
+ enable_call { true }
end
factory :action_page_with_email, parent: :action_page do
- enable_email true
+ enable_email { true }
end
factory :action_page_with_congress_message, parent: :action_page do
- enable_congress_message true
+ enable_congress_message { true }
congress_message_campaign
end
factory :archived_action_page, parent: :action_page do
- archived true
+ archived { true }
association :active_action_page_for_redirect, factory: :action_page
- victory false
+ victory { false }
end
factory :action_page_with_views, parent: :action_page do
- after(:build) do |action_page, evaluator|
+ after(:build) do |action_page, _evaluator|
10.times do |n|
- FactoryGirl.create(:ahoy_view,
- action_page: action_page,
- time: Time.zone.now - n.days)
+ FactoryBot.create(:ahoy_view,
+ action_page: action_page,
+ time: Time.zone.now - n.days)
end
end
end
diff --git a/spec/factories/affiliation_types.rb b/spec/factories/affiliation_types.rb
index df1b7ca42..8967288c5 100644
--- a/spec/factories/affiliation_types.rb
+++ b/spec/factories/affiliation_types.rb
@@ -1,5 +1,5 @@
-FactoryGirl.define do
+FactoryBot.define do
factory :affiliation_type do
- name "Student"
+ name { "Student" }
end
end
diff --git a/spec/factories/affiliations.rb b/spec/factories/affiliations.rb
index 615d9c889..2b6ec65fa 100644
--- a/spec/factories/affiliations.rb
+++ b/spec/factories/affiliations.rb
@@ -1,4 +1,4 @@
-FactoryGirl.define do
+FactoryBot.define do
factory :affiliation do
institution
affiliation_type
diff --git a/spec/factories/ahoy_event.rb b/spec/factories/ahoy_event.rb
index d8d0b1311..e76aaba5f 100644
--- a/spec/factories/ahoy_event.rb
+++ b/spec/factories/ahoy_event.rb
@@ -1,21 +1,25 @@
-FactoryGirl.define do
+FactoryBot.define do
factory :ahoy_view, class: Ahoy::Event do
id { SecureRandom.uuid }
- name "View"
- properties { {
- type: "action",
- actionType: "view"
- } }
- time Time.zone.now
+ name { "View" }
+ properties do
+ {
+ type: "action",
+ actionType: "view"
+ }
+ end
+ time { Time.zone.now }
end
factory :ahoy_signature, class: Ahoy::Event do
id { SecureRandom.uuid }
- name "Action"
- properties { {
- type: "action",
- actionType: "signature"
- } }
- time Time.zone.now
+ name { "Action" }
+ properties do
+ {
+ type: "action",
+ actionType: "signature"
+ }
+ end
+ time { Time.zone.now }
end
end
diff --git a/spec/factories/call_campaigns.rb b/spec/factories/call_campaigns.rb
index 63e4b61b4..fdbcebdcc 100644
--- a/spec/factories/call_campaigns.rb
+++ b/spec/factories/call_campaigns.rb
@@ -1,10 +1,10 @@
-FactoryGirl.define do
+FactoryBot.define do
factory :call_campaign do
- title "a call campaign"
- call_campaign_id 1
+ title { "a call campaign" }
+ call_campaign_id { 1 }
after(:create) do |campaign|
- FactoryGirl.create(:action_page_with_call, call_campaign_id: campaign.id)
+ FactoryBot.create(:action_page_with_call, call_campaign_id: campaign.id)
end
end
end
diff --git a/spec/factories/categories.rb b/spec/factories/categories.rb
index 0c5b53a1a..e9de41bf0 100644
--- a/spec/factories/categories.rb
+++ b/spec/factories/categories.rb
@@ -1,5 +1,5 @@
-FactoryGirl.define do
+FactoryBot.define do
factory :category do
- title "Free Speech"
+ title { "Free Speech" }
end
end
diff --git a/spec/factories/congress_member.rb b/spec/factories/congress_member.rb
index 5fb948655..8f91bb380 100644
--- a/spec/factories/congress_member.rb
+++ b/spec/factories/congress_member.rb
@@ -1,12 +1,12 @@
-FactoryGirl.define do
+FactoryBot.define do
factory :congress_member do
sequence(:bioguide_id) { |n| "A00000#{n}" }
- term_end (Time.now + 1.year).strftime("%Y-%m-%d")
- full_name "Alice Mars"
- first_name "Alice"
- last_name "Mars"
- twitter_id "AliceMars"
- chamber "senate"
- state "CA"
+ term_end { (Time.zone.now + 1.year).strftime("%Y-%m-%d") }
+ full_name { "Alice Mars" }
+ first_name { "Alice" }
+ last_name { "Mars" }
+ twitter_id { "AliceMars" }
+ chamber { "senate" }
+ state { "CA" }
end
end
diff --git a/spec/factories/congress_message.rb b/spec/factories/congress_message.rb
index 0dd0740fc..99216d7eb 100644
--- a/spec/factories/congress_message.rb
+++ b/spec/factories/congress_message.rb
@@ -1,22 +1,22 @@
-FactoryGirl.define do
+FactoryBot.define do
form1 = CongressForms::Form.new("C000880", [
- { "value" => "$NAME_FIRST" },
- { "value" => "$NAME_LAST" },
- { "value" => "$ADDRESS_STATE", "options_hash" => {
- "CALIFORNIA" => "CA",
- "NEW YORK" => "NY"
- } }
- ])
+ { "value" => "$NAME_FIRST" },
+ { "value" => "$NAME_LAST" },
+ { "value" => "$ADDRESS_STATE", "options_hash" => {
+ "CALIFORNIA" => "CA",
+ "NEW YORK" => "NY"
+ } }
+ ])
form2 = CongressForms::Form.new("C000881", [
- { "value" => "$ADDRESS_CITY" },
- { "value" => "$ADDRESS_STATE", "options_hash" => {
- "CALIFORNIA" => "CA",
- "NEW YORK" => "NY"
- } }
- ])
+ { "value" => "$ADDRESS_CITY" },
+ { "value" => "$ADDRESS_STATE", "options_hash" => {
+ "CALIFORNIA" => "CA",
+ "NEW YORK" => "NY"
+ } }
+ ])
factory :congress_message do
- forms [form1, form2]
+ forms { [form1, form2] }
end
end
diff --git a/spec/factories/congress_message_campaigns.rb b/spec/factories/congress_message_campaigns.rb
index 528955ab5..3c314d0dc 100644
--- a/spec/factories/congress_message_campaigns.rb
+++ b/spec/factories/congress_message_campaigns.rb
@@ -1,15 +1,15 @@
-FactoryGirl.define do
+FactoryBot.define do
factory :congress_message_campaign do
- subject "a subject"
- message "a message"
- campaign_tag "a campaign tag"
+ subject { "a subject" }
+ message { "a message" }
+ campaign_tag { "a campaign tag" }
trait :targeting_bioguide_ids do
- target_bioguide_ids "C000880"
+ target_bioguide_ids { "C000880" }
end
trait :targeting_senate do
- target_house false
+ target_house { false }
end
end
end
diff --git a/spec/factories/email_campaigns.rb b/spec/factories/email_campaigns.rb
index 5f0de73ad..e335aaea5 100644
--- a/spec/factories/email_campaigns.rb
+++ b/spec/factories/email_campaigns.rb
@@ -1,11 +1,11 @@
-FactoryGirl.define do
+FactoryBot.define do
factory :email_campaign do
- email_addresses "a@example.com, b@example.com"
- subject "a subject"
- message "a message"
+ email_addresses { "a@example.com, b@example.com" }
+ subject { "a subject" }
+ message { "a message" }
after(:create) do |campaign|
- FactoryGirl.create(:action_page_with_email, email_campaign_id: campaign.id)
+ FactoryBot.create(:action_page_with_email, email_campaign_id: campaign.id)
end
end
end
diff --git a/spec/factories/institutions.rb b/spec/factories/institutions.rb
index ca2d6f692..59c1d5a98 100644
--- a/spec/factories/institutions.rb
+++ b/spec/factories/institutions.rb
@@ -1,6 +1,6 @@
-FactoryGirl.define do
+FactoryBot.define do
factory :institution do
sequence(:name) { |n| "University of Wherever #{n}" }
- category "University"
+ category { "University" }
end
end
diff --git a/spec/factories/partners.rb b/spec/factories/partners.rb
index e1e870999..e8ecb57ce 100644
--- a/spec/factories/partners.rb
+++ b/spec/factories/partners.rb
@@ -1,6 +1,6 @@
-FactoryGirl.define do
+FactoryBot.define do
factory :partner do
- name "Another Activist Org"
+ name { "Another Activist Org" }
sequence(:code) { |n| "p#{n}" }
end
end
diff --git a/spec/factories/petitions.rb b/spec/factories/petitions.rb
index 8c6972415..0249666e1 100644
--- a/spec/factories/petitions.rb
+++ b/spec/factories/petitions.rb
@@ -1,38 +1,38 @@
-FactoryGirl.define do
+FactoryBot.define do
factory :petition do
- sequence(:title) { |n| "petition-#{n}" }
- description "A sample Petition"
- goal 100
+ sequence(:title) { |n| "petition-#{n}" }
+ description { "A sample Petition" }
+ goal { 100 }
after(:create) do |petition|
- FactoryGirl.create(:action_page_with_petition, petition_id: petition.id)
+ FactoryBot.create(:action_page_with_petition, petition_id: petition.id)
end
end
factory :petition_complete_with_one_hundred_signatures, parent: :petition do
after(:create) do |petition|
- 100.times { petition.signatures << FactoryGirl.build(:signature, petition_id: petition.id) }
+ 100.times { petition.signatures << FactoryBot.build(:signature, petition_id: petition.id) }
end
end
factory :petition_with_99_signatures_needing_1_more, parent: :petition do
after(:create) do |petition|
- 99.times { petition.signatures << FactoryGirl.build(:signature, petition_id: petition.id) }
+ 99.times { petition.signatures << FactoryBot.build(:signature, petition_id: petition.id) }
end
end
factory :petition_complete_with_one_thousand_signatures, parent: :petition do
after(:create) do |petition|
- 1000.times { petition.signatures << FactoryGirl.build(:signature, petition_id: petition.id) }
+ 1000.times { petition.signatures << FactoryBot.build(:signature, petition_id: petition.id) }
end
end
factory :local_organizing_petition, parent: :petition do
- enable_affiliations true
+ enable_affiliations { true }
after(:create) do |petition|
- petition.action_page.institutions << FactoryGirl.build(:institution)
- petition.action_page.affiliation_types << FactoryGirl.build(:affiliation_type)
+ petition.action_page.institutions << FactoryBot.build(:institution)
+ petition.action_page.affiliation_types << FactoryBot.build(:affiliation_type)
end
end
end
diff --git a/spec/factories/signatures.rb b/spec/factories/signatures.rb
index 5a3926cf2..195999334 100644
--- a/spec/factories/signatures.rb
+++ b/spec/factories/signatures.rb
@@ -1,13 +1,13 @@
-FactoryGirl.define do
+FactoryBot.define do
factory :signature do
- first_name "John"
- last_name "Doe"
+ first_name { "John" }
+ last_name { "Doe" }
sequence(:email) { |n| "signer-#{n}@example.com" }
- country_code "US"
- zipcode "94109"
- street_address "815 Eddy St"
- city "San Francisco"
- state "California"
- anonymous false
+ country_code { "US" }
+ zipcode { "94109" }
+ street_address { "815 Eddy St" }
+ city { "San Francisco" }
+ state { "California" }
+ anonymous { false }
end
end
diff --git a/spec/factories/source_file.rb b/spec/factories/source_file.rb
index 269e2f568..310f29c46 100644
--- a/spec/factories/source_file.rb
+++ b/spec/factories/source_file.rb
@@ -1,6 +1,6 @@
-FactoryGirl.define do
+FactoryBot.define do
factory :source_file do
- key "uploaded_files/meh.jpg"
+ key { "uploaded_files/meh.jpg" }
to_create { |instance| instance.save(validate: false) } # skip before filters
end
diff --git a/spec/factories/subscriptions.rb b/spec/factories/subscriptions.rb
index 07a442937..f247a6f23 100644
--- a/spec/factories/subscriptions.rb
+++ b/spec/factories/subscriptions.rb
@@ -1,7 +1,7 @@
-FactoryGirl.define do
+FactoryBot.define do
factory :subscription do
- first_name "John"
- last_name "Doe"
+ first_name { "John" }
+ last_name { "Doe" }
sequence(:email) { |n| "signer-#{n}@example.com" }
partner { |a| a.association :partner }
end
diff --git a/spec/factories/topic.rb b/spec/factories/topic.rb
index b914813fc..7b9a5e6f3 100644
--- a/spec/factories/topic.rb
+++ b/spec/factories/topic.rb
@@ -1,4 +1,4 @@
-FactoryGirl.define do
+FactoryBot.define do
factory :topic do
sequence(:name) { |n| "Vampire#{n}" }
end
diff --git a/spec/factories/topic_category.rb b/spec/factories/topic_category.rb
index 061dbae76..1ae77fd8a 100644
--- a/spec/factories/topic_category.rb
+++ b/spec/factories/topic_category.rb
@@ -1,8 +1,8 @@
-FactoryGirl.define do
+FactoryBot.define do
factory :topic_category do
- name "Demons"
+ name { "Demons" }
- after(:create) do |category, evaluator|
+ after(:create) do |category, _evaluator|
create_list(:topic_set, 2, topic_category: category)
end
end
diff --git a/spec/factories/topic_set.rb b/spec/factories/topic_set.rb
index 7a5a2d571..ed7171a49 100644
--- a/spec/factories/topic_set.rb
+++ b/spec/factories/topic_set.rb
@@ -1,8 +1,8 @@
-FactoryGirl.define do
+FactoryBot.define do
factory :topic_set do
sequence(:tier) { |n| n }
- after(:create) do |set, evaluator|
+ after(:create) do |set, _evaluator|
create_list(:topic, 2, topic_set: set)
end
end
diff --git a/spec/factories/tweets.rb b/spec/factories/tweets.rb
index f3737878c..5f6285821 100644
--- a/spec/factories/tweets.rb
+++ b/spec/factories/tweets.rb
@@ -1,13 +1,13 @@
-FactoryGirl.define do
+FactoryBot.define do
factory :tweet do
- message "Please protect my right to use the Internet safely"
+ message { "Please protect my right to use the Internet safely" }
after(:create) do |tweet|
- FactoryGirl.create(:action_page_with_tweet, tweet_id: tweet.id)
+ FactoryBot.create(:action_page_with_tweet, tweet_id: tweet.id)
end
end
factory :tweet_targeting_senate, parent: :tweet do
- target_senate true
+ target_senate { true }
end
end
diff --git a/spec/factories/users.rb b/spec/factories/users.rb
index 2dc8954c4..efb6f8609 100644
--- a/spec/factories/users.rb
+++ b/spec/factories/users.rb
@@ -1,15 +1,13 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
-FactoryGirl.define do
+FactoryBot.define do
factory :unconfirmed_user, class: User do
sequence(:email, ActiveRecord::Base.connection.table_exists?("users") ? User.next_id : 0) { |n| "person_#{n}@example.com" }
- password "strong passwords defeat lobsters covering wealth"
+ password { "strong passwords defeat lobsters covering wealth" }
end
factory :user, parent: :unconfirmed_user do
- after(:build) do |user|
- user.skip_confirmation!
- end
+ after(:build, &:skip_confirmation!)
end
factory :admin_user, parent: :user do
diff --git a/spec/features/action_pages/call_action_spec.rb b/spec/features/action_pages/call_action_spec.rb
index 2c09c4baa..d37fed016 100644
--- a/spec/features/action_pages/call_action_spec.rb
+++ b/spec/features/action_pages/call_action_spec.rb
@@ -2,14 +2,14 @@
RSpec.feature "Call actions", type: :feature, js: true do
let!(:action) do
- FactoryGirl.create(:call_campaign).action_page
+ FactoryBot.create(:call_campaign).action_page
end
let!(:calltool_request) do
{
- "objects" => [{ "id" => 1, "name" => "call someone", "status" => "live" }],
- "required_fields" => { "userLocation" => "" },
- "page" => 1,
- "total_pages" => 1
+ "objects" => [{ "id" => 1, "name" => "call someone", "status" => "live" }],
+ "required_fields" => { "userLocation" => "" },
+ "page" => 1,
+ "total_pages" => 1
}.to_json
end
diff --git a/spec/features/action_pages/congress_action_spec.rb b/spec/features/action_pages/congress_action_spec.rb
index 7dc267a68..8f6fb197f 100644
--- a/spec/features/action_pages/congress_action_spec.rb
+++ b/spec/features/action_pages/congress_action_spec.rb
@@ -2,15 +2,15 @@
RSpec.feature "Congress actions", type: :feature, js: true do
let!(:action) do
- FactoryGirl.create(:action_page_with_congress_message)
+ FactoryBot.create(:action_page_with_congress_message)
end
- let!(:members) {
- [FactoryGirl.create(:congress_member,
- twitter_id: "sisko",
- state: "CA", bioguide_id: "C000880"),
- FactoryGirl.create(:congress_member, state: "CA", bioguide_id: "A000360")]
- }
- let(:location) {
+ let!(:members) do
+ [FactoryBot.create(:congress_member,
+ twitter_id: "sisko",
+ state: "CA", bioguide_id: "C000880"),
+ FactoryBot.create(:congress_member, state: "CA", bioguide_id: "A000360")]
+ end
+ let(:location) do
OpenStruct.new(success: true,
street: "1630 Ravello Drive",
city: "Sunnydale",
@@ -18,16 +18,16 @@
zip4: 1234,
state: "CA",
district: 10)
- }
+ end
before do
allow(SmartyStreets).to receive(:get_location).and_return(location)
- stub_request(:post, /retrieve-form-elements/).
- with(body: { "bio_ids" => ["C000880", "A000360"] }).
- and_return(status: 200, body: file_fixture("retrieve-form-elements.json"))
- stub_request(:post, /retrieve-form-elements/).
- with(body: { "bio_ids" => ["", "C000880", "A000360"] }).
- and_return(status: 200, body: file_fixture("retrieve-form-elements.json"))
+ stub_request(:post, /retrieve-form-elements/)
+ .with(body: { "bio_ids" => %w[C000880 A000360] })
+ .and_return(status: 200, body: file_fixture("retrieve-form-elements.json"))
+ stub_request(:post, /retrieve-form-elements/)
+ .with(body: { "bio_ids" => ["", "C000880", "A000360"] })
+ .and_return(status: 200, body: file_fixture("retrieve-form-elements.json"))
stub_request(:post, /fill-out-form/).and_return(status: 200, body: "{}")
end
diff --git a/spec/features/action_pages/email_action_spec.rb b/spec/features/action_pages/email_action_spec.rb
index 31a464955..3592b1db5 100644
--- a/spec/features/action_pages/email_action_spec.rb
+++ b/spec/features/action_pages/email_action_spec.rb
@@ -2,7 +2,7 @@
RSpec.feature "Email actions", type: :feature, js: true do
let!(:action) do
- FactoryGirl.create(:email_campaign).action_page
+ FactoryBot.create(:email_campaign).action_page
end
it "allows vistors to send emails" do
visit action_page_path(action)
diff --git a/spec/features/action_pages/petition_action_spec.rb b/spec/features/action_pages/petition_action_spec.rb
index b206605b2..50d7638fd 100644
--- a/spec/features/action_pages/petition_action_spec.rb
+++ b/spec/features/action_pages/petition_action_spec.rb
@@ -2,7 +2,7 @@
RSpec.feature "Petition actions", type: :feature, js: true do
let!(:action) do
- FactoryGirl.create(:petition).action_page
+ FactoryBot.create(:petition).action_page
end
let(:location) { OpenStruct.new(city: "Sunnydale", state: "CA") }
diff --git a/spec/features/action_pages/tweet_action_spec.rb b/spec/features/action_pages/tweet_action_spec.rb
index a61ff43b8..4f177ab89 100644
--- a/spec/features/action_pages/tweet_action_spec.rb
+++ b/spec/features/action_pages/tweet_action_spec.rb
@@ -2,15 +2,15 @@
RSpec.feature "Tweet actions", type: :feature, js: true do
let!(:tweet_action) do
- FactoryGirl.create(:tweet, message: "Default message").action_page
+ FactoryBot.create(:tweet, message: "Default message").action_page
end
- let!(:members) {
- [FactoryGirl.create(:congress_member,
- twitter_id: "sisko",
- state: "CA", bioguide_id: "C000880"),
- FactoryGirl.create(:congress_member, state: "CA", bioguide_id: "A000360")]
- }
- let(:location) {
+ let!(:members) do
+ [FactoryBot.create(:congress_member,
+ twitter_id: "sisko",
+ state: "CA", bioguide_id: "C000880"),
+ FactoryBot.create(:congress_member, state: "CA", bioguide_id: "A000360")]
+ end
+ let(:location) do
OpenStruct.new(success: true,
street: "1630 Ravello Drive",
city: "Sunnydale",
@@ -18,7 +18,7 @@
zip4: 1234,
state: "CA",
district: 10)
- }
+ end
before do
allow(SmartyStreets).to receive(:get_location).and_return(location)
@@ -26,15 +26,11 @@
it "allows vistors to tweet at representatives" do
visit action_page_path(tweet_action)
-
expect(page).not_to have_content("THANK YOU!")
fill_in "street_address", with: "1630 Ravello Drive"
fill_in "zipcode", with: "94109"
click_on "Look up your reps"
-
- expect(page).to have_content("Default message")
click_on "Tweet @sisko"
-
expect(page).to have_content("THANK YOU!")
end
end
diff --git a/spec/features/admin/action_creation_spec.rb b/spec/features/admin/action_creation_spec.rb
index ec9fc701e..73f3a381d 100644
--- a/spec/features/admin/action_creation_spec.rb
+++ b/spec/features/admin/action_creation_spec.rb
@@ -1,28 +1,28 @@
require "rails_helper"
RSpec.describe "Admin action page creation", type: :feature, js: true do
- before { sign_in_user(FactoryGirl.create(:admin_user)) }
- let!(:category) { FactoryGirl.create(:category, title: "Privacy") }
+ before { sign_in_user(FactoryBot.create(:admin_user)) }
+ let!(:category) { FactoryBot.create(:category, title: "Privacy") }
it "can create tweet actions" do
visit new_admin_action_page_path
fill_in_basic_info(title: "Very Important Action",
summary: "A summary",
description: "A description")
- click_on "Next"
+ next_section
select_action_type("tweet")
fill_in "Message", with: "A message"
- click_on "Next"
+ next_section
+
+ # skip banner selection
+ next_section
- skip_image_selection
fill_in_social_media
- # Skip partners
- click_on "Next"
- tempermental {
+ tempermental do
click_button "Save"
expect(page).to have_content("Very Important Action", wait: 10)
- }
+ end
end
it "can create basic petition actions" do
@@ -30,23 +30,23 @@
fill_in_basic_info(title: "Very Important Action",
summary: "A summary",
description: "A description")
- click_on "Next"
+ next_section
select_action_type("petition")
fill_in_editor "#action_page_petition_attributes_description",
- with: "A petititon letter"
+ with: "A petititon letter"
fill_in "Goal", with: 1000
- click_on "Next"
+ next_section
+
+ # skip banner selection
+ next_section
- skip_image_selection
fill_in_social_media
- # Skip partners
- click_on "Next"
- tempermental {
+ tempermental do
click_button "Save"
expect(page).to have_content("Very Important Action", wait: 10)
- }
+ end
end
it "can create email actions" do
@@ -54,23 +54,23 @@
fill_in_basic_info(title: "Very Important Action",
summary: "A summary",
description: "A description")
- click_on "Next"
+ next_section
select_action_type("email")
fill_in "To", with: "test@gmail.com"
fill_in "Subject", with: "Subject"
fill_in "Message", with: "An email"
- click_on "Next"
+ next_section
+
+ # skip banner selection
+ next_section
- skip_image_selection
fill_in_social_media
- # Skip partners
- click_on "Next"
- tempermental {
+ tempermental do
click_button "Save"
expect(page).to have_content("Very Important Action", wait: 10)
- }
+ end
end
it "can create congress actions" do
@@ -78,22 +78,22 @@
fill_in_basic_info(title: "Very Important Action",
summary: "A summary",
description: "A description")
- click_on "Next"
+ next_section
select_action_type("congress_message")
fill_in "Subject", with: "Subject"
fill_in "Message", with: "A message"
- click_on "Next"
+ next_section
+
+ # skip banner selection
+ next_section
- skip_image_selection
fill_in_social_media
- # Skip partners
- click_on "Next"
- tempermental {
+ tempermental do
click_button "Save"
expect(page).to have_content("Very Important Action", wait: 10)
- }
+ end
end
it "can create call actions" do
@@ -101,22 +101,22 @@
fill_in_basic_info(title: "Very Important Action",
summary: "A summary",
description: "A description")
- click_on "Next"
+ next_section
select_action_type "call"
fill_in_editor "#action_page_call_campaign_attributes_message",
- with: "Call script"
- click_on "Next"
+ with: "Call script"
+ next_section
+
+ # skip banner selection
+ next_section
- skip_image_selection
fill_in_social_media
- # Skip partners
- click_on "Next"
- tempermental {
+ tempermental do
click_button "Save"
expect(page).to have_content("Very Important Action", wait: 10)
- }
+ end
end
def fill_in_basic_info(title:, summary:, description:)
@@ -126,17 +126,15 @@ def fill_in_basic_info(title:, summary:, description:)
fill_in_select2 "#action_page_category_id", with: category.title
end
- def skip_image_selection
+ def next_section
click_on "Next"
- sleep 0.1
- click_on "Next"
- sleep 0.1
+ sleep 0.05
end
def fill_in_social_media
fill_in "Share Message", with: "Twitter message"
fill_in "Title", with: "A social media title"
- click_on "Next"
+ next_section
end
def select_action_type(type)
diff --git a/spec/features/admin/previews_spec.rb b/spec/features/admin/previews_spec.rb
index 11b69850a..522427e06 100644
--- a/spec/features/admin/previews_spec.rb
+++ b/spec/features/admin/previews_spec.rb
@@ -1,12 +1,12 @@
require "rails_helper"
RSpec.describe "Admin action page previews", type: :feature, js: true do
- before { sign_in_user(FactoryGirl.create(:admin_user)) }
+ before { sign_in_user(FactoryBot.create(:admin_user)) }
xit "works for tweet actions" do
# window switching is broken, fixing previews for now
- tweet = FactoryGirl.create(:tweet)
- action = FactoryGirl.create(:action_page_with_tweet, tweet: tweet)
+ tweet = FactoryBot.create(:tweet)
+ action = FactoryBot.create(:action_page_with_tweet, tweet: tweet)
visit edit_admin_action_page_path(action)
fill_in "Title", with: "New title"
click_on "Action"
diff --git a/spec/features/congress_message.rb b/spec/features/congress_message.rb
index c412e4846..e227c72ec 100644
--- a/spec/features/congress_message.rb
+++ b/spec/features/congress_message.rb
@@ -1,14 +1,14 @@
require "rails_helper"
RSpec.feature "Submit congress message", type: :feature do
- let(:action_page) { FactoryGirl.create(:action_page_with_congress_message, :with_partner) }
+ let(:action_page) { FactoryBot.create(:action_page_with_congress_message, :with_partner) }
let(:partner) { action_page.partners.first }
- let!(:members) {
- [FactoryGirl.create(:congress_member, state: "CA", bioguide_id: "C000880"),
- FactoryGirl.create(:congress_member, state: "CA", bioguide_id: "A000360")]
- }
+ let!(:members) do
+ [FactoryBot.create(:congress_member, state: "CA", bioguide_id: "C000880"),
+ FactoryBot.create(:congress_member, state: "CA", bioguide_id: "A000360")]
+ end
let(:location) do
OpenStruct.new(success: true,
@@ -25,16 +25,16 @@
allow(SmartyStreets).to receive(:get_location).and_return(location)
- stub_request(:post, /retrieve-form-elements/).
- with(body: { "bio_ids" => ["C000880", "A000360"] }).
- and_return(status: 200, body: file_fixture("retrieve-form-elements.json"))
+ stub_request(:post, /retrieve-form-elements/)
+ .with(body: { "bio_ids" => %w[C000880 A000360] })
+ .and_return(status: 200, body: file_fixture("retrieve-form-elements.json"))
- stub_request(:post, /fill-out-form/).
- and_return(status: 200, body: "{}")
+ stub_request(:post, /fill-out-form/)
+ .and_return(status: 200, body: "{}")
end
scenario "User submits a congress message and subscribes to newletters" do
- visit "/action/#{action_page.title.downcase.gsub(" ", "-")}?partner=#{partner.code}"
+ visit "/action/#{action_page.title.downcase.tr(' ', '-')}?partner=#{partner.code}"
fill_in "street_address", with: "The Library"
fill_in "zipcode", with: "94109"
click_button "Submit your message"
@@ -51,20 +51,20 @@
expect(page).to have_content "Now help spread the word"
expect(partner.subscriptions.count).to eq 1
- expect(WebMock).to have_requested(:post, CiviCRM::supporters_api_url).
- with(body: hash_including({
- data: '{"contact_params":{"email":"mrgiles@sunnydale.edu","first_name":"Rupert","last_name":"Giles","source":"action center congress message :: Sample Action Page","subscribe":true,"opt_in":true},"address_params":{"city":"Sunnydale","state":null,"street":"The Library","zip":"94109","country":null},"phone":null}'
- }))
+ expect(WebMock).to have_requested(:post, CiviCRM.supporters_api_url)
+ .with(body: hash_including({
+ data: '{"contact_params":{"email":"mrgiles@sunnydale.edu","first_name":"Rupert","last_name":"Giles","source":"action center congress message :: Sample Action Page","subscribe":true,"opt_in":true},"address_params":{"city":"Sunnydale","state":null,"street":"The Library","zip":"94109","country":null},"phone":null}'
+ }))
end
scenario "Logged in user submits a congress message" do
- giles = FactoryGirl.create(:user,
- first_name: "Rupert",
- last_name: "Giles",
- email: "mrgiles@sunnydale.edu")
+ giles = FactoryBot.create(:user,
+ first_name: "Rupert",
+ last_name: "Giles",
+ email: "mrgiles@sunnydale.edu")
sign_in_user(giles)
- visit "/action/#{action_page.title.downcase.gsub(" ", "-")}"
+ visit "/action/#{action_page.title.downcase.tr(' ', '-')}"
click_button "Submit your message"
fill_in "common_attributes__NAME_FIRST", with: "Ripper"
diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb
deleted file mode 100644
index 106598e70..000000000
--- a/spec/features/users_spec.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-require "rails_helper"
-
-RSpec.describe "Tests about users", type: :feature do
- before(:each) do
- stub_civicrm
- @user = FactoryGirl.create(:user)
- end
-
- it "promoted users lose their old password and need a strong one" do
- sign_in_user(@user)
-
- # Test that we can see that we're at the /account page fine
- expect(page).to have_content("Personal information")
-
- # log user out
- find("input[value='Logout']", match: :first).click
-
- #promote user to activist
- @user.admin = true
- @user.save
-
- # try to login and see prompt to add password
- sign_in_user(@user)
- expect(page).not_to have_content("Personal information")
-
- # try navigating anywhere else to make sure they can't get around it
- visit "/admin/action_pages"
- expect(page).to have_content("Your account has been flagged for importance")
-
- # Submit a strong password and move on like an adult
- fill_in "Current Password", with: @user.password
- fill_in "New Password", with: "P1" + @user.password
- fill_in "Confirm New Password", with: "P1" + @user.password
- click_button "Submit"
-
- # check that the password update nag screen is eliminated
- visit "/account"
- expect(page).to have_content("Personal information")
- end
-end
diff --git a/spec/lib/action_cloner_spec.rb b/spec/lib/action_cloner_spec.rb
index 4882833e9..f7942e91b 100644
--- a/spec/lib/action_cloner_spec.rb
+++ b/spec/lib/action_cloner_spec.rb
@@ -2,51 +2,51 @@
describe ActionCloner do
it "does not persist action pages" do
- page = FactoryGirl.create(:action_page)
+ page = FactoryBot.create(:action_page)
clone = described_class.run(page)
expect(clone).not_to be_persisted
end
it "returns an ActionPage with cloned attributes" do
- page = FactoryGirl.create(:action_page)
+ page = FactoryBot.create(:action_page)
clone_attrs = filter_attrs(described_class.run(page).attributes)
expect(clone_attrs).to eq(filter_attrs(page.attributes))
end
it "returns a draft action page" do
- page = FactoryGirl.build(:action_page)
+ page = FactoryBot.build(:action_page)
clone = described_class.run(page)
expect(clone).not_to be_published
end
it "does not return an archived page" do
- page = FactoryGirl.build(:action_page, archived: true)
+ page = FactoryBot.build(:action_page, archived: true)
clone = described_class.run(page)
expect(clone).not_to be_archived
end
it "does not return a victory page" do
- page = FactoryGirl.build(:action_page, victory: true)
+ page = FactoryBot.build(:action_page, victory: true)
clone = described_class.run(page)
expect(clone).not_to be_victory
end
it "retains its category" do
- page = FactoryGirl.create(:action_page, category: FactoryGirl.build(:category))
+ page = FactoryBot.create(:action_page, category: FactoryBot.build(:category))
clone = described_class.run(page)
expect(clone.category.title).to eq(page.category.title)
end
it "can be persisted" do
- page = FactoryGirl.create(:action_page)
+ page = FactoryBot.create(:action_page)
clone = described_class.run(page)
expect(clone.save).to be(true)
end
shared_examples "properly duplicates campaign" do |enable_mthd, model|
let(:page) do
- FactoryGirl.create(:action_page, enable_mthd => true,
- model => FactoryGirl.create(model))
+ FactoryBot.create(:action_page, enable_mthd => true,
+ model => FactoryBot.create(model))
end
let(:clone) { described_class.run(page) }
it "does not persist" do
@@ -66,10 +66,10 @@
it_behaves_like "properly duplicates campaign", :enable_petition, :petition
it_behaves_like "properly duplicates campaign", :enable_call, :call_campaign
it_behaves_like "properly duplicates campaign", :enable_congress_message,
- :congress_message_campaign
+ :congress_message_campaign
def filter_attrs(attrs)
- attrs_not_cloned = %w(published archived created_at updated_at slug id)
+ attrs_not_cloned = %w[published archived created_at updated_at slug id]
attrs.tap do |hash|
attrs_not_cloned.each { |a| hash.delete a }
end
diff --git a/spec/lib/call_tool_spec.rb b/spec/lib/call_tool_spec.rb
index 28a128c48..6f8f81040 100644
--- a/spec/lib/call_tool_spec.rb
+++ b/spec/lib/call_tool_spec.rb
@@ -7,9 +7,9 @@
end
describe ".campaign_call" do
- let(:campaign) { FactoryGirl.create(:call_campaign) }
+ let(:campaign) { FactoryBot.create(:call_campaign) }
- let(:keywords) {
+ let(:keywords) do
{
phone: "000-000-0000",
location: "00000",
@@ -17,11 +17,11 @@
action_id: 789,
callback_url: "/"
}
- }
+ end
it "should get call_tool_url/call/create, transforming keyword arguments into params" do
expect(RestClient).to receive(:get) do |url, opts|
- base_href = Rails.application.config.call_tool_url.sub(/\/$/, "")
+ base_href = Rails.application.config.call_tool_url.sub(%r{/$}, "")
expect(url).to eq("#{base_href}/call/create")
expect(opts[:params]).not_to be_nil
expect(opts[:params][:campaignId]).to eq(campaign.to_param)
@@ -40,29 +40,29 @@
it "should raise ArgumentError if a required param is missing" do
allow(RestClient).to receive(:get)
- expect {
+ expect do
CallTool.campaign_call(nil, **keywords)
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
- expect {
+ expect do
CallTool.campaign_call(campaign, **keywords.dup.tap { |x| x[:phone] = nil })
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
- expect {
+ expect do
CallTool.campaign_call(campaign, **keywords.dup.tap { |x| x[:location] = nil })
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
- expect {
+ expect do
CallTool.campaign_call(campaign, **keywords.dup.tap { |x| x[:action_id] = nil })
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
- expect {
+ expect do
CallTool.campaign_call(campaign, **keywords.dup.tap { |x| x[:callback_url] = nil })
- }.to raise_error(ArgumentError)
+ end.to raise_error(ArgumentError)
- expect {
+ expect do
CallTool.campaign_call(campaign, **keywords.dup.tap { |x| x[:user_id] = nil })
- }.not_to raise_error
+ end.not_to raise_error
end
it "should not raise any errors for twilio 'number invalid' error" do
@@ -79,7 +79,7 @@
it "should get call_tool_url/api/campaign/:id with the call tool api key" do
campaign = 12345
expect(RestClient).to receive(:get) do |url, opts|
- base_href = Rails.application.config.call_tool_url.sub(/\/$/, "")
+ base_href = Rails.application.config.call_tool_url.sub(%r{/$}, "")
expect(url).to eq("#{base_href}/api/campaign/#{campaign}")
expect(opts[:params][:api_key]).to eq(Rails.application.secrets.call_tool_api_key)
OpenStruct.new(body: { required_fields: { userLocation: "postal", userPhone: "US" } }.to_json)
@@ -90,13 +90,13 @@
end
describe ".campaigns" do
- let(:calltool_campaign) {
+ let(:calltool_campaign) do
{ "id" => 1, "name" => "call someone", "status" => "live" }
- }
+ end
before do
- stub_request(:get, %r{/api/campaign\?api_key(.*)?&page=1}).
- to_return(status: 200, body: { "objects" => [calltool_campaign], "page" => 1, "total_pages" => 1 }.to_json)
+ stub_request(:get, %r{/api/campaign\?api_key(.*)?&page=1})
+ .to_return(status: 200, body: { "objects" => [calltool_campaign], "page" => 1, "total_pages" => 1 }.to_json)
end
it "should get call_tool_url/api/campaign and return values with id, name, status" do
diff --git a/spec/lib/civicrm_spec.rb b/spec/lib/civicrm_spec.rb
index d4929ed2e..54f7ce3ce 100644
--- a/spec/lib/civicrm_spec.rb
+++ b/spec/lib/civicrm_spec.rb
@@ -7,8 +7,8 @@
describe "self.get_checksum" do
it "calls the civicrm API with method 'generate_checksum'" do
- CiviCRM::get_checksum(123)
- assert_requested :post, CiviCRM::supporters_api_url, body: /generate_checksum/
+ CiviCRM.get_checksum(123)
+ assert_requested :post, CiviCRM.supporters_api_url, body: /generate_checksum/
end
end
end
diff --git a/spec/lib/congress_forms_spec.rb b/spec/lib/congress_forms_spec.rb
index 7c01ec8a7..b394a3463 100644
--- a/spec/lib/congress_forms_spec.rb
+++ b/spec/lib/congress_forms_spec.rb
@@ -2,33 +2,35 @@
describe CongressForms do
describe CongressForms::Form do
- let(:form) {
+ let(:form) do
CongressForms::Form.new("C000880", [
- { "value" => "$NAME_FIRST" },
- { "value" => "$NAME_LAST" },
- { "value" => "$ADDRESS_STATE", "options_hash" => {
- "CALIFORNIA" => "CA",
- "NEW YORK" => "NY"
- } }
- ])
- }
+ { "value" => "$NAME_FIRST" },
+ { "value" => "$NAME_LAST" },
+ { "value" => "$ADDRESS_STATE", "options_hash" => {
+ "CALIFORNIA" => "CA",
+ "NEW YORK" => "NY"
+ } }
+ ])
+ end
- let(:input) { {
- "$NAME_FIRST" => "Willow",
- "$NAME_LAST" => "Rosenberg",
- "$MESSAGE" => "Impeach Mayor Richard Wilkins III",
- "$ADDRESS_STATE" => "CA"
- } }
+ let(:input) do
+ {
+ "$NAME_FIRST" => "Willow",
+ "$NAME_LAST" => "Rosenberg",
+ "$MESSAGE" => "Impeach Mayor Richard Wilkins III",
+ "$ADDRESS_STATE" => "CA"
+ }
+ end
describe "::find" do
before do
- stub_request(:post, /retrieve-form-elements/).
- with(body: { "bio_ids" => ["C000880", "A000360"] }).
- and_return(status: 200, body: file_fixture("retrieve-form-elements.json"))
+ stub_request(:post, /retrieve-form-elements/)
+ .with(body: { "bio_ids" => %w[C000880 A000360] })
+ .and_return(status: 200, body: file_fixture("retrieve-form-elements.json"))
end
it "retrieves a Form for each bioguide_id" do
- forms = CongressForms::Form.find(["C000880", "A000360"]).first
+ forms = CongressForms::Form.find(%w[C000880 A000360]).first
expect(forms.length).to eq 2
lamar = forms.first
expect(lamar.fields.length).to eq 11
@@ -38,13 +40,13 @@
describe "#fill" do
it "posts to the congress forms API" do
- stub_request(:post, /fill-out-form/).
- and_return(status: 200, body: "{}")
- campaign = FactoryGirl.build(:congress_message_campaign)
+ stub_request(:post, /fill-out-form/)
+ .and_return(status: 200, body: "{}")
+ campaign = FactoryBot.build(:congress_message_campaign)
form.fill(input, campaign.campaign_tag)
- expect(WebMock).to have_requested(:post, /fill-out-form/).
- with(body: { bio_id: "C000880", fields: input,
- campaign_tag: campaign.campaign_tag })
+ expect(WebMock).to have_requested(:post, /fill-out-form/)
+ .with(body: { bio_id: "C000880", fields: input,
+ campaign_tag: campaign.campaign_tag })
end
end
end
diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb
index bfdf96d2e..ca7c47cfe 100644
--- a/spec/mailers/user_mailer_spec.rb
+++ b/spec/mailers/user_mailer_spec.rb
@@ -2,8 +2,8 @@
describe UserMailer, type: :mailer do
describe "instructions" do
- let(:user) { FactoryGirl.create(:user) }
- let(:action_page) { FactoryGirl.create(:action_page) }
+ let(:user) { FactoryBot.create(:user) }
+ let(:action_page) { FactoryBot.create(:action_page) }
it "escapes HTML in names" do
bad_name = "
Mallory"
diff --git a/spec/models/action_institution_spec.rb b/spec/models/action_institution_spec.rb
index 12aa11448..e539d6b4a 100644
--- a/spec/models/action_institution_spec.rb
+++ b/spec/models/action_institution_spec.rb
@@ -3,11 +3,11 @@
RSpec.describe ActionInstitution, type: :model do
describe ".add" do
let!(:page) do
- petition = FactoryGirl.create(:petition, enable_affiliations: true)
- FactoryGirl.create(:action_page_with_petition, petition: petition)
+ petition = FactoryBot.create(:petition, enable_affiliations: true)
+ FactoryBot.create(:action_page_with_petition, petition: petition)
end
let!(:institutions) do
- FactoryGirl.create_list(:institution, 2, category: "university")
+ FactoryBot.create_list(:institution, 2, category: "university")
end
it "adds all institutions of a category" do
described_class.add(action_page: page, category: "university")
@@ -19,13 +19,13 @@
end
it "adds new institutions in the category" do
page.institutions << institutions
- new = FactoryGirl.create(:institution, category: "university")
+ new = FactoryBot.create(:institution, category: "university")
described_class.add(action_page: page, category: "university")
expect(page.reload.institutions).to eq(institutions + [new])
end
it "removes institutions when reset: '1'" do
page.institutions << institutions
- new = FactoryGirl.create(:institution, category: "city")
+ new = FactoryBot.create(:institution, category: "city")
described_class.add(action_page: page, category: "city", reset: "1")
expect(page.reload.institutions).to eq([new])
end
diff --git a/spec/models/action_page_spec.rb b/spec/models/action_page_spec.rb
index e292e1cad..ec529d49c 100644
--- a/spec/models/action_page_spec.rb
+++ b/spec/models/action_page_spec.rb
@@ -1,16 +1,16 @@
require "rails_helper"
describe ActionPage do
- let(:attr) { FactoryGirl.attributes_for :action_page }
+ let(:attr) { FactoryBot.attributes_for :action_page }
it "creates a new instance given a valid attribute" do
- expect {
+ expect do
ActionPage.create!(attr)
- }.to change { ActionPage.count }.by(1)
+ end.to change { ActionPage.count }.by(1)
end
it "knows when to redirect from an archived action" do
- action_page = FactoryGirl.build_stubbed :archived_action_page
+ action_page = FactoryBot.build_stubbed :archived_action_page
expect(action_page.redirect_from_archived_to_active_action?).to be_truthy
end
@@ -25,16 +25,15 @@
# end
describe "slug" do
- let(:page) { FactoryGirl.create(:action_page) }
+ let(:page) { FactoryBot.create(:action_page) }
let(:new_slug) { "a-better-slug" }
it "has a friendly slug" do
- expect(page.slug).to eq(page.title.downcase.gsub(" ", "-"))
+ expect(page.slug).to eq(page.title.downcase.tr(" ", "-"))
end
it "updates the slug when title changes" do
- expect { page.update(title: "something else") }
- .to change { page.slug }
+ expect { page.update(title: "something else") }.to change { page.slug }
end
it "does not update slug when unrelated attr changes" do
@@ -74,17 +73,17 @@
before { page.update(slug: new_slug) }
it "does not allow slug conflicts" do
- expect(FactoryGirl.create(:action_page, slug: old_slug).slug)
+ expect(FactoryBot.create(:action_page, slug: old_slug).slug)
.not_to eq(old_slug)
end
end
end
describe "counter cache" do
- let(:page) { FactoryGirl.create(:action_page_with_petition) }
+ let(:page) { FactoryBot.create(:action_page_with_petition) }
before(:each) do
- FactoryGirl.create_list(:ahoy_view, 2, action_page: page)
- FactoryGirl.create(:ahoy_signature, action_page: page)
+ FactoryBot.create_list(:ahoy_view, 2, action_page: page)
+ FactoryBot.create(:ahoy_signature, action_page: page)
page.reload
end
it "counts actions taken" do
@@ -97,24 +96,24 @@
describe "#actions_taken_percent" do
it "calculates the percentage of views that led to actions" do
- page = FactoryGirl.create(:action_page_with_petition)
- FactoryGirl.create_list(:ahoy_view, 3, action_page: page)
- FactoryGirl.create_list(:ahoy_signature, 2, action_page: page)
+ page = FactoryBot.create(:action_page_with_petition)
+ FactoryBot.create_list(:ahoy_view, 3, action_page: page)
+ FactoryBot.create_list(:ahoy_signature, 2, action_page: page)
page.reload
expect(page.actions_taken_percent).to eq((2 / 3.0) * 100)
end
it "returns all zeroes when no events" do
- page = FactoryGirl.create(:action_page)
+ page = FactoryBot.create(:action_page)
expect(page.actions_taken_percent).to eq(0)
end
end
describe ".type(types)" do
- let(:call) { FactoryGirl.create(:action_page_with_call) }
- let(:congress_message) { FactoryGirl.create(:action_page_with_congress_message) }
- let(:email) { FactoryGirl.create(:action_page_with_email) }
- let(:petition) { FactoryGirl.create(:action_page_with_petition) }
- let(:tweet) { FactoryGirl.create(:action_page_with_tweet) }
+ let(:call) { FactoryBot.create(:action_page_with_call) }
+ let(:congress_message) { FactoryBot.create(:action_page_with_congress_message) }
+ let(:email) { FactoryBot.create(:action_page_with_email) }
+ let(:petition) { FactoryBot.create(:action_page_with_petition) }
+ let(:tweet) { FactoryBot.create(:action_page_with_tweet) }
before do
[call, congress_message, email, petition, tweet]
@@ -124,7 +123,7 @@
calls = ActionPage.type("call")
expect(calls).to contain_exactly(call)
- calls_and_tweets = ActionPage.type(["call", "tweet"])
+ calls_and_tweets = ActionPage.type(%w[call tweet])
expect(calls_and_tweets).to contain_exactly(call, tweet)
all = ActionPage.type("call", "congress_message", "email", "petition", "tweet")
@@ -139,29 +138,29 @@
describe ".status(status)" do
shared_examples "returns only the given status" do |status, action|
it status do
- action = FactoryGirl.create(*action)
+ action = FactoryBot.create(*action)
result = ActionPage.status(status)
expect(result).to contain_exactly(action)
end
end
context "not live" do
- before { FactoryGirl.create(:action_page) }
+ before { FactoryBot.create(:action_page) }
it_behaves_like "returns only the given status", "archived",
- [:action_page, { archived: true }]
+ [:action_page, { archived: true }]
it_behaves_like "returns only the given status", "victory",
- [:action_page, { victory: true }]
+ [:action_page, { victory: true }]
it_behaves_like "returns only the given status", "draft",
- [:action_page, { published: false }]
+ [:action_page, { published: false }]
end
context "live action" do
- before { FactoryGirl.create(:action_page, published: false) }
+ before { FactoryBot.create(:action_page, published: false) }
it_behaves_like "returns only the given status", "live",
- [:action_page, { published: true }]
+ [:action_page, { published: true }]
end
it "raises an ArgumentError when an invalid status is given" do
diff --git a/spec/models/ahoy/event_spec.rb b/spec/models/ahoy/event_spec.rb
index 749615d91..60203874e 100644
--- a/spec/models/ahoy/event_spec.rb
+++ b/spec/models/ahoy/event_spec.rb
@@ -3,24 +3,24 @@
describe Ahoy::Event do
describe "#types" do
it "returns event types for an action" do
- action_page = FactoryGirl.create(:action_page_with_tweet)
- expect(Ahoy::Event.action_types(action_page)).to eq([:views, :tweets])
+ action_page = FactoryBot.create(:action_page_with_tweet)
+ expect(Ahoy::Event.action_types(action_page)).to eq(%i[views tweets])
end
end
describe "calculations" do
let!(:now) { Time.zone.parse("12-11-2019 11:00 AM") }
let!(:page) do
- FactoryGirl.create(:action_page_with_petition,
- created_at: now - 1.week, updated_at: now)
+ FactoryBot.create(:action_page_with_petition,
+ created_at: now - 1.week, updated_at: now)
end
before(:each) do
- FactoryGirl.create_list(:ahoy_view, 3,
- action_page: page, time: now - 3.days)
- FactoryGirl.create_list(:ahoy_view, 2,
- action_page: page, time: now + 1.hour)
- FactoryGirl.create(:ahoy_signature, action_page: page, time: now + 2.hours)
- FactoryGirl.create(:ahoy_signature, action_page: page, time: now - 2.days)
+ FactoryBot.create_list(:ahoy_view, 3,
+ action_page: page, time: now - 3.days)
+ FactoryBot.create_list(:ahoy_view, 2,
+ action_page: page, time: now + 1.hour)
+ FactoryBot.create(:ahoy_signature, action_page: page, time: now + 2.hours)
+ FactoryBot.create(:ahoy_signature, action_page: page, time: now - 2.days)
page.reload
end
diff --git a/spec/models/congress_member_spec.rb b/spec/models/congress_member_spec.rb
index 0018d4cfb..765804953 100644
--- a/spec/models/congress_member_spec.rb
+++ b/spec/models/congress_member_spec.rb
@@ -2,7 +2,7 @@
describe CongressMember do
let(:legislators) do
- end_date = (Time.now + 1.year).strftime("%Y-%m-%d")
+ end_date = (Time.zone.now + 1.year).strftime("%Y-%m-%d")
[
CongressMember.new(
"bioguide_id" => "A000001",
diff --git a/spec/models/congress_message_campaign_spec.rb b/spec/models/congress_message_campaign_spec.rb
index 601b3d551..e405b2031 100644
--- a/spec/models/congress_message_campaign_spec.rb
+++ b/spec/models/congress_message_campaign_spec.rb
@@ -1,11 +1,12 @@
-
require "rails_helper"
describe EmailCampaign do
- let(:campaign) { FactoryGirl.create :congress_message_campaign }
+ let(:campaign) { FactoryBot.create :congress_message_campaign }
it "generates a url for fills by date" do
- expect(campaign.date_fills_url(Date.today - 30.days, Date.today)).to include "campaign_tag=a+campaign+tag"
- expect(campaign.date_fills_url(Date.today - 30.days, Date.today)).to match /date_end=\d{4}-\d{2}-\d{2}&date_start=\d{4}-\d{2}-\d{2}/
+ expect(campaign.date_fills_url(Time.zone.today - 30.days, Time.zone.today)).to \
+ include("campaign_tag=a+campaign+tag")
+ expect(campaign.date_fills_url(Time.zone.today - 30.days, Time.zone.today)).to \
+ match(/date_end=\d{4}-\d{2}-\d{2}&date_start=\d{4}-\d{2}-\d{2}/)
end
end
diff --git a/spec/models/congress_message_spec.rb b/spec/models/congress_message_spec.rb
index b3cd1cba6..b6b0a57ba 100644
--- a/spec/models/congress_message_spec.rb
+++ b/spec/models/congress_message_spec.rb
@@ -1,9 +1,9 @@
require "rails_helper"
describe CongressMessage do
- subject {
- FactoryGirl.build(:congress_message)
- }
+ subject do
+ FactoryBot.build(:congress_message)
+ end
describe "#common_fields" do
it "groups matching opt_hashes" do
diff --git a/spec/models/email_campaign_spec.rb b/spec/models/email_campaign_spec.rb
index 6a470716d..d02493198 100644
--- a/spec/models/email_campaign_spec.rb
+++ b/spec/models/email_campaign_spec.rb
@@ -3,7 +3,7 @@
describe EmailCampaign do
describe "#service_uri(service)" do
let(:campaign) do
- FactoryGirl.create(
+ FactoryBot.create(
:email_campaign,
email_addresses: "a@example.com, b@example.com",
subject: "hey hey hey",
diff --git a/spec/models/institution_spec.rb b/spec/models/institution_spec.rb
index 208318ca9..42bebf759 100644
--- a/spec/models/institution_spec.rb
+++ b/spec/models/institution_spec.rb
@@ -2,7 +2,7 @@
describe Institution do
describe ".top" do
- let(:petition) { FactoryGirl.create(:local_organizing_petition) }
+ let(:petition) { FactoryBot.create(:local_organizing_petition) }
let(:high_rank) { petition.action_page.institutions.create(name: "A", category: "University") }
let(:mid_rank) { petition.action_page.institutions.create(name: "B", category: "University") }
@@ -12,17 +12,17 @@
before(:each) do
100.times do
- sig = FactoryGirl.create(:signature, petition_id: petition.id)
+ sig = FactoryBot.create(:signature, petition_id: petition.id)
sig.affiliations.create(institution_id: high_rank.id, affiliation_type: student)
end
50.times do
- sig = FactoryGirl.create(:signature, petition_id: petition.id)
+ sig = FactoryBot.create(:signature, petition_id: petition.id)
sig.affiliations.create(institution_id: mid_rank.id, affiliation_type: student)
end
10.times do
- sig = FactoryGirl.create(:signature, petition_id: petition.id)
+ sig = FactoryBot.create(:signature, petition_id: petition.id)
sig.affiliations.create(institution_id: low_rank.id, affiliation_type: student)
end
end
@@ -37,17 +37,17 @@
end
describe ".import" do
- let(:action_page) { FactoryGirl.create(:action_page) }
- let(:institution) { FactoryGirl.create(:institution) }
+ let(:action_page) { FactoryBot.create(:action_page) }
+ let(:institution) { FactoryBot.create(:institution) }
let(:names) do
["University of California, Berkeley",
"University of California, Santa Cruz"]
end
it "adds institutions by name" do
- expect {
+ expect do
described_class.import("University", names)
- }.to change(Institution.where(category: "University"), :count).by(names.count)
+ end.to change(Institution.where(category: "University"), :count).by(names.count)
end
end
end
diff --git a/spec/models/petition_spec.rb b/spec/models/petition_spec.rb
index 21abb0e54..496ac035a 100644
--- a/spec/models/petition_spec.rb
+++ b/spec/models/petition_spec.rb
@@ -14,11 +14,10 @@
end
it "should output useful CSV files" do
- p = FactoryGirl.create(:petition_complete_with_one_hundred_signatures)
- expected_first_record = "John Doe,#{p.signatures.to_a.first.email},San Francisco,CA,United States of America\n"
-
+ p = FactoryBot.create(:petition_complete_with_one_hundred_signatures)
+ expected_first_record = "John Doe,#{p.signatures.order(:id).first.email},"\
+ "San Francisco,CA,United States of America\n"
csv = p.signatures.to_presentable_csv
-
columns = csv.lines.first
first_record = csv.lines[1]
diff --git a/spec/models/signature_spec.rb b/spec/models/signature_spec.rb
index 60691093e..593e628d9 100644
--- a/spec/models/signature_spec.rb
+++ b/spec/models/signature_spec.rb
@@ -23,29 +23,29 @@
it "should reject spammy emails" do
invalid_email = @attr.merge(email: "a@b")
- expect {
+ expect do
Signature.create!(invalid_email)
- }.to raise_error ActiveRecord::RecordInvalid
+ end.to raise_error ActiveRecord::RecordInvalid
end
it "should impose an arbitrary opinion as to whether a string of text may refer to a country" do
- # note: it is my personal belief that there is no such thing as a country/ nation =)
+ # NOTE: it is my personal belief that there is no such thing as a country/ nation =)
arbitrarily_invalid_opinion = @attr.merge(country_code: "laserland")
- expect {
+ expect do
Signature.create!(arbitrarily_invalid_opinion)
- }.to raise_error ActiveRecord::RecordInvalid
+ end.to raise_error ActiveRecord::RecordInvalid
end
it "should reject long zipcodes" do
long_zip = @attr.merge(zipcode: "9" * 13)
- expect {
+ expect do
Signature.create!(long_zip)
- }.to raise_error ActiveRecord::RecordInvalid
+ end.to raise_error ActiveRecord::RecordInvalid
end
- describe ".filter" do
+ describe ".search" do
let(:jon) { Signature.create!(@attr.merge(email: "xx@example.com", first_name: "Jon", last_name: "A")) }
let(:jan) { Signature.create!(@attr.merge(email: "xy@example.com", first_name: "Jan", last_name: "B")) }
let(:jeb) { Signature.create!(@attr.merge(email: "wz@example.com", first_name: "Jeb", last_name: "C")) }
@@ -54,23 +54,23 @@
let(:all_signatures) { [jon, jan, jeb, jen] }
it "should return .all when query is blank" do
- expect(Signature.filter(nil)).to contain_exactly(*all_signatures)
- expect(Signature.filter("")).to contain_exactly(*all_signatures)
- expect(Signature.filter(" \t")).to contain_exactly(*all_signatures)
+ expect(Signature.search(nil)).to contain_exactly(*all_signatures)
+ expect(Signature.search("")).to contain_exactly(*all_signatures)
+ expect(Signature.search(" \t")).to contain_exactly(*all_signatures)
end
it "should return signatures with matching email (case insensitive)" do
- expect(Signature.filter("example.com")).to contain_exactly(*all_signatures)
- expect(Signature.filter("EXAMPLE")).to contain_exactly(*all_signatures)
- expect(Signature.filter("w")).to contain_exactly(jeb, jen)
- expect(Signature.filter("xx")).to contain_exactly(jon)
+ expect(Signature.search("example.com")).to contain_exactly(*all_signatures)
+ expect(Signature.search("EXAMPLE")).to contain_exactly(*all_signatures)
+ expect(Signature.search("w")).to contain_exactly(jeb, jen)
+ expect(Signature.search("xx")).to contain_exactly(jon)
end
it "should return signatures with matching names (case insensitive)" do
- expect(Signature.filter("J")).to contain_exactly(*all_signatures)
- expect(Signature.filter("Jon")).to contain_exactly(jon)
- expect(Signature.filter("Jan B")).to contain_exactly(jan)
- expect(Signature.filter("Jeb c")).to contain_exactly(jeb)
+ expect(Signature.search("J")).to contain_exactly(*all_signatures)
+ expect(Signature.search("Jon")).to contain_exactly(jon)
+ expect(Signature.search("Jan B")).to contain_exactly(jan)
+ expect(Signature.search("Jeb c")).to contain_exactly(jeb)
end
end
end
diff --git a/spec/models/source_file_spec.rb b/spec/models/source_file_spec.rb
index 0f1e47cef..daa07269c 100644
--- a/spec/models/source_file_spec.rb
+++ b/spec/models/source_file_spec.rb
@@ -2,7 +2,7 @@
describe SourceFile do
before(:each) do
- @source_file = FactoryGirl.create(:source_file, key: "meh.jpg")
+ @source_file = FactoryBot.create(:source_file, key: "meh.jpg")
end
it "should generate full_urls correctly when amazon_bucket_url is set" do
diff --git a/spec/models/topic_category_spec.rb b/spec/models/topic_category_spec.rb
index f863aeac4..6ec41bf2b 100644
--- a/spec/models/topic_category_spec.rb
+++ b/spec/models/topic_category_spec.rb
@@ -1,21 +1,21 @@
require "rails_helper"
describe TopicCategory do
- subject { FactoryGirl.create(:topic_category) }
+ subject { FactoryBot.create(:topic_category) }
describe "#best_match" do
it "selects the best match from a list of options" do
- options = ["Spike", "Vampire3", "Drusilla", "Vampire2", "Harmony"].map { |o| [o] * 2 }
- expect(subject.best_match options).to eq "Vampire2"
+ options = %w[Spike Vampire3 Drusilla Vampire2 Harmony].map { |o| [o] * 2 }
+ expect(subject.best_match(options)).to eq "Vampire2"
end
it "ignores case, whitespace, and punctuation when matching" do
options = ["Vampire3", "VamPire 2!"].map { |o| [o] * 2 }
- expect(subject.best_match options).to eq "VamPire 2!"
+ expect(subject.best_match(options)).to eq "VamPire 2!"
end
after do
- FactoryGirl.reload # Reset sequence numbers
+ FactoryBot.reload # Reset sequence numbers
end
end
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index af5fd159a..da827928e 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -2,8 +2,8 @@
require "lib/civicrm_spec"
describe User do
- let(:attr) { FactoryGirl.attributes_for :user }
- let(:user) { FactoryGirl.create(:user) }
+ let(:attr) { FactoryBot.attributes_for :user }
+ let(:user) { FactoryBot.create(:user) }
before(:each) do
stub_civicrm
@@ -17,16 +17,16 @@
describe "password management" do
it "resets password reset tokens upon email change" do
- user.update_attributes(reset_password_token: "stub_token")
- user.update_attributes(email: "2" + user.email)
+ user.update(reset_password_token: "stub_token")
+ user.update(email: "2#{user.email}")
user.confirm
expect(user.reset_password_token).to be_nil
end
it "resets password reset tokens upon password change" do
- user.update_attributes(reset_password_token: "stub_token")
+ user.update(reset_password_token: "stub_token")
expect(user.reset_password_token).not_to be_nil
- user.update_attributes(password: "My new password is pretty great")
+ user.update(password: "My new password is pretty great")
expect(user.reset_password_token).to be_nil
end
@@ -36,7 +36,7 @@
end
it "makes sure admins are using strong passwords" do
- user = FactoryGirl.create(:user, admin: true)
+ user = FactoryBot.create(:user, admin: true)
result = set_weak_password(user)
expect(result).to be_falsey
@@ -47,9 +47,9 @@
end
describe "track user actions" do
- let(:user) { FactoryGirl.create(:user, record_activity: true) }
+ let(:user) { FactoryBot.create(:user, record_activity: true) }
let(:ahoy) { Ahoy::Tracker.new }
- let(:action_page) { FactoryGirl.create :action_page_with_petition }
+ let(:action_page) { FactoryBot.create :action_page_with_petition }
it "knows if the user has taken a given action" do
ahoy.authenticate(user)
@@ -57,25 +57,20 @@
expect(user.taken_action?(action_page)).to be_truthy
end
-
- it "ranks users" do
- record_several_actions
- expect(user.percentile_rank).to eq(50)
- end
end
end
def record_several_actions
# a user with no actions
- FactoryGirl.create(:user, record_activity: true)
+ FactoryBot.create(:user, record_activity: true)
# a user with three actions
- ahoy.authenticate(FactoryGirl.create(:user, record_activity: true))
+ ahoy.authenticate(FactoryBot.create(:user, record_activity: true))
3.times { track_signature(action_page) }
# a user with 1 action
- ahoy.authenticate(FactoryGirl.create(:user, record_activity: true))
- 1.times { track_signature(action_page) }
+ ahoy.authenticate(FactoryBot.create(:user, record_activity: true))
+ track_signature(action_page)
# our friend, with 2 actions
ahoy.authenticate(user)
@@ -85,12 +80,12 @@ def record_several_actions
def track_signature(action_page)
ahoy.track "Action",
- { type: "action", actionType: "signature", actionPageId: action_page.id },
- action_page: action_page
+ { type: "action", actionType: "signature", actionPageId: action_page.id },
+ action_page: action_page
end
def track_view(action_page)
ahoy.track "View",
- { type: "action", actionType: "view", actionPageId: action_page.id },
- action_page: action_page
+ { type: "action", actionType: "view", actionPageId: action_page.id },
+ action_page: action_page
end
diff --git a/spec/queries/action_page_filters_spec.rb b/spec/queries/action_page_filters_spec.rb
index c232c9d2f..0a77dc922 100644
--- a/spec/queries/action_page_filters_spec.rb
+++ b/spec/queries/action_page_filters_spec.rb
@@ -2,20 +2,20 @@
describe ActionPageFilters do
it "returns only actions matching the given filters" do
- category = FactoryGirl.create(:category)
- basic = FactoryGirl.create(:action_page)
- category_action = FactoryGirl.create(:action_page,
- enable_tweet: true,
- category: category)
- draft_old = FactoryGirl.create(:action_page,
- enable_tweet: true,
- published: false,
- created_at: Time.zone.today - 7.days)
- authored_old = FactoryGirl.create(:action_page,
- enable_tweet: true,
- created_at: Time.zone.today - 7.days,
- author: FactoryGirl.create(:user),
- category: category)
+ category = FactoryBot.create(:category)
+ basic = FactoryBot.create(:action_page)
+ category_action = FactoryBot.create(:action_page,
+ enable_tweet: true,
+ category: category)
+ draft_old = FactoryBot.create(:action_page,
+ enable_tweet: true,
+ published: false,
+ created_at: Time.zone.today - 7.days)
+ authored_old = FactoryBot.create(:action_page,
+ enable_tweet: true,
+ created_at: Time.zone.today - 7.days,
+ author: FactoryBot.create(:user),
+ category: category)
new_date_range = "#{Time.zone.today - 3.days} - #{Time.zone.today}"
result = described_class.run(category: category)
@@ -32,13 +32,13 @@
end
it "does not filter when values are blank or 'all'" do
- FactoryGirl.create(:action_page)
- FactoryGirl.create(:action_page, enable_tweet: true,
- category: FactoryGirl.create(:category))
- FactoryGirl.create(:action_page, enable_tweet: true, published: false,
- created_at: Time.zone.today - 7.days)
+ FactoryBot.create(:action_page)
+ FactoryBot.create(:action_page, enable_tweet: true,
+ category: FactoryBot.create(:category))
+ FactoryBot.create(:action_page, enable_tweet: true, published: false,
+ created_at: Time.zone.today - 7.days)
result = described_class.run(category: "all", type: "", status: "all",
- author: "", date_range: "")
+ author: "", date_range: "")
expect(result.size).to eq(3)
end
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index 9c8ec65d4..a5c1a57e4 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -1,12 +1,11 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= "test"
-require File.expand_path("../../config/environment", __FILE__)
+require File.expand_path("../config/environment", __dir__)
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
require "spec_helper"
require "rspec/rails"
-require "selenium/webdriver"
-require "webdrivers"
+require "capybara/apparition"
# Add additional requires below this line. Rails is not loaded until this point!
@@ -29,25 +28,25 @@
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.maintain_test_schema!
-
-capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
- :loggingPrefs => {
- browser: "ALL",
- client: "ALL",
- driver: "ALL",
- server: "ALL"
- },
- "chromeOptions" => {
+apparition_opts = {
+ window_size: [1400, 900],
+ screen_size: [1920, 1090],
+ browser_options: {
"w3c" => false,
- "args" => ["headless", "disable-gpu", "--window-size=1400,900"].tap do |a|
- a.push("no-sandbox") if ENV["TRAVIS"]
- end
+ "args" => ["headless", "disable-gpu", "--window-size=1400,900"]
+ }
+}
+
+if ENV["TRAVIS"]
+ apparition_opts[:browser_options] = {
+ "remote-debugging-address" => "127.0.0.1",
+ "remote-debugging-port" => 9222
}
-)
+ apparition_opts[:remote] = true
+end
Capybara.register_driver :chrome_headless do |app|
- Capybara::Selenium::Driver.new(app, browser: :chrome,
- desired_capabilities: capabilities)
+ Capybara::Apparition::Driver.new(app, apparition_opts)
end
Capybara.server = :puma
@@ -60,7 +59,7 @@
config.include Warden::Test::Helpers, type: :feature
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
+ config.fixture_path = Rails.root.join("spec/fixtures")
# 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
@@ -93,7 +92,7 @@
disable_call_tool
end
- FileUtils.mkdir_p("#{Rails.root}/tmp/cache")
+ FileUtils.mkdir_p(Rails.root.join("tmp/cache"))
config.before(:each) do
Rails.cache.clear
end
diff --git a/spec/requests/action_pages_spec.rb b/spec/requests/action_pages_spec.rb
index 328922e21..705523dc2 100644
--- a/spec/requests/action_pages_spec.rb
+++ b/spec/requests/action_pages_spec.rb
@@ -3,7 +3,7 @@
RSpec.describe "Action Pages", type: :request do
describe "small petition" do
before(:each) do
- @action_page = FactoryGirl.create(:petition_with_99_signatures_needing_1_more).action_page
+ @action_page = FactoryBot.create(:petition_with_99_signatures_needing_1_more).action_page
end
it "lists action pages" do
@@ -25,7 +25,7 @@
describe "large petition" do
it "should present the count of signatures" do
- @action_page = FactoryGirl.create(:petition_complete_with_one_thousand_signatures).action_page
+ @action_page = FactoryBot.create(:petition_complete_with_one_thousand_signatures).action_page
path = "#{action_page_path(@action_page)}/signature_count"
get path
diff --git a/spec/requests/admin/action_pages_spec.rb b/spec/requests/admin/action_pages_spec.rb
index 4362c8570..5d1292bd3 100644
--- a/spec/requests/admin/action_pages_spec.rb
+++ b/spec/requests/admin/action_pages_spec.rb
@@ -16,15 +16,15 @@
describe "Non-Privileged Users" do
it "should prevent them creating action pages" do
- expect {
+ expect do
post "/admin/action_pages", params: valid_attributes
- }.to raise_exception(ActiveRecord::RecordNotFound)
+ end.to raise_exception(ActiveRecord::RecordNotFound)
end
end
describe "Admins" do
before(:each) do
- @admin = FactoryGirl.create(:admin_user)
+ @admin = FactoryBot.create(:admin_user)
login @admin
end
@@ -39,7 +39,7 @@
end
it "should allow them to search action pages" do
- border = FactoryGirl.create(
+ border = FactoryBot.create(
:action_page_with_petition,
title: "borderpetition",
petition_attributes: {
@@ -47,23 +47,23 @@
}
)
- privacy = FactoryGirl.create(
+ privacy = FactoryBot.create(
:action_page_with_petition,
title: "privacypetition",
petition_attributes: { description: "online privacy" }
)
- tweet = FactoryGirl.create(
+ tweet = FactoryBot.create(
:action_page_with_tweet,
title: "bordertweet",
tweet_attributes: { message: "border surveillance tweet" }
)
- xhr :get, "/admin/action_pages?q=border+surveil"
+ get "/admin/action_pages?q=border+surveil", xhr: true
- expect(response.body).to include("borderpetition")
- expect(response.body).to include("bordertweet")
- expect(response.body).not_to include("privacypetition")
+ expect(response.body).to include(border.title)
+ expect(response.body).to include(tweet.title)
+ expect(response.body).not_to include(privacy.title)
end
end
end
diff --git a/spec/requests/admin/events_spec.rb b/spec/requests/admin/events_spec.rb
index f47f72966..ff350215d 100644
--- a/spec/requests/admin/events_spec.rb
+++ b/spec/requests/admin/events_spec.rb
@@ -1,64 +1,62 @@
require "rails_helper"
RSpec.describe "Admin Action Page Analytics", type: :request do
- let(:action_page) { FactoryGirl.create(:action_page_with_views) }
- before { login FactoryGirl.create(:admin_user) }
+ let(:action_page) { FactoryBot.create(:action_page_with_views) }
+ before { login FactoryBot.create(:admin_user) }
describe "#index" do
context "with type param" do
it "responds with views over time as JSON" do
- expect(Time.zone).
- to receive(:now).
- and_return(Time.local(2019)).
- at_least(:once)
+ expect(Time.zone)
+ .to receive(:now)
+ .and_return(Time.zone.local(2019))
+ .at_least(:once)
get "/admin/action_pages/#{action_page.slug}/events",
- params: { type: "views" },
- headers: { "ACCEPT" => "application/json" }
+ params: { type: "views" },
+ headers: { "ACCEPT" => "application/json" }
expect(response.code).to eq "200"
# Default is to return data for the previous month.
- expect(JSON.parse(response.body).keys).
- to include(*(1..31).map { |i| sprintf("Dec %d 2018", i) })
+ expect(JSON.parse(response.body).keys)
+ .to include(*(1..31).map { |i| format("Dec %d 2018", i) })
end
it "filters by date" do
- start_date = Time.utc(2019, 1, 1).strftime("%Y-%m-%d")
- end_date = Time.utc(2019, 1, 7).strftime("%Y-%m-%d")
get "/admin/action_pages/#{action_page.slug}/events",
- params: {
- date_range_text: "Jan 1, 2019 - Jan 8, 2019",
- type: "views"
- },
- headers: { "ACCEPT" => "application/json" }
+ params: {
+ date_range_text: "Jan 1, 2019 - Jan 8, 2019",
+ type: "views"
+ },
+ headers: { "ACCEPT" => "application/json" }
# Returns one datapoint per day in range.
- expect(JSON.parse(response.body).keys).
- to eq([
- "Jan 1 2019",
- "Jan 2 2019",
- "Jan 3 2019",
- "Jan 4 2019",
- "Jan 5 2019",
- "Jan 6 2019",
- "Jan 7 2019",
- "Jan 8 2019"
- ])
+ expect(JSON.parse(response.body).keys)
+ .to eq([
+ "Jan 1 2019",
+ "Jan 2 2019",
+ "Jan 3 2019",
+ "Jan 4 2019",
+ "Jan 5 2019",
+ "Jan 6 2019",
+ "Jan 7 2019",
+ "Jan 8 2019"
+ ])
end
end
context "without type param" do
before do
- allow(Time.zone).to receive(:now).and_return(Time.local(2019))
+ allow(Time.zone).to receive(:now).and_return(Time.zone.local(2019))
action_page.update(
enable_petition: true,
petition_id: Petition.create.id
)
- FactoryGirl.create(:ahoy_signature,
- action_page: action_page,
- time: Time.zone.now)
+ FactoryBot.create(:ahoy_signature,
+ action_page: action_page,
+ time: Time.zone.now)
end
it "renders html" do
@@ -67,5 +65,4 @@
end
end
end
-
end
diff --git a/spec/requests/admin/petition_spec.rb b/spec/requests/admin/petition_spec.rb
index c95c04705..1532858d8 100644
--- a/spec/requests/admin/petition_spec.rb
+++ b/spec/requests/admin/petition_spec.rb
@@ -3,12 +3,12 @@
RSpec.describe "Admin Action Pages", type: :request do
describe "admins" do
before(:each) do
- @admin = FactoryGirl.create(:admin_user)
+ @admin = FactoryBot.create(:admin_user)
login @admin
end
it "should let admins download the CSV" do
- @petition = FactoryGirl.create(:petition_complete_with_one_hundred_signatures)
+ @petition = FactoryBot.create(:petition_complete_with_one_hundred_signatures)
get "/admin/petitions/#{@petition.id}/presentable_csv"
diff --git a/spec/requests/admin/s3_uploads_spec.rb b/spec/requests/admin/s3_uploads_spec.rb
index 7f6eb0bfe..3e00c35be 100644
--- a/spec/requests/admin/s3_uploads_spec.rb
+++ b/spec/requests/admin/s3_uploads_spec.rb
@@ -1,18 +1,20 @@
require "rails_helper"
RSpec.describe "S3 Uploads Spec", type: :request do
- let(:valid_attributes) { {
- "source_file" => {
- "bucket" => "actioncenter-staging",
- "file_name" => "img.png",
- "file_content_type" => "image",
- "file_size" => "10",
- "key" => "uploads/3be325f2b4e64d9d92a89405577280a4/img.png"
- },
- "action" => "create",
- "controller" => "admin/s3_uploads",
- "format" => "json"
- } }
+ let(:valid_attributes) do
+ {
+ "source_file" => {
+ "bucket" => "actioncenter-staging",
+ "file_name" => "img.png",
+ "file_content_type" => "image",
+ "file_size" => "10",
+ "key" => "uploads/3be325f2b4e64d9d92a89405577280a4/img.png"
+ },
+ "action" => "create",
+ "controller" => "admin/s3_uploads",
+ "format" => "json"
+ }
+ end
before(:each) do
# bypasses a 3rd party lookup (s3)
@@ -20,17 +22,17 @@
end
it "should deny non-admins" do
- expect {
+ expect do
post "/admin/source_files", params: valid_attributes
- }.to raise_exception(ActiveRecord::RecordNotFound)
+ end.to raise_exception(ActiveRecord::RecordNotFound)
end
it "should allow admins" do
- @admin = FactoryGirl.create(:admin_user)
+ @admin = FactoryBot.create(:admin_user)
login @admin
- expect {
+ expect do
post "/admin/source_files", params: valid_attributes
- }.to change { SourceFile.count }.by(1)
+ end.to change { SourceFile.count }.by(1)
end
end
diff --git a/spec/requests/admin/users_spec.rb b/spec/requests/admin/users_spec.rb
index bb1bf9dab..efc632572 100644
--- a/spec/requests/admin/users_spec.rb
+++ b/spec/requests/admin/users_spec.rb
@@ -2,14 +2,14 @@
RSpec.describe "Admin Users", type: :request do
before(:each) do
- admin = FactoryGirl.create(:admin_user)
+ admin = FactoryBot.create(:admin_user)
login admin
end
describe "#index" do
before do
10.times do |n|
- FactoryGirl.create(:user, created_at: Time.now - n.days, email: "user-#{n}@example.com")
+ FactoryBot.create(:user, created_at: Time.zone.now - n.days, email: "user-#{n}@example.com")
end
end
diff --git a/spec/requests/congress_messages_spec.rb b/spec/requests/congress_messages_spec.rb
index ab20708a0..9602892c9 100644
--- a/spec/requests/congress_messages_spec.rb
+++ b/spec/requests/congress_messages_spec.rb
@@ -1,16 +1,16 @@
require "rails_helper"
RSpec.describe "Congress Messages", type: :request do
- let!(:members) {
- [FactoryGirl.create(:congress_member, state: "CA", bioguide_id: "C000880"),
- FactoryGirl.create(:congress_member, state: "CA", bioguide_id: "A000360")]
- }
+ let!(:members) do
+ [FactoryBot.create(:congress_member, state: "CA", bioguide_id: "C000880"),
+ FactoryBot.create(:congress_member, state: "CA", bioguide_id: "A000360")]
+ end
- let(:action_page) {
- FactoryGirl.create(:action_page_with_congress_message)
- }
+ let(:action_page) do
+ FactoryBot.create(:action_page_with_congress_message)
+ end
- let(:location) {
+ let(:location) do
OpenStruct.new(success: true,
street: "1630 Ravello Drive",
city: "Sunnydale",
@@ -18,20 +18,20 @@
zip4: 1234,
state: "CA",
district: 10)
- }
+ end
def stub_congress_forms_find_with_two_reps
- stub_request(:post, /retrieve-form-elements/).
- with(body: { "bio_ids" => ["C000880", "A000360"] }).
- and_return(status: 200, body: file_fixture("retrieve-form-elements.json"))
+ stub_request(:post, /retrieve-form-elements/)
+ .with(body: { "bio_ids" => %w[C000880 A000360] })
+ .and_return(status: 200, body: file_fixture("retrieve-form-elements.json"))
end
def stub_congress_forms_find_with_one_rep
forms_body = JSON.parse(file_fixture("retrieve-form-elements.json").read)
forms_body.delete("A000360")
- stub_request(:post, /retrieve-form-elements/).
- with(body: { "bio_ids" => ["C000880"] }).
- and_return(status: 200, body: forms_body.to_json)
+ stub_request(:post, /retrieve-form-elements/)
+ .with(body: { "bio_ids" => ["C000880"] })
+ .and_return(status: 200, body: forms_body.to_json)
end
before do
@@ -40,7 +40,7 @@ def stub_congress_forms_find_with_one_rep
end
describe "#new" do
- def get_congress_message_form
+ def get_congress_message_form # rubocop:todo Naming/AccessorMethodName
campaign_id = action_page.congress_message_campaign_id
get("/congress_message_campaigns/#{campaign_id}/congress_messages/new",
params: { street_address: location.street,
@@ -73,17 +73,21 @@ def get_congress_message_form
end
it "to target bioguide_ids" do
- campaign = FactoryGirl.create(:congress_message_campaign, :targeting_bioguide_ids)
+ campaign = FactoryBot.create(:congress_message_campaign, :targeting_bioguide_ids)
+ # rubocop:todo Rails/SkipsModelValidations
action_page.update_attribute(:congress_message_campaign, campaign)
+ # rubocop:enable Rails/SkipsModelValidations
get_congress_message_form
expect(response.body).to include("C000880")
expect(response.body).not_to include("A000360")
end
it "to target a single chamber" do
- members.last.update_attributes(chamber: "house", district: 10)
- campaign = FactoryGirl.create(:congress_message_campaign, :targeting_senate)
+ members.last.update(chamber: "house", district: 10)
+ campaign = FactoryBot.create(:congress_message_campaign, :targeting_senate)
+ # rubocop:todo Rails/SkipsModelValidations
action_page.update_attribute(:congress_message_campaign, campaign)
+ # rubocop:enable Rails/SkipsModelValidations
get_congress_message_form
expect(response.body).to include("C000880")
expect(response.body).not_to include("A000360")
@@ -101,13 +105,13 @@ def get_congress_message_form
"$ADDRESS_CITY" => "Sunnydale",
"$ADDRESS_ZIP5" => "94109",
"$EMAIL" => "jsummers@altavista.com",
- "$NAME_PREFIX" => "Mrs.",
+ "$NAME_PREFIX" => "Mrs."
},
member_attributes: {
"C000880" => {
"$SUBJECT" => "Take Action",
"$ADDRESS_STATE_POSTAL_ABBREV" => "CA",
- "$TOPIC" => "JU",
+ "$TOPIC" => "JU"
},
"A000360" => {
"$ADDRESS_STATE" => "CA",
@@ -115,7 +119,7 @@ def get_congress_message_form
}
},
forms: {
- bioguide_ids: %w(C000880 A000360)
+ bioguide_ids: %w[C000880 A000360]
},
message: "Impeach Mayor Richard Wilkins III"
}
@@ -129,30 +133,30 @@ def submit_congress_message
end
before do
- stub_request(:post, /fill-out-form/).
- and_return(status: 200, body: "{}")
+ stub_request(:post, /fill-out-form/)
+ .and_return(status: 200, body: "{}")
end
it "successfully submits good input" do
submit_congress_message
- expect(WebMock).to have_requested(:post, /fill-out-form/).
- with(body: {
- "bio_id": "C000880",
- "fields": {
- "$NAME_FIRST": "Joyce",
- "$NAME_LAST": "Summers",
- "$ADDRESS_STREET": "1630 Ravello Drive",
- "$ADDRESS_CITY": "Sunnydale",
- "$ADDRESS_ZIP5": "94109",
- "$EMAIL": "jsummers@altavista.com",
- "$SUBJECT": "Take Action",
- "$NAME_PREFIX": "Mrs.",
- "$ADDRESS_STATE_POSTAL_ABBREV": "CA",
- "$MESSAGE": "Impeach Mayor Richard Wilkins III",
- "$TOPIC": "JU"
- },
- campaign_tag: "a campaign tag"
- })
+ expect(WebMock).to have_requested(:post, /fill-out-form/)
+ .with(body: {
+ "bio_id": "C000880",
+ "fields": {
+ "$NAME_FIRST": "Joyce",
+ "$NAME_LAST": "Summers",
+ "$ADDRESS_STREET": "1630 Ravello Drive",
+ "$ADDRESS_CITY": "Sunnydale",
+ "$ADDRESS_ZIP5": "94109",
+ "$EMAIL": "jsummers@altavista.com",
+ "$SUBJECT": "Take Action",
+ "$NAME_PREFIX": "Mrs.",
+ "$ADDRESS_STATE_POSTAL_ABBREV": "CA",
+ "$MESSAGE": "Impeach Mayor Richard Wilkins III",
+ "$TOPIC": "JU"
+ },
+ campaign_tag: "a campaign tag"
+ })
end
it "returns an error when validation fails" do
@@ -166,30 +170,12 @@ def submit_congress_message
message_attributes[:test] = 1
submit_congress_message
expect(response.status).to eq 200
- expect(WebMock).to have_requested(:post, /fill-out-form/).
- with(body: hash_including(test: 1)).twice
+ expect(WebMock).to have_requested(:post, /fill-out-form/)
+ .with(body: hash_including(test: 1)).twice
end
it "succeeds with no common attributs" do
stub_congress_forms_find_with_one_rep
- message_attributes = {
- member_attributes: {
- "C000880" => {
- "$NAME_FIRST" => "Joyce",
- "$NAME_LAST" => "Summers",
- "$ADDRESS_STREET" => "1630 Ravello Drive",
- "$ADDRESS_CITY" => "Sunnydale",
- "$ADDRESS_ZIP5" => "94109",
- "$EMAIL" => "jsummers@altavista.com",
- "$NAME_PREFIX" => "Mrs.",
- "$MESSAGE" => "Impeach Mayor Richard Wilkins III",
- "$SUBJECT" => "Take Action",
- "$ADDRESS_STATE_POSTAL_ABBREV" => "CA",
- "$TOPIC" => "JU",
- }
- },
- bioguide_ids: "C000880"
- }
submit_congress_message
expect(response.status).to eq 200
end
diff --git a/spec/requests/registrations_spec.rb b/spec/requests/registrations_spec.rb
index 44e655dbd..9dabfc0d3 100644
--- a/spec/requests/registrations_spec.rb
+++ b/spec/requests/registrations_spec.rb
@@ -15,10 +15,8 @@
}
}
end
- subject { post "/", params: valid_attributes }
-
it "creates users" do
- subject
+ post "/", params: valid_attributes
expect(response.code).to eq "302"
expect(User.count).to eq 1
# Expect an email confirmation message.
@@ -26,7 +24,7 @@
end
it "lets unconfirmed users register a new password" do
- subject
+ post "/", params: valid_attributes
# Attempt to re-register+confirm with a new password,
post "/", params: {
user: {
diff --git a/spec/requests/sns_spec.rb b/spec/requests/sns_spec.rb
index 39b6a1643..2195fbb77 100644
--- a/spec/requests/sns_spec.rb
+++ b/spec/requests/sns_spec.rb
@@ -10,7 +10,7 @@
headers = { "CONTENT_TYPE" => "application/json" }
body = File.read("./spec/fixtures/files/sns_complaint.json")
post "/complaint/#{Rails.application.secrets.amazon_authorize_key}",
- params: body, headers: headers
+ params: body, headers: headers
expect(JSON.parse(response.body)["success"]).to be true
expect(Complaint.count).to eq 1
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 21581c358..7eb9dd77e 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,25 +1,7 @@
require "capybara/rspec"
require "webmock/rspec"
-Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
+Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |f| require f }
-# This file was generated by the `rails generate rspec:install` command. Conventionally, all
-# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
-# The generated `.rspec` file contains `--require spec_helper` which will cause
-# this file to always be loaded, without a need to explicitly require it in any
-# files.
-#
-# Given that it is always loaded, you are encouraged to keep this file as
-# light-weight as possible. Requiring heavyweight dependencies from this file
-# will add to the boot time of your test suite on EVERY test run, even for an
-# individual file that may not need all of that loaded. Instead, consider making
-# a separate helper file that requires the additional dependencies and performs
-# the additional setup, and require it from the spec files that actually need
-# it.
-#
-# The `.rspec` file also contains a few flags that are not defaults but that
-# users commonly want.
-#
-# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
config.before(:each) do
DatabaseCleaner.clean_with :truncation
@@ -52,56 +34,6 @@
config.include FeatureHelpers, type: :feature
WebMock.disable_net_connect!(allow_localhost: true)
-
-# The settings below are suggested to provide a good initial experience
-# with RSpec, but feel free to customize to your heart's content.
-=begin
- # These two settings work together to allow you to limit a spec run
- # to individual examples or groups you care about by tagging them with
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
- # get run.
- config.filter_run :focus
- config.run_all_when_everything_filtered = true
-
- # Allows RSpec to persist some state between runs in order to support
- # the `--only-failures` and `--next-failure` CLI options. We recommend
- # you configure your source control system to ignore this file.
- config.example_status_persistence_file_path = "spec/examples.txt"
-
- # Limits the available syntax to the non-monkey patched syntax that is
- # recommended. For more details, see:
- # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
- # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
- # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
- config.disable_monkey_patching!
-
- # Many RSpec users commonly either run the entire suite or an individual
- # file, and it's useful to allow more verbose output when running an
- # individual spec file.
- if config.files_to_run.one?
- # Use the documentation formatter for detailed output,
- # unless a formatter has already been configured
- # (e.g. via a command-line flag).
- config.default_formatter = 'doc'
- end
-
- # Print the 10 slowest examples and example groups at the
- # end of the spec run, to help surface which specs are running
- # particularly slow.
- config.profile_examples = 10
-
- # 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
- # the seed, which is printed after each run.
- # --seed 1234
- config.order = :random
-
- # Seed global randomization in this process using the `--seed` CLI option.
- # Setting this allows you to use `--seed` to deterministically reproduce
- # test failures related to randomization by passing the same `--seed` value
- # as the one that triggered the failure.
- Kernel.srand config.seed
-=end
end
# Don't prevent form fills by bots during the test run
@@ -112,24 +44,24 @@
# for controller tests
def login_as_admin
@request.env["devise.mapping"] = Devise.mappings[:admin]
- sign_in FactoryGirl.create(:admin_user)
+ sign_in FactoryBot.create(:admin_user)
end
def login_as_collaborator
@request.env["devise.mapping"] = Devise.mappings[:admin]
- sign_in FactoryGirl.create(:collaborator_user)
+ sign_in FactoryBot.create(:collaborator_user)
end
-def set_weak_password(user)
+def set_weak_password(user) # rubocop:todo Naming/AccessorMethodName
weak_password = "12345678"
user.password = weak_password
user.password_confirmation = weak_password
- result = user.save
+ user.save
end
-def set_strong_password(user)
+def set_strong_password(user) # rubocop:todo Naming/AccessorMethodName
weak_password = "strong passwords defeat lobsters covering wealth"
user.password = weak_password
user.password_confirmation = weak_password
- result = user.save
+ user.save
end
diff --git a/spec/support/exit_code_helpers.rb b/spec/support/exit_code_helpers.rb
index 2c2eb6614..b1d82e35d 100644
--- a/spec/support/exit_code_helpers.rb
+++ b/spec/support/exit_code_helpers.rb
@@ -14,11 +14,11 @@ def supports_block_expectations?
actual and actual == exp_code
end
- failure_message do |block|
+ failure_message do |_block|
"expected block to call exit(#{exp_code}) but exit" +
(actual.nil? ? " not called" : "(#{actual}) was called")
end
- failure_message_when_negated do |block|
+ failure_message_when_negated do |_block|
"expected block not to call exit(#{exp_code})"
end
description do
diff --git a/spec/support/feature_helpers.rb b/spec/support/feature_helpers.rb
index 2ae488dcf..9b791f99c 100644
--- a/spec/support/feature_helpers.rb
+++ b/spec/support/feature_helpers.rb
@@ -7,13 +7,18 @@ def sign_in_user(user)
click_button "Sign in"
end
+ def sign_out_user(_user)
+ find("#nav-modal-toggle").click
+ find("input[value='Logout']", visible: :all, match: :first).click
+ end
+
def disable_call_tool
allow(CallTool).to receive(:enabled?).and_return(false)
end
def fill_in_editor(locator, with:)
within_frame find(locator, visible: :all).sibling("div").find("iframe") do
- within_frame find("iframe") do
+ within_frame find("#epiceditor-editor-frame") do
find("body").set(with)
end
end
@@ -26,12 +31,10 @@ def fill_in_select2(locator, with:)
def tempermental(try: 2.times)
try.each do |attempt|
- begin
- yield
- break
- rescue RSpec::Expectations::ExpectationNotMetError => e
- raise e if attempt == try.size - 1
- end
+ yield
+ break
+ rescue RSpec::Expectations::ExpectationNotMetError => e
+ raise e if attempt == try.size - 1
end
end
end
diff --git a/spec/support/service_helpers.rb b/spec/support/service_helpers.rb
index 5029aae42..b8c46d6e6 100644
--- a/spec/support/service_helpers.rb
+++ b/spec/support/service_helpers.rb
@@ -1,12 +1,12 @@
module ServiceHelpers
def stub_civicrm
- Rails.application.secrets.supporters["host"] = "https://civicrm.test"
- stub_request(:post, CiviCRM::supporters_api_url).
- and_return(status: 200, body: "{}", headers: {})
+ Rails.application.secrets.supporters[:host] = "https://civicrm.test"
+ stub_request(:post, CiviCRM.supporters_api_url)
+ .and_return(status: 200, body: "{}", headers: {})
- stub_request(:post, CiviCRM::supporters_api_url).
- with(body: /generate_checksum/).
- and_return(status: 200, body: { checksum: "xyz" }.to_json, headers: {})
+ stub_request(:post, CiviCRM.supporters_api_url)
+ .with(body: /generate_checksum/)
+ .and_return(status: 200, body: { checksum: "xyz" }.to_json, headers: {})
end
end
@@ -14,4 +14,4 @@ def stub_civicrm
c.include ServiceHelpers
end
-World(ServiceHelpers) if respond_to?(:World) #cucumber
+World(ServiceHelpers) if respond_to?(:World) # cucumber
diff --git a/spec/tasks/signatures_spec.rb b/spec/tasks/signatures_spec.rb
index 9b0f5f7a1..e22c5b3f2 100644
--- a/spec/tasks/signatures_spec.rb
+++ b/spec/tasks/signatures_spec.rb
@@ -11,11 +11,15 @@
after { Rake.application["signatures:deduplicate"].reenable }
it "should delete signatures with non-unique emails from petitions" do
- regular_petition = FactoryGirl.create(:petition_complete_with_one_hundred_signatures)
+ regular_petition = FactoryBot.create(:petition_complete_with_one_hundred_signatures)
- petition_with_dups = FactoryGirl.create(:petition_complete_with_one_hundred_signatures)
+ petition_with_dups = FactoryBot.create(:petition_complete_with_one_hundred_signatures)
+ # rubocop:todo Rails/SkipsModelValidations
petition_with_dups.signatures.take(20).each { |sig| sig.update_column(:email, "dup1@example.com") }
+ # rubocop:enable Rails/SkipsModelValidations
+ # rubocop:todo Rails/SkipsModelValidations
petition_with_dups.signatures.take(10).each { |sig| sig.update_column(:email, "dup2@example.com") }
+ # rubocop:enable Rails/SkipsModelValidations
distinct_emails = petition_with_dups.signatures.pluck(:email).uniq
@@ -31,18 +35,18 @@
end
context "with duplicate subscriptions" do
- let(:subscription) { FactoryGirl.create(:subscription) }
+ let(:subscription) { FactoryBot.create(:subscription) }
let(:email) { subscription.email }
let(:partner) { subscription.partner }
let!(:owner_subscription2) do
- FactoryGirl.create(:subscription, email: email)
+ FactoryBot.create(:subscription, email: email)
end
let!(:partner_subscription2) do
- FactoryGirl.create(:subscription, partner: partner)
+ FactoryBot.create(:subscription, partner: partner)
end
let!(:dup_subscription) do
- FactoryGirl.create(:subscription)
- .update_columns(email: email, partner_id: partner.id)
+ FactoryBot.create(:subscription)
+ .update_columns(email: email, partner_id: partner.id)
end
it "removes the newer duplicates" do
diff --git a/spec/tasks/users_spec.rb b/spec/tasks/users_spec.rb
index 0e7bd1b5b..2e6165ef9 100644
--- a/spec/tasks/users_spec.rb
+++ b/spec/tasks/users_spec.rb
@@ -2,7 +2,7 @@
require "rake"
describe "User-related rake tasks" do
- let(:user) { FactoryGirl.create(:user) }
+ let(:user) { FactoryBot.create(:user) }
let(:email) { user.email }
let(:run_task) { Rake.application.invoke_task "#{task}[#{email}]" }
@@ -56,7 +56,7 @@
end
describe "users:remove_admin" do
- let(:user) { FactoryGirl.create(:user, admin: true) }
+ let(:user) { FactoryBot.create(:user, admin: true) }
let(:task) { "users:remove_admin" }
it "grants admin status to the given user" do