Skip to content

Commit 81e586c

Browse files
committed
Add migration for better_together_metrics_rich_text_links and update schema; include WebMock for testing
1 parent 44c6d45 commit 81e586c

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

db/migrate/20241125190948_create_better_together_metrics_rich_text_links.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# associations between ActionText content and discovered links.
55
class CreateBetterTogetherMetricsRichTextLinks < ActiveRecord::Migration[7.1]
66
def change
7+
return if table_exists? :better_together_metrics_rich_text_links
8+
79
create_bt_table :rich_text_links, prefix: :better_together_metrics do |t|
810
t.bt_references :link, foreign_key: { to_table: :better_together_content_links }
911
t.bt_references :rich_text, foreign_key: { to_table: :action_text_rich_texts }

spec/dummy/db/schema.rb

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,28 @@
348348
t.index ["privacy"], name: "by_better_together_content_blocks_privacy"
349349
end
350350

351+
create_table "better_together_content_links", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
352+
t.integer "lock_version", default: 0, null: false
353+
t.datetime "created_at", null: false
354+
t.datetime "updated_at", null: false
355+
t.string "link_type", null: false
356+
t.string "url", null: false
357+
t.string "scheme"
358+
t.string "host"
359+
t.boolean "external"
360+
t.boolean "valid_link"
361+
t.datetime "last_checked_at"
362+
t.string "latest_status_code"
363+
t.text "error_message"
364+
t.index ["external"], name: "index_better_together_content_links_on_external"
365+
t.index ["host"], name: "index_better_together_content_links_on_host"
366+
t.index ["last_checked_at"], name: "index_better_together_content_links_on_last_checked_at"
367+
t.index ["latest_status_code"], name: "index_better_together_content_links_on_latest_status_code"
368+
t.index ["link_type"], name: "index_better_together_content_links_on_link_type"
369+
t.index ["url"], name: "index_better_together_content_links_on_url"
370+
t.index ["valid_link"], name: "index_better_together_content_links_on_valid_link"
371+
end
372+
351373
create_table "better_together_content_page_blocks", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
352374
t.integer "lock_version", default: 0, null: false
353375
t.datetime "created_at", null: false
@@ -871,6 +893,20 @@
871893
t.index ["pageable_type", "pageable_id"], name: "index_better_together_metrics_page_views_on_pageable"
872894
end
873895

896+
create_table "better_together_metrics_rich_text_links", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
897+
t.integer "lock_version", default: 0, null: false
898+
t.datetime "created_at", null: false
899+
t.datetime "updated_at", null: false
900+
t.uuid "rich_text_id", null: false
901+
t.string "url", null: false
902+
t.string "link_type", null: false
903+
t.boolean "external", null: false
904+
t.boolean "valid", default: false
905+
t.string "host"
906+
t.text "error_message"
907+
t.index ["rich_text_id"], name: "index_better_together_metrics_rich_text_links_on_rich_text_id"
908+
end
909+
874910
create_table "better_together_metrics_search_queries", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
875911
t.integer "lock_version", default: 0, null: false
876912
t.datetime "created_at", null: false
@@ -1097,7 +1133,6 @@
10971133
t.boolean "protected", default: false, null: false
10981134
t.uuid "community_id", null: false
10991135
t.string "privacy", limit: 50, default: "private", null: false
1100-
t.string "slug"
11011136
t.string "url", null: false
11021137
t.string "time_zone", null: false
11031138
t.jsonb "settings", default: {}, null: false

spec/spec_helper.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
require 'simplecov'
2222
require 'coveralls'
2323
require 'rspec/rebound'
24+
require 'webmock/rspec'
25+
26+
# Disable real external HTTP connections in tests but allow localhost so
27+
# Capybara drivers (cuprite/ferrum/selenium) can communicate with the app
28+
# server started by the test suite.
29+
WebMock.disable_net_connect!(allow_localhost: true)
2430

2531
# Allow CI/local runs to override coverage output to avoid permission issues
2632
SimpleCov.coverage_dir ENV['SIMPLECOV_DIR'] if ENV['SIMPLECOV_DIR']

0 commit comments

Comments
 (0)