diff --git a/db/schema.rb b/db/schema.rb index 87449f13..5838e594 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -25,7 +25,7 @@ t.index ["resource_type", "resource_id"], name: "index_active_admin_comments_on_resource" end - create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_general_ci", comment: "Created by CoPlan engine", force: :cascade do |t| + create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", comment: "Created by CoPlan engine", force: :cascade do |t| t.bigint "blob_id", null: false t.datetime "created_at", null: false t.string "name", null: false @@ -35,7 +35,7 @@ t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true end - create_table "active_storage_blobs", charset: "utf8mb4", collation: "utf8mb4_general_ci", comment: "Created by CoPlan engine", force: :cascade do |t| + create_table "active_storage_blobs", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", comment: "Created by CoPlan engine", force: :cascade do |t| t.bigint "byte_size", null: false t.string "checksum" t.string "content_type" @@ -47,7 +47,7 @@ t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true end - create_table "active_storage_variant_records", charset: "utf8mb4", collation: "utf8mb4_general_ci", comment: "Created by CoPlan engine", force: :cascade do |t| + create_table "active_storage_variant_records", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", comment: "Created by CoPlan engine", force: :cascade do |t| t.bigint "blob_id", null: false t.string "variation_digest", null: false t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true diff --git a/engine/app/views/coplan/welcome/_default_landing.html.erb b/engine/app/views/coplan/welcome/_default_landing.html.erb index 533b3764..183e9bde 100644 --- a/engine/app/views/coplan/welcome/_default_landing.html.erb +++ b/engine/app/views/coplan/welcome/_default_landing.html.erb @@ -10,6 +10,8 @@
<% if signed_in? %> <%= link_to "Browse plans", plans_path, class: "btn btn--primary" %> + <% elsif main_app.respond_to?(:sign_in_path) %> + <%= link_to "Sign in", main_app.sign_in_path, class: "btn btn--primary" %> <% end %> <%= link_to "Read the agent API", agent_instructions_path, class: "btn btn--secondary" %>
diff --git a/engine/app/views/layouts/coplan/application.html.erb b/engine/app/views/layouts/coplan/application.html.erb index f0d3ec14..8b4b87df 100644 --- a/engine/app/views/layouts/coplan/application.html.erb +++ b/engine/app/views/layouts/coplan/application.html.erb @@ -62,6 +62,13 @@ <% end %> + <% elsif main_app.respond_to?(:sign_in_path) %> + <%# Signed-out visitors need a way in when the host exposes its own + sign-in route (hosts gating at the perimeter never render this + state — they arrive authenticated). %> + <% end %> diff --git a/spec/requests/welcome_spec.rb b/spec/requests/welcome_spec.rb index e381eb95..34922fac 100644 --- a/spec/requests/welcome_spec.rb +++ b/spec/requests/welcome_spec.rb @@ -20,6 +20,20 @@ end end + context "anonymous visitor" do + it "offers a way to sign in (host exposes sign_in_path)" do + get root_path + expect(response).to have_http_status(:ok) + expect(response.body).to include(main_app.sign_in_path) + expect(response.body).to include("Sign in") + end + + it "does not show the signed-in 'Browse plans' CTA" do + get root_path + expect(response.body).not_to include("Browse plans") + end + end + context "signed-in user with at least one plan" do before do sign_in_as(alice)