<%= f.hidden_field :tab, value: @tab %>
diff --git a/db/migrate/20181016181008_add_medium_url_to_users.rb b/db/migrate/20181016181008_add_medium_url_to_users.rb
new file mode 100644
index 000000000..e53b534f9
--- /dev/null
+++ b/db/migrate/20181016181008_add_medium_url_to_users.rb
@@ -0,0 +1,5 @@
+class AddMediumUrlToUsers < ActiveRecord::Migration[5.1]
+ def change
+ add_column :users, :medium_url, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 6e1f85117..51495dcd2 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
@@ -10,7 +12,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20181008174839) do
+ActiveRecord::Schema.define(version: 20181016181008) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -693,6 +695,7 @@ ActiveRecord::Schema.define(version: 20181008174839) do
t.string "location"
t.boolean "looking_for_work", default: false
t.boolean "looking_for_work_publicly", default: false
+ t.string "medium_url"
t.datetime "membership_started_at"
t.text "mentee_description"
t.datetime "mentee_form_updated_at"
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index fb0ca2153..5758376f6 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -142,6 +142,18 @@ RSpec.describe User, type: :model do
expect(user).not_to be_valid
end
+ it "accepts valid https medium url" do
+ %w(jess jess/ je-ss je_ss).each do |username|
+ user.medium_url = "https://medium.com/#{username}"
+ expect(user).to be_valid
+ end
+ end
+
+ it "does not accept invalid medium url" do
+ user.medium_url = "ben.com"
+ expect(user).not_to be_valid
+ end
+
it "changes old_username if old_old_username properly if username changes" do
old_username = user.username
random_new_username = "username_#{rand(100000000)}"