From c954a2a01777aeacd605d02c43dacc022b3af2b1 Mon Sep 17 00:00:00 2001 From: Margaret Williford Date: Wed, 7 Nov 2018 10:03:01 -0700 Subject: [PATCH 01/19] creating model tests for postal address --- spec/models/postal_address_spec.rb | 14 ++++++++++++++ spec/models/user_spec.rb | 1 + 2 files changed, 15 insertions(+) create mode 100644 spec/models/postal_address_spec.rb diff --git a/spec/models/postal_address_spec.rb b/spec/models/postal_address_spec.rb new file mode 100644 index 000000000..7aa6705ce --- /dev/null +++ b/spec/models/postal_address_spec.rb @@ -0,0 +1,14 @@ +require 'rails_helper' + +RSpec.describe PostalAddress, type: :model do + describe 'associations' do + it { is_expected.to belong_to(:user) } + end + + describe 'validations' do + it { should_validate_presence_of(:address_line_1)} + it { should_validate_presence_of(:city)} + it { should_validate_presence_of(:postal_code)} + it { should_validate_presence_of(:country)} + end +end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index b11c3378b..2b4cd878c 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -12,6 +12,7 @@ it { is_expected.to have_many(:applications).through(:teams) } it { is_expected.to have_many(:todos).dependent(:destroy) } it { is_expected.to have_many(:comments).dependent(:destroy) } + it { is_expected.to have_one(:postal_address).dependent(:destroy) } end describe 'validations' do From 549d37099bd4e09132db1949d2e4f07558e5b37f Mon Sep 17 00:00:00 2001 From: Margaret Williford Date: Wed, 7 Nov 2018 10:30:34 -0700 Subject: [PATCH 02/19] creating postal address model and removing attribute from users --- app/controllers/users_controller.rb | 2 +- app/models/postal_address.rb | 4 ++++ app/models/user.rb | 2 ++ .../20181107171037_create_postal_addresses.rb | 15 +++++++++++++++ ...07172409_remove_postal_address_from_users.rb | 5 +++++ db/schema.rb | 17 +++++++++++++++-- spec/models/postal_address_spec.rb | 8 ++++---- 7 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 app/models/postal_address.rb create mode 100644 db/migrate/20181107171037_create_postal_addresses.rb create mode 100644 db/migrate/20181107172409_remove_postal_address_from_users.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4224b2942..d983404c0 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -97,7 +97,7 @@ def user_params :github_handle, :twitter_handle, :irc_handle, :name, :email, :homepage, :location, :bio, :tech_expertise_list, :tech_interest_list, - :tshirt_size, :tshirt_cut, :postal_address, :timezone, + :tshirt_size, :tshirt_cut, :timezone, :country, :hide_email, :is_company, :company_name, :company_info, diff --git a/app/models/postal_address.rb b/app/models/postal_address.rb new file mode 100644 index 000000000..2be83f86d --- /dev/null +++ b/app/models/postal_address.rb @@ -0,0 +1,4 @@ +class PostalAddress < ApplicationRecord + belongs_to :user + validates_presence_of :address_line_1, :city, :postal_code, :country +end diff --git a/app/models/user.rb b/app/models/user.rb index 1d5732086..fda75dd3f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -65,6 +65,7 @@ def student has_many :applications, through: :teams has_many :todos, dependent: :destroy has_many :comments, dependent: :destroy + has_one :postal_address, dependent: :destroy validates :github_handle, presence: true, uniqueness: { case_sensitive: false } validates :homepage, format: { with: URL_PREFIX_PATTERN }, allow_blank: true @@ -73,6 +74,7 @@ def student validates :name, :email, :country, :location, presence: true, unless: :github_import accepts_nested_attributes_for :roles, allow_destroy: true + accepts_nested_attributes_for :postal_address, allow_destroy: true before_save :normalize_location after_create :complete_from_github diff --git a/db/migrate/20181107171037_create_postal_addresses.rb b/db/migrate/20181107171037_create_postal_addresses.rb new file mode 100644 index 000000000..1ca1a49c8 --- /dev/null +++ b/db/migrate/20181107171037_create_postal_addresses.rb @@ -0,0 +1,15 @@ +class CreatePostalAddresses < ActiveRecord::Migration[5.1] + def change + create_table :postal_addresses do |t| + t.string :address_line_1 + t.string :address_line_2 + t.string :city + t.string :state_or_province + t.string :postal_code + t.string :country + + t.references :user, foreign_key: true + t.timestamps + end + end +end diff --git a/db/migrate/20181107172409_remove_postal_address_from_users.rb b/db/migrate/20181107172409_remove_postal_address_from_users.rb new file mode 100644 index 000000000..0c1cf5ee2 --- /dev/null +++ b/db/migrate/20181107172409_remove_postal_address_from_users.rb @@ -0,0 +1,5 @@ +class RemovePostalAddressFromUsers < ActiveRecord::Migration[5.1] + def change + remove_column :users, :postal_address, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 98eff50a1..1d226020d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180714153306) do +ActiveRecord::Schema.define(version: 20181107172409) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -173,6 +173,19 @@ t.index ["user_id"], name: "index_notes_on_user_id" end + create_table "postal_addresses", force: :cascade do |t| + t.string "address_line_1" + t.string "address_line_2" + t.string "city" + t.string "state_or_province" + t.string "postal_code" + t.string "country" + t.bigint "user_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["user_id"], name: "index_postal_addresses_on_user_id" + end + create_table "projects", id: :serial, force: :cascade do |t| t.string "name", limit: 255 t.datetime "created_at" @@ -296,7 +309,6 @@ t.string "twitter_handle", limit: 255 t.string "irc_handle", limit: 255 t.string "tshirt_size", limit: 255 - t.text "postal_address" t.string "timezone", limit: 255 t.string "interested_in", limit: 255, default: [], array: true t.boolean "hide_email" @@ -339,5 +351,6 @@ t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true end + add_foreign_key "postal_addresses", "users" add_foreign_key "teams", "projects" end diff --git a/spec/models/postal_address_spec.rb b/spec/models/postal_address_spec.rb index 7aa6705ce..43005354c 100644 --- a/spec/models/postal_address_spec.rb +++ b/spec/models/postal_address_spec.rb @@ -6,9 +6,9 @@ end describe 'validations' do - it { should_validate_presence_of(:address_line_1)} - it { should_validate_presence_of(:city)} - it { should_validate_presence_of(:postal_code)} - it { should_validate_presence_of(:country)} + it { is_expected.to validate_presence_of(:address_line_1)} + it { is_expected.to validate_presence_of(:city)} + it { is_expected.to validate_presence_of(:postal_code)} + it { is_expected.to validate_presence_of(:country)} end end From 08bb3d228c70aad0e871ee7bfda96c69ea2d7399 Mon Sep 17 00:00:00 2001 From: Margaret Williford Date: Wed, 7 Nov 2018 11:12:46 -0700 Subject: [PATCH 03/19] accepts nested attributes form for postal address --- app/controllers/users_controller.rb | 3 ++- app/views/users/edit.html.slim | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d983404c0..7ab4488c4 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -107,7 +107,8 @@ def user_params :application_learning_history, :application_skills, :application_code_samples, :application_location, :application_minimum_money, :application_money, :application_goals, :application_code_background, interested_in: [], - roles_attributes: [:id, :name, :team_id, :_destroy] + roles_attributes: [:id, :name, :team_id, :_destroy], + postal_address_attributes: [:address_line_1, :address_line_2, :city, :state_or_province, :country] ) end end diff --git a/app/views/users/edit.html.slim b/app/views/users/edit.html.slim index 28a1df06f..d23e3bfff 100644 --- a/app/views/users/edit.html.slim +++ b/app/views/users/edit.html.slim @@ -107,7 +107,14 @@ p.help-block This information will only be visible to yourself and the organizers. = f.input :tshirt_size, as: :select, collection: User::TSHIRT_SIZES.map { |k| [k, k] }, label: 'T-Shirt size', blank: false, required: false, hint: 'For sponsor T-Shirts, in case they send some.' = f.input :tshirt_cut, as: :select, collection: User::TSHIRT_CUTS.map { |s| [s, s] }, label: 'T-Shirt cut', include_blank: true - = f.input :postal_address, hint: "Please give your postal address, including your full name, so we can send things we've received from our sponsors for you :)" + h4 Shipping Address + = f.simple_fields_for :postal_addresses do |pa| + = pa.input :address_line_1, required: false + = pa.input :address_line_2, required: false + = pa.input :city, required: false + = pa.input :state_or_province, required: false + = pa.input :country, required: false + - if admin? h3.page-header Roles From dd200a35acdec338bc23d21c8eb5e77fa3389c50 Mon Sep 17 00:00:00 2001 From: Margaret Williford Date: Wed, 7 Nov 2018 11:48:05 -0700 Subject: [PATCH 04/19] adding postal address factory and happy path testing for adding shipping address --- app/views/users/edit.html.slim | 1 + spec/factories/postal_address.rb | 11 ++++++++ spec/features/users/postal_address_spec.rb | 33 ++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 spec/factories/postal_address.rb create mode 100644 spec/features/users/postal_address_spec.rb diff --git a/app/views/users/edit.html.slim b/app/views/users/edit.html.slim index d23e3bfff..d4f87ce66 100644 --- a/app/views/users/edit.html.slim +++ b/app/views/users/edit.html.slim @@ -113,6 +113,7 @@ = pa.input :address_line_2, required: false = pa.input :city, required: false = pa.input :state_or_province, required: false + = pa.input :postal_code, required: false = pa.input :country, required: false diff --git a/spec/factories/postal_address.rb b/spec/factories/postal_address.rb new file mode 100644 index 000000000..7b35261ad --- /dev/null +++ b/spec/factories/postal_address.rb @@ -0,0 +1,11 @@ +FactoryBot.define do + factory :postal_address do + user + address_line_1 { FFaker::AddressUS.street_address } + address_line_2 { FFaker::AddressUS.secondary_address } + city { FFaker::AddressUS.city} + state_or_province { FFaker::AddressUS.state} + postal_code { FFaker::AddressUS.zip_code} + country { FFaker::AddressUS.country} + end +end diff --git a/spec/features/users/postal_address_spec.rb b/spec/features/users/postal_address_spec.rb new file mode 100644 index 000000000..deea95cb6 --- /dev/null +++ b/spec/features/users/postal_address_spec.rb @@ -0,0 +1,33 @@ +require 'rails_helper' + +RSpec.describe 'Add Postal Address', type: :feature do + let(:user) { create(:user) } + let(:address) { create(:postal_address) } + + context 'signed in' do + before { sign_in user } + + context 'in the user edit page' do + before { visit edit_user_path(user) } + + it 'allows creation of postal address if all required address fields are entered' do + fill_in 'user_postal_addresses_address_line_1', with: address.address_line_1 + fill_in 'user_postal_addresses_address_line_2', with: address.address_line_2 + fill_in 'user_postal_addresses_city', with: address.city + fill_in 'user_postal_addresses_state_or_province', with: address.state_or_province + fill_in 'user_postal_addresses_postal_code', with: address.postal_code + select address.country, from: 'user_postal_addresses_country' + click_on 'Save' + + expect(current_path).to eq user_path(user) + + expect(page).to have_content address.address_line_1 + expect(page).to have_content address.address_line_2 + expect(page).to have_content address.city + expect(page).to have_content address.state_or_province + expect(page).to have_content address.postal_code + expect(page).to have_content address.country + end + end + end +end From 752ab32c4c14386a4f269b7a730db197ae801667 Mon Sep 17 00:00:00 2001 From: Margaret Williford Date: Wed, 7 Nov 2018 13:21:17 -0700 Subject: [PATCH 05/19] fixing nested attributes pluralization --- app/controllers/users_controller.rb | 2 +- app/views/users/edit.html.slim | 2 +- spec/factories/postal_address.rb | 2 +- spec/features/users/postal_address_spec.rb | 12 ++++++------ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 7ab4488c4..4715bbcc1 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -108,7 +108,7 @@ def user_params :application_location, :application_minimum_money, :application_money, :application_goals, :application_code_background, interested_in: [], roles_attributes: [:id, :name, :team_id, :_destroy], - postal_address_attributes: [:address_line_1, :address_line_2, :city, :state_or_province, :country] + postal_address_attributes: [:id, :address_line_1, :address_line_2, :city, :state_or_province, :postal_code, :country] ) end end diff --git a/app/views/users/edit.html.slim b/app/views/users/edit.html.slim index d4f87ce66..3e07bf6f5 100644 --- a/app/views/users/edit.html.slim +++ b/app/views/users/edit.html.slim @@ -108,7 +108,7 @@ = f.input :tshirt_size, as: :select, collection: User::TSHIRT_SIZES.map { |k| [k, k] }, label: 'T-Shirt size', blank: false, required: false, hint: 'For sponsor T-Shirts, in case they send some.' = f.input :tshirt_cut, as: :select, collection: User::TSHIRT_CUTS.map { |s| [s, s] }, label: 'T-Shirt cut', include_blank: true h4 Shipping Address - = f.simple_fields_for :postal_addresses do |pa| + = f.simple_fields_for :postal_address_attributes do |pa| = pa.input :address_line_1, required: false = pa.input :address_line_2, required: false = pa.input :city, required: false diff --git a/spec/factories/postal_address.rb b/spec/factories/postal_address.rb index 7b35261ad..78f971ea7 100644 --- a/spec/factories/postal_address.rb +++ b/spec/factories/postal_address.rb @@ -6,6 +6,6 @@ city { FFaker::AddressUS.city} state_or_province { FFaker::AddressUS.state} postal_code { FFaker::AddressUS.zip_code} - country { FFaker::AddressUS.country} + country "Barbados" end end diff --git a/spec/features/users/postal_address_spec.rb b/spec/features/users/postal_address_spec.rb index deea95cb6..8b472a7c1 100644 --- a/spec/features/users/postal_address_spec.rb +++ b/spec/features/users/postal_address_spec.rb @@ -11,12 +11,12 @@ before { visit edit_user_path(user) } it 'allows creation of postal address if all required address fields are entered' do - fill_in 'user_postal_addresses_address_line_1', with: address.address_line_1 - fill_in 'user_postal_addresses_address_line_2', with: address.address_line_2 - fill_in 'user_postal_addresses_city', with: address.city - fill_in 'user_postal_addresses_state_or_province', with: address.state_or_province - fill_in 'user_postal_addresses_postal_code', with: address.postal_code - select address.country, from: 'user_postal_addresses_country' + fill_in 'user[postal_address_attributes][address_line_1]', with: address.address_line_1 + fill_in 'user[postal_address_attributes][address_line_2]', with: address.address_line_2 + fill_in 'user[postal_address_attributes][city]', with: address.city + fill_in 'user[postal_address_attributes][state_or_province]', with: address.state_or_province + fill_in 'user[postal_address_attributes][postal_code]', with: address.postal_code + select address.country, from: 'user[postal_address_attributes][country]' click_on 'Save' expect(current_path).to eq user_path(user) From 0992f1f3124e09e50e26ba9af8ddd014e24f08e0 Mon Sep 17 00:00:00 2001 From: Margaret Williford Date: Wed, 7 Nov 2018 15:39:58 -0700 Subject: [PATCH 06/19] display shipping address on user profile page --- app/views/users/edit.html.slim | 2 +- app/views/users/show.html.slim | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/views/users/edit.html.slim b/app/views/users/edit.html.slim index 3e07bf6f5..6742a8200 100644 --- a/app/views/users/edit.html.slim +++ b/app/views/users/edit.html.slim @@ -114,7 +114,7 @@ = pa.input :city, required: false = pa.input :state_or_province, required: false = pa.input :postal_code, required: false - = pa.input :country, required: false + = pa.input :country, as: :country, label: "Country", prompt: "Select your country", required: false - if admin? diff --git a/app/views/users/show.html.slim b/app/views/users/show.html.slim index 36db984d6..5b0cf667a 100644 --- a/app/views/users/show.html.slim +++ b/app/views/users/show.html.slim @@ -65,9 +65,27 @@ nav.actions p = @user.company_info - if can_see_private_info? - - fields = ['tshirt_size', 'tshirt_cut', 'postal_address'] .well.private-info h3 Private info + h4 Postal Address + p + - if @user.postal_address.address_line_1 + = @user.postal_address.address_line_1 + br + - if @user.postal_address.address_line_2 + = @user.postal_address.address_line_2 + br + - if @user.postal_address.city + = @user.postal_address.city + br + - if @user.postal_address.state_or_province + = @user.postal_address.state_or_province + br + - if @user.postal_address.postal_code + = @user.postal_address.postal_code + br + = User.human_attribute_name(@user.postal_address.country) + - fields = ['tshirt_size', 'tshirt_cut'] - fields.each do |field| - if @user.send(field).present? p From f3d0205ec5b18274458407ae44c03508ca77928a Mon Sep 17 00:00:00 2001 From: Margaret Williford Date: Wed, 7 Nov 2018 16:33:07 -0700 Subject: [PATCH 07/19] reject blank postal addresses and add formatter method --- app/models/postal_address.rb | 4 ++++ app/models/user.rb | 6 +++++- app/views/users/show.html.slim | 22 ++++------------------ spec/features/users/postal_address_spec.rb | 2 +- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/app/models/postal_address.rb b/app/models/postal_address.rb index 2be83f86d..3c3c2d21a 100644 --- a/app/models/postal_address.rb +++ b/app/models/postal_address.rb @@ -1,4 +1,8 @@ class PostalAddress < ApplicationRecord belongs_to :user validates_presence_of :address_line_1, :city, :postal_code, :country + + def formatted + "#{address_line_1.split.map(&:capitalize).join(' ')} #{address_line_2} #{city}, #{state_or_province} #{postal_code} #{country}" + end end diff --git a/app/models/user.rb b/app/models/user.rb index fda75dd3f..f36beb9b3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -74,7 +74,11 @@ def student validates :name, :email, :country, :location, presence: true, unless: :github_import accepts_nested_attributes_for :roles, allow_destroy: true - accepts_nested_attributes_for :postal_address, allow_destroy: true + accepts_nested_attributes_for :postal_address, allow_destroy: true, reject_if: :postal_address_rejectable? + + def postal_address_rejectable?(attr) + attr['address_line_1'].blank? || attr['city'].blank? || attr['postal_code'].blank? || attr['country'].blank? + end before_save :normalize_location after_create :complete_from_github diff --git a/app/views/users/show.html.slim b/app/views/users/show.html.slim index 5b0cf667a..0e9053b77 100644 --- a/app/views/users/show.html.slim +++ b/app/views/users/show.html.slim @@ -67,24 +67,10 @@ nav.actions - if can_see_private_info? .well.private-info h3 Private info - h4 Postal Address - p - - if @user.postal_address.address_line_1 - = @user.postal_address.address_line_1 - br - - if @user.postal_address.address_line_2 - = @user.postal_address.address_line_2 - br - - if @user.postal_address.city - = @user.postal_address.city - br - - if @user.postal_address.state_or_province - = @user.postal_address.state_or_province - br - - if @user.postal_address.postal_code - = @user.postal_address.postal_code - br - = User.human_attribute_name(@user.postal_address.country) + - if @user.postal_address + h4 Postal Address + p + = @user.postal_address.formatted - fields = ['tshirt_size', 'tshirt_cut'] - fields.each do |field| - if @user.send(field).present? diff --git a/spec/features/users/postal_address_spec.rb b/spec/features/users/postal_address_spec.rb index 8b472a7c1..d37da1ca0 100644 --- a/spec/features/users/postal_address_spec.rb +++ b/spec/features/users/postal_address_spec.rb @@ -26,7 +26,7 @@ expect(page).to have_content address.city expect(page).to have_content address.state_or_province expect(page).to have_content address.postal_code - expect(page).to have_content address.country + # expect(page).to have_content address.country end end end From 020fc85014ab7bec770129e28f2dc55d743095a0 Mon Sep 17 00:00:00 2001 From: Margaret Williford Date: Fri, 9 Nov 2018 12:00:54 -0700 Subject: [PATCH 08/19] nest attributes postal address form prepopulates with saved info --- app/views/users/edit.html.slim | 2 +- spec/features/users/postal_address_spec.rb | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/views/users/edit.html.slim b/app/views/users/edit.html.slim index 6742a8200..16361fcd2 100644 --- a/app/views/users/edit.html.slim +++ b/app/views/users/edit.html.slim @@ -108,7 +108,7 @@ = f.input :tshirt_size, as: :select, collection: User::TSHIRT_SIZES.map { |k| [k, k] }, label: 'T-Shirt size', blank: false, required: false, hint: 'For sponsor T-Shirts, in case they send some.' = f.input :tshirt_cut, as: :select, collection: User::TSHIRT_CUTS.map { |s| [s, s] }, label: 'T-Shirt cut', include_blank: true h4 Shipping Address - = f.simple_fields_for :postal_address_attributes do |pa| + = f.simple_fields_for :postal_address_attributes, @user.postal_address do |pa| = pa.input :address_line_1, required: false = pa.input :address_line_2, required: false = pa.input :city, required: false diff --git a/spec/features/users/postal_address_spec.rb b/spec/features/users/postal_address_spec.rb index d37da1ca0..cc9cb8c7a 100644 --- a/spec/features/users/postal_address_spec.rb +++ b/spec/features/users/postal_address_spec.rb @@ -28,6 +28,26 @@ expect(page).to have_content address.postal_code # expect(page).to have_content address.country end + + it 'does not allow a postal address to be added if required fields are missing' do + fill_in 'user[postal_address_attributes][address_line_1]', with: address.address_line_1 + fill_in 'user[postal_address_attributes][postal_code]', with: address.postal_code + click_on 'Save' + + expect(current_path).to eq edit_user_path(user) + + expect(page).to have_content "If adding a shipping address, please include all required fields." + end + + it 'autofills saved postal address info on edit form if it exists' do + user.update(postal_address: create(:postal_address)) + visit edit_user_path(user) + + expect(page).to have_selector("input[value='#{user.postal_address.address_line_1}']") + expect(page).to have_selector("input[value='#{user.postal_address.city}']") + expect(page).to have_selector("input[value='#{user.postal_address.state_or_province}']") + expect(page).to have_selector("input[value='#{user.postal_address.postal_code}']") + end end end end From 30eb3b31bd0afb4e27721e84c4d9755ce407df54 Mon Sep 17 00:00:00 2001 From: Margaret Williford Date: Fri, 9 Nov 2018 13:26:44 -0700 Subject: [PATCH 09/19] user can delete a postal address --- app/controllers/users_controller.rb | 2 +- app/views/users/edit.html.slim | 4 +++- spec/features/users/postal_address_spec.rb | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4715bbcc1..efbf8eca1 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -108,7 +108,7 @@ def user_params :application_location, :application_minimum_money, :application_money, :application_goals, :application_code_background, interested_in: [], roles_attributes: [:id, :name, :team_id, :_destroy], - postal_address_attributes: [:id, :address_line_1, :address_line_2, :city, :state_or_province, :postal_code, :country] + postal_address_attributes: [:id, :address_line_1, :address_line_2, :city, :state_or_province, :postal_code, :country, :_destroy] ) end end diff --git a/app/views/users/edit.html.slim b/app/views/users/edit.html.slim index 16361fcd2..6ea6126aa 100644 --- a/app/views/users/edit.html.slim +++ b/app/views/users/edit.html.slim @@ -108,13 +108,15 @@ = f.input :tshirt_size, as: :select, collection: User::TSHIRT_SIZES.map { |k| [k, k] }, label: 'T-Shirt size', blank: false, required: false, hint: 'For sponsor T-Shirts, in case they send some.' = f.input :tshirt_cut, as: :select, collection: User::TSHIRT_CUTS.map { |s| [s, s] }, label: 'T-Shirt cut', include_blank: true h4 Shipping Address + - if @user.postal_address + = link_to "Remove Address", user_path(@user, user: { postal_address_attributes: { id: @user.postal_address.id, "_destroy" => true }}), method: :put, data: { confirm: 'You sure?' } = f.simple_fields_for :postal_address_attributes, @user.postal_address do |pa| = pa.input :address_line_1, required: false = pa.input :address_line_2, required: false = pa.input :city, required: false = pa.input :state_or_province, required: false = pa.input :postal_code, required: false - = pa.input :country, as: :country, label: "Country", prompt: "Select your country", required: false + = pa.input :country, prompt: "Select your country", required: false, include_blank: true - if admin? diff --git a/spec/features/users/postal_address_spec.rb b/spec/features/users/postal_address_spec.rb index cc9cb8c7a..2e40252ce 100644 --- a/spec/features/users/postal_address_spec.rb +++ b/spec/features/users/postal_address_spec.rb @@ -48,6 +48,23 @@ expect(page).to have_selector("input[value='#{user.postal_address.state_or_province}']") expect(page).to have_selector("input[value='#{user.postal_address.postal_code}']") end + + it 'lets you delete an existing postal address' do + user.update(postal_address: address) + visit edit_user_path(user) + + accept_alert do + click_on 'Remove Address' + end + + expect(current_path).to eq user_path(user) + + expect(page).to_not have_content address.address_line_1 + expect(page).to_not have_content address.address_line_2 + expect(page).to_not have_content address.city + expect(page).to_not have_content address.state_or_province + expect(page).to_not have_content address.postal_code + end end end end From e57bc9c8d7656953651e16d31f6864d7b7584baa Mon Sep 17 00:00:00 2001 From: Margaret Williford Date: Fri, 9 Nov 2018 14:37:53 -0700 Subject: [PATCH 10/19] user sees error if partially completing postal address field --- app/models/user.rb | 2 +- app/views/users/edit.html.slim | 2 +- spec/features/users/postal_address_spec.rb | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index f36beb9b3..292a75376 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -74,7 +74,7 @@ def student validates :name, :email, :country, :location, presence: true, unless: :github_import accepts_nested_attributes_for :roles, allow_destroy: true - accepts_nested_attributes_for :postal_address, allow_destroy: true, reject_if: :postal_address_rejectable? + accepts_nested_attributes_for :postal_address, allow_destroy: true, reject_if: :all_blank def postal_address_rejectable?(attr) attr['address_line_1'].blank? || attr['city'].blank? || attr['postal_code'].blank? || attr['country'].blank? diff --git a/app/views/users/edit.html.slim b/app/views/users/edit.html.slim index 6ea6126aa..2c52095d3 100644 --- a/app/views/users/edit.html.slim +++ b/app/views/users/edit.html.slim @@ -109,7 +109,7 @@ = f.input :tshirt_cut, as: :select, collection: User::TSHIRT_CUTS.map { |s| [s, s] }, label: 'T-Shirt cut', include_blank: true h4 Shipping Address - if @user.postal_address - = link_to "Remove Address", user_path(@user, user: { postal_address_attributes: { id: @user.postal_address.id, "_destroy" => true }}), method: :put, data: { confirm: 'You sure?' } + = link_to "Remove Address", user_path(@user, user: { postal_address_attributes: { id: @user.postal_address.id, "_destroy" => true }}), method: :put, data: { confirm: 'Are you sure?' } = f.simple_fields_for :postal_address_attributes, @user.postal_address do |pa| = pa.input :address_line_1, required: false = pa.input :address_line_2, required: false diff --git a/spec/features/users/postal_address_spec.rb b/spec/features/users/postal_address_spec.rb index 2e40252ce..7d62ce345 100644 --- a/spec/features/users/postal_address_spec.rb +++ b/spec/features/users/postal_address_spec.rb @@ -30,13 +30,13 @@ end it 'does not allow a postal address to be added if required fields are missing' do + expect(user.postal_address).to be_nil fill_in 'user[postal_address_attributes][address_line_1]', with: address.address_line_1 fill_in 'user[postal_address_attributes][postal_code]', with: address.postal_code click_on 'Save' - expect(current_path).to eq edit_user_path(user) - - expect(page).to have_content "If adding a shipping address, please include all required fields." + expect(page).to have_content "Postal address city can't be blank" + expect(page).to have_content "Postal address country can't be blank" end it 'autofills saved postal address info on edit form if it exists' do From 89c8a4ca73180c3e386be5593fbc7a938578bd32 Mon Sep 17 00:00:00 2001 From: Margaret Williford Date: Fri, 9 Nov 2018 15:10:49 -0700 Subject: [PATCH 11/19] formatting address on user profile page --- app/models/postal_address.rb | 9 ++++++++- spec/factories/postal_address.rb | 2 +- spec/features/users/postal_address_spec.rb | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/models/postal_address.rb b/app/models/postal_address.rb index 3c3c2d21a..e82f88513 100644 --- a/app/models/postal_address.rb +++ b/app/models/postal_address.rb @@ -1,8 +1,15 @@ +# frozen_string_literal: true class PostalAddress < ApplicationRecord belongs_to :user validates_presence_of :address_line_1, :city, :postal_code, :country def formatted - "#{address_line_1.split.map(&:capitalize).join(' ')} #{address_line_2} #{city}, #{state_or_province} #{postal_code} #{country}" + "#{capitalize(address_line_1)} #{capitalize(address_line_2)} #{capitalize(city)}, #{state_or_province} #{postal_code} #{country}" + end + + private + + def capitalize(string) + string.split.map(&:capitalize).join(' ') end end diff --git a/spec/factories/postal_address.rb b/spec/factories/postal_address.rb index 78f971ea7..812247d9c 100644 --- a/spec/factories/postal_address.rb +++ b/spec/factories/postal_address.rb @@ -6,6 +6,6 @@ city { FFaker::AddressUS.city} state_or_province { FFaker::AddressUS.state} postal_code { FFaker::AddressUS.zip_code} - country "Barbados" + country { FFaker::Address.country } end end diff --git a/spec/features/users/postal_address_spec.rb b/spec/features/users/postal_address_spec.rb index 7d62ce345..d32fbe6a1 100644 --- a/spec/features/users/postal_address_spec.rb +++ b/spec/features/users/postal_address_spec.rb @@ -26,7 +26,7 @@ expect(page).to have_content address.city expect(page).to have_content address.state_or_province expect(page).to have_content address.postal_code - # expect(page).to have_content address.country + expect(page).to have_content user.postal_address.country end it 'does not allow a postal address to be added if required fields are missing' do From 2eea06b7848b1735633e4aa69d010d486b9cad09 Mon Sep 17 00:00:00 2001 From: Margaret Williford Date: Fri, 9 Nov 2018 15:46:45 -0700 Subject: [PATCH 12/19] rubocop fix --- db/migrate/20181107171037_create_postal_addresses.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20181107171037_create_postal_addresses.rb b/db/migrate/20181107171037_create_postal_addresses.rb index 1ca1a49c8..0606cbdb8 100644 --- a/db/migrate/20181107171037_create_postal_addresses.rb +++ b/db/migrate/20181107171037_create_postal_addresses.rb @@ -7,7 +7,7 @@ def change t.string :state_or_province t.string :postal_code t.string :country - + t.references :user, foreign_key: true t.timestamps end From e73d7fa537c5e8d3d480d4f7132b48362011f5fe Mon Sep 17 00:00:00 2001 From: Margaret Williford Date: Tue, 13 Nov 2018 14:32:28 -0700 Subject: [PATCH 13/19] rename postal address db columns and update spec --- app/controllers/users_controller.rb | 2 +- app/models/postal_address.rb | 11 ++-- app/models/user.rb | 4 -- app/views/users/edit.html.slim | 8 +-- ...3210909_fix_postal_address_column_names.rb | 8 +++ db/schema.rb | 10 ++-- spec/factories/postal_address.rb | 10 ++-- spec/features/users/postal_address_spec.rb | 52 +++++++++---------- spec/models/postal_address_spec.rb | 2 +- 9 files changed, 53 insertions(+), 54 deletions(-) create mode 100644 db/migrate/20181113210909_fix_postal_address_column_names.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index efbf8eca1..2dfccf0dd 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -108,7 +108,7 @@ def user_params :application_location, :application_minimum_money, :application_money, :application_goals, :application_code_background, interested_in: [], roles_attributes: [:id, :name, :team_id, :_destroy], - postal_address_attributes: [:id, :address_line_1, :address_line_2, :city, :state_or_province, :postal_code, :country, :_destroy] + postal_address_attributes: [:id, :line1, :line2, :city, :state, :zip, :country, :_destroy] ) end end diff --git a/app/models/postal_address.rb b/app/models/postal_address.rb index e82f88513..3013b5586 100644 --- a/app/models/postal_address.rb +++ b/app/models/postal_address.rb @@ -1,15 +1,10 @@ # frozen_string_literal: true class PostalAddress < ApplicationRecord belongs_to :user - validates_presence_of :address_line_1, :city, :postal_code, :country - def formatted - "#{capitalize(address_line_1)} #{capitalize(address_line_2)} #{capitalize(city)}, #{state_or_province} #{postal_code} #{country}" - end + validates_presence_of :line1, :city, :zip, :country - private - - def capitalize(string) - string.split.map(&:capitalize).join(' ') + def formatted + "#{line1.titlecase} #{line2.titlecase} #{city.titlecase}, #{state} #{zip} #{country}" end end diff --git a/app/models/user.rb b/app/models/user.rb index 292a75376..9d9691ce4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -76,10 +76,6 @@ def student accepts_nested_attributes_for :roles, allow_destroy: true accepts_nested_attributes_for :postal_address, allow_destroy: true, reject_if: :all_blank - def postal_address_rejectable?(attr) - attr['address_line_1'].blank? || attr['city'].blank? || attr['postal_code'].blank? || attr['country'].blank? - end - before_save :normalize_location after_create :complete_from_github diff --git a/app/views/users/edit.html.slim b/app/views/users/edit.html.slim index 2c52095d3..9b28c7d85 100644 --- a/app/views/users/edit.html.slim +++ b/app/views/users/edit.html.slim @@ -111,11 +111,11 @@ - if @user.postal_address = link_to "Remove Address", user_path(@user, user: { postal_address_attributes: { id: @user.postal_address.id, "_destroy" => true }}), method: :put, data: { confirm: 'Are you sure?' } = f.simple_fields_for :postal_address_attributes, @user.postal_address do |pa| - = pa.input :address_line_1, required: false - = pa.input :address_line_2, required: false + = pa.input :line1, required: false + = pa.input :line2, required: false = pa.input :city, required: false - = pa.input :state_or_province, required: false - = pa.input :postal_code, required: false + = pa.input :state, required: false + = pa.input :zip, required: false = pa.input :country, prompt: "Select your country", required: false, include_blank: true diff --git a/db/migrate/20181113210909_fix_postal_address_column_names.rb b/db/migrate/20181113210909_fix_postal_address_column_names.rb new file mode 100644 index 000000000..2f22bcf78 --- /dev/null +++ b/db/migrate/20181113210909_fix_postal_address_column_names.rb @@ -0,0 +1,8 @@ +class FixPostalAddressColumnNames < ActiveRecord::Migration[5.1] + def change + rename_column :postal_addresses, :address_line_1, :line1 + rename_column :postal_addresses, :address_line_2, :line2 + rename_column :postal_addresses, :state_or_province, :state + rename_column :postal_addresses, :postal_code, :zip + end +end diff --git a/db/schema.rb b/db/schema.rb index 1d226020d..902d6289b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20181107172409) do +ActiveRecord::Schema.define(version: 20181113210909) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -174,11 +174,11 @@ end create_table "postal_addresses", force: :cascade do |t| - t.string "address_line_1" - t.string "address_line_2" + t.string "line1" + t.string "line2" t.string "city" - t.string "state_or_province" - t.string "postal_code" + t.string "state" + t.string "zip" t.string "country" t.bigint "user_id" t.datetime "created_at", null: false diff --git a/spec/factories/postal_address.rb b/spec/factories/postal_address.rb index 812247d9c..74893f5cb 100644 --- a/spec/factories/postal_address.rb +++ b/spec/factories/postal_address.rb @@ -1,11 +1,11 @@ FactoryBot.define do factory :postal_address do user - address_line_1 { FFaker::AddressUS.street_address } - address_line_2 { FFaker::AddressUS.secondary_address } + line1 { FFaker::AddressUS.street_address } + line2 { FFaker::AddressUS.secondary_address } city { FFaker::AddressUS.city} - state_or_province { FFaker::AddressUS.state} - postal_code { FFaker::AddressUS.zip_code} - country { FFaker::Address.country } + state { FFaker::AddressUS.state} + zip { FFaker::AddressUS.zip_code} + country { "United States" } end end diff --git a/spec/features/users/postal_address_spec.rb b/spec/features/users/postal_address_spec.rb index d32fbe6a1..0a47a27b3 100644 --- a/spec/features/users/postal_address_spec.rb +++ b/spec/features/users/postal_address_spec.rb @@ -11,46 +11,47 @@ before { visit edit_user_path(user) } it 'allows creation of postal address if all required address fields are entered' do - fill_in 'user[postal_address_attributes][address_line_1]', with: address.address_line_1 - fill_in 'user[postal_address_attributes][address_line_2]', with: address.address_line_2 - fill_in 'user[postal_address_attributes][city]', with: address.city - fill_in 'user[postal_address_attributes][state_or_province]', with: address.state_or_province - fill_in 'user[postal_address_attributes][postal_code]', with: address.postal_code - select address.country, from: 'user[postal_address_attributes][country]' + fill_in 'Line1', with: address.line1 + fill_in 'Line2', with: address.line2 + fill_in 'City', with: address.city + fill_in 'State', with: address.state + fill_in 'Zip', with: address.zip + select address.country, from: 'Country' click_on 'Save' expect(current_path).to eq user_path(user) - expect(page).to have_content address.address_line_1 - expect(page).to have_content address.address_line_2 + expect(page).to have_content address.line1 + expect(page).to have_content address.line2 expect(page).to have_content address.city - expect(page).to have_content address.state_or_province - expect(page).to have_content address.postal_code - expect(page).to have_content user.postal_address.country + expect(page).to have_content address.state + expect(page).to have_content address.zip + expect(page).to have_content 'US' end it 'does not allow a postal address to be added if required fields are missing' do - expect(user.postal_address).to be_nil - fill_in 'user[postal_address_attributes][address_line_1]', with: address.address_line_1 - fill_in 'user[postal_address_attributes][postal_code]', with: address.postal_code + fill_in 'Line1', with: address.line1 + fill_in 'Zip', with: address.zip click_on 'Save' expect(page).to have_content "Postal address city can't be blank" expect(page).to have_content "Postal address country can't be blank" end + end + + context 'when the user already has a postal address set up' do + let!(:postal_address) { create(:postal_address, user: user) } it 'autofills saved postal address info on edit form if it exists' do - user.update(postal_address: create(:postal_address)) visit edit_user_path(user) - expect(page).to have_selector("input[value='#{user.postal_address.address_line_1}']") + expect(page).to have_selector("input[value='#{user.postal_address.line1}']") expect(page).to have_selector("input[value='#{user.postal_address.city}']") - expect(page).to have_selector("input[value='#{user.postal_address.state_or_province}']") - expect(page).to have_selector("input[value='#{user.postal_address.postal_code}']") + expect(page).to have_selector("input[value='#{user.postal_address.state}']") + expect(page).to have_selector("input[value='#{user.postal_address.zip}']") end - it 'lets you delete an existing postal address' do - user.update(postal_address: address) + it 'allows to delete an existing postal address' do visit edit_user_path(user) accept_alert do @@ -58,12 +59,11 @@ end expect(current_path).to eq user_path(user) - - expect(page).to_not have_content address.address_line_1 - expect(page).to_not have_content address.address_line_2 - expect(page).to_not have_content address.city - expect(page).to_not have_content address.state_or_province - expect(page).to_not have_content address.postal_code + expect(page).to_not have_content postal_address.line1 + expect(page).to_not have_content postal_address.line2 + expect(page).to_not have_content postal_address.city + expect(page).to_not have_content postal_address.state + expect(page).to_not have_content postal_address.zip end end end diff --git a/spec/models/postal_address_spec.rb b/spec/models/postal_address_spec.rb index 43005354c..efbc4b7a6 100644 --- a/spec/models/postal_address_spec.rb +++ b/spec/models/postal_address_spec.rb @@ -6,7 +6,7 @@ end describe 'validations' do - it { is_expected.to validate_presence_of(:address_line_1)} + it { is_expected.to validate_presence_of(:line1)} it { is_expected.to validate_presence_of(:city)} it { is_expected.to validate_presence_of(:postal_code)} it { is_expected.to validate_presence_of(:country)} From b06aa4c2c10f8206379977612a57cb7ee1e3310d Mon Sep 17 00:00:00 2001 From: Margaret Williford Date: Tue, 13 Nov 2018 15:10:03 -0700 Subject: [PATCH 14/19] move postal address formatting to partial --- app/models/postal_address.rb | 4 ---- app/views/postal_addresses/_postal_address.html.slim | 3 +++ app/views/users/show.html.slim | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 app/views/postal_addresses/_postal_address.html.slim diff --git a/app/models/postal_address.rb b/app/models/postal_address.rb index 3013b5586..58fa06d43 100644 --- a/app/models/postal_address.rb +++ b/app/models/postal_address.rb @@ -3,8 +3,4 @@ class PostalAddress < ApplicationRecord belongs_to :user validates_presence_of :line1, :city, :zip, :country - - def formatted - "#{line1.titlecase} #{line2.titlecase} #{city.titlecase}, #{state} #{zip} #{country}" - end end diff --git a/app/views/postal_addresses/_postal_address.html.slim b/app/views/postal_addresses/_postal_address.html.slim new file mode 100644 index 000000000..ab5f0ef82 --- /dev/null +++ b/app/views/postal_addresses/_postal_address.html.slim @@ -0,0 +1,3 @@ += @user.postal_address.line1.titlecase + " " + @user.postal_address.line2.titlecase + " " += @user.postal_address.city.titlecase + ", " + @user.postal_address.state.titlecase + " " += @user.postal_address.zip + " " +@user.postal_address.country diff --git a/app/views/users/show.html.slim b/app/views/users/show.html.slim index 0e9053b77..25ca61d94 100644 --- a/app/views/users/show.html.slim +++ b/app/views/users/show.html.slim @@ -70,7 +70,7 @@ nav.actions - if @user.postal_address h4 Postal Address p - = @user.postal_address.formatted + = render @user.postal_address - fields = ['tshirt_size', 'tshirt_cut'] - fields.each do |field| - if @user.send(field).present? From 70ecfbcdfa50ac106ec57292e3be4ab1f98141a8 Mon Sep 17 00:00:00 2001 From: Margaret Williford Date: Tue, 13 Nov 2018 15:15:40 -0700 Subject: [PATCH 15/19] fixing model spec for postal address --- spec/models/postal_address_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/postal_address_spec.rb b/spec/models/postal_address_spec.rb index efbc4b7a6..36a11336c 100644 --- a/spec/models/postal_address_spec.rb +++ b/spec/models/postal_address_spec.rb @@ -8,7 +8,7 @@ describe 'validations' do it { is_expected.to validate_presence_of(:line1)} it { is_expected.to validate_presence_of(:city)} - it { is_expected.to validate_presence_of(:postal_code)} + it { is_expected.to validate_presence_of(:zip)} it { is_expected.to validate_presence_of(:country)} end end From f92b1c2d8f65a607a8b5833e9170bd3d9952aa61 Mon Sep 17 00:00:00 2001 From: Margaret Williford Date: Tue, 13 Nov 2018 16:22:56 -0700 Subject: [PATCH 16/19] change link to checkbox to remove a postal address from user profile --- app/views/users/edit.html.slim | 6 ++++-- spec/features/users/postal_address_spec.rb | 5 ++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/views/users/edit.html.slim b/app/views/users/edit.html.slim index 9b28c7d85..e712af174 100644 --- a/app/views/users/edit.html.slim +++ b/app/views/users/edit.html.slim @@ -108,9 +108,11 @@ = f.input :tshirt_size, as: :select, collection: User::TSHIRT_SIZES.map { |k| [k, k] }, label: 'T-Shirt size', blank: false, required: false, hint: 'For sponsor T-Shirts, in case they send some.' = f.input :tshirt_cut, as: :select, collection: User::TSHIRT_CUTS.map { |s| [s, s] }, label: 'T-Shirt cut', include_blank: true h4 Shipping Address - - if @user.postal_address - = link_to "Remove Address", user_path(@user, user: { postal_address_attributes: { id: @user.postal_address.id, "_destroy" => true }}), method: :put, data: { confirm: 'Are you sure?' } = f.simple_fields_for :postal_address_attributes, @user.postal_address do |pa| + - if @user.postal_address + = pa.input :id, as: :hidden, input_html: { value: @user.postal_address.id } + = pa.check_box '_destroy' + | Remove Address = pa.input :line1, required: false = pa.input :line2, required: false = pa.input :city, required: false diff --git a/spec/features/users/postal_address_spec.rb b/spec/features/users/postal_address_spec.rb index 0a47a27b3..1339e60b4 100644 --- a/spec/features/users/postal_address_spec.rb +++ b/spec/features/users/postal_address_spec.rb @@ -54,9 +54,8 @@ it 'allows to delete an existing postal address' do visit edit_user_path(user) - accept_alert do - click_on 'Remove Address' - end + check 'user[postal_address_attributes][_destroy]' + click_on 'Save' expect(current_path).to eq user_path(user) expect(page).to_not have_content postal_address.line1 From 978544ed2eb1ac753dbcb06d45b2ebf8ea318c1a Mon Sep 17 00:00:00 2001 From: Margaret Williford Date: Wed, 14 Nov 2018 09:18:43 -0700 Subject: [PATCH 17/19] skipping season spec for now --- spec/models/season_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/season_spec.rb b/spec/models/season_spec.rb index 74d4539df..bd34c1b9d 100644 --- a/spec/models/season_spec.rb +++ b/spec/models/season_spec.rb @@ -205,7 +205,7 @@ context 'on New Year\'s' do before { Timecop.travel Date.parse('2016-01-01') } - it { is_expected.not_to be_transition } + xit { is_expected.not_to be_transition } end end From 6b07d34c3d44b4c4c2b40cb76ddbf6e41c0e3eb5 Mon Sep 17 00:00:00 2001 From: Margaret Williford Date: Wed, 14 Nov 2018 09:23:58 -0700 Subject: [PATCH 18/19] unskipping test --- spec/models/season_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/season_spec.rb b/spec/models/season_spec.rb index bd34c1b9d..74d4539df 100644 --- a/spec/models/season_spec.rb +++ b/spec/models/season_spec.rb @@ -205,7 +205,7 @@ context 'on New Year\'s' do before { Timecop.travel Date.parse('2016-01-01') } - xit { is_expected.not_to be_transition } + it { is_expected.not_to be_transition } end end From 8565c6f82fdc685d68b8a32a0006992920c01503 Mon Sep 17 00:00:00 2001 From: Margaret Williford Date: Wed, 14 Nov 2018 09:39:43 -0700 Subject: [PATCH 19/19] fixing rubocop --- spec/features/users/postal_address_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/users/postal_address_spec.rb b/spec/features/users/postal_address_spec.rb index 1339e60b4..a0c268aa2 100644 --- a/spec/features/users/postal_address_spec.rb +++ b/spec/features/users/postal_address_spec.rb @@ -30,8 +30,8 @@ end it 'does not allow a postal address to be added if required fields are missing' do - fill_in 'Line1', with: address.line1 - fill_in 'Zip', with: address.zip + fill_in 'Line1', with: address.line1 + fill_in 'Zip', with: address.zip click_on 'Save' expect(page).to have_content "Postal address city can't be blank"