Skip to content

Commit

Permalink
🐞 Neighborhood: Link explicitly to the Neighborhood URL.
Browse files Browse the repository at this point in the history
- #892
- #74

I noticed that the `Convene` link in the footer was always to the
current `root_url`, which will be the `Space` when visiting the `Space`
via a `Domain`.

This shifts it to use the `APP_ROOT_URL`, and allows `Operator`s to
configure the Neighborhood name and Tagline.
  • Loading branch information
zspencer committed Jun 1, 2023
1 parent b1875e8 commit 2561c42
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
13 changes: 13 additions & 0 deletions app/components/neighborhood/link_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Neighborhood::LinkComponent < ApplicationComponent
include ViewComponent::InlineTemplate

erb_template <<~ERB
<%= link_to name, url %>: <%= tagline %>
ERB

def neighborhood
@neighborhood ||= Neighborhood.new
end

delegate :name, :url, :tagline, to: :neighborhood
end
12 changes: 12 additions & 0 deletions app/models/neighborhood.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ def operators
Person.where(operator: true)
end

def url
ENV.fetch("APP_ROOT_URL")
end

def name
ENV.fetch("NEIGHBORHOOD_NAME", "Convene")
end

def tagline
ENV.fetch("NEIGHBORHOOD_TAGLINE", "Space to Work, Play, or Simply Be")
end

def email_configuration
{
address: ENV["SMTP_ADDRESS"],
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<%- if current_room && policy(current_room).edit? %>
<%= link_to t('icons.edit'), [:edit, current_space, current_room], class: 'no-underline', aria: { label: "Configure Section"} %>
<%- end %>
<%= link_to "Convene", root_url %>: Space to Work, Play, or Simply Be
<%= render Neighborhood::LinkComponent.new %>
</div>
<div>
💾&nbsp;
Expand Down
21 changes: 21 additions & 0 deletions spec/components/neighborhood/link_component_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe Neighborhood::LinkComponent, type: :component do
subject(:output) { render_inline(component) }

let(:component) { described_class.new }

it { is_expected.to have_link("Convene", href: ENV.fetch("APP_ROOT_URL")) }
it { is_expected.to have_content("Space to Work, Play, or Simply Be") }

context "when an Operator has set custom values" do
before do
stub_const("ENV", "NEIGHBORHOOD_NAME" => "Parsley's Persimmons Cooperative", "NEIGHBORHOOD_TAGLINE" => "The Place for Persimmon People", "APP_ROOT_URL" => "https://parsleys-persimmons-coop.example.com")
end

it { is_expected.to have_link("Parsley's Persimmons Cooperative", href: "https://parsleys-persimmons-coop.example.com") }
it { is_expected.to have_content("The Place for Persimmon People") }
end
end

0 comments on commit 2561c42

Please sign in to comment.