Skip to content

Commit 6510cd4

Browse files
authored
Merge branch 'main' into codex/add-hreflang-links-generation-and-rendering
Signed-off-by: Robert Smith <[email protected]>
2 parents bb56f41 + a55f451 commit 6510cd4

File tree

18 files changed

+89
-8
lines changed

18 files changed

+89
-8
lines changed

.github/workflows/rubyonrails.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,22 @@ jobs:
8989
bundle exec rspec
9090
continue-on-error: ${{ matrix.allowed_failure }}
9191

92+
- name: Generate coverage badge
93+
if: ${{ github.ref == 'refs/heads/main' && success() }}
94+
continue-on-error: true
95+
run: |
96+
COVERAGE=$(jq -r '.result.covered_percent' coverage/.last_run.json)
97+
COLOR=$(node -e "cov=parseFloat(process.argv[1]);console.log(cov>=90?'green':cov>=75?'orange':'red')" $COVERAGE)
98+
npx badgen-cli --subject coverage --status ${COVERAGE}% --color $COLOR > coverage.svg
99+
100+
- name: Commit badge
101+
if: ${{ github.ref == 'refs/heads/main' && success() }}
102+
continue-on-error: true
103+
uses: stefanzweifel/git-auto-commit-action@v5
104+
with:
105+
commit_message: "chore: update coverage badge"
106+
file_pattern: coverage.svg
107+
92108
# ── style & security jobs (unchanged) ───────────────────────────────────────
93109
rubocop:
94110
runs-on: ubuntu-latest

Gemfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ GEM
678678
rubocop-factory_bot (2.27.1)
679679
lint_roller (~> 1.1)
680680
rubocop (~> 1.72, >= 1.72.1)
681-
rubocop-rails (2.33.0)
681+
rubocop-rails (2.33.1)
682682
activesupport (>= 4.2.0)
683683
lint_roller (~> 1.1)
684684
rack (>= 1.1)
@@ -699,7 +699,7 @@ GEM
699699
ruby-vips (2.2.3)
700700
ffi (~> 1.12)
701701
logger
702-
rubyzip (2.4.1)
702+
rubyzip (3.0.1)
703703
sass-embedded (1.86.3-aarch64-linux-gnu)
704704
google-protobuf (~> 4.30)
705705
sass-embedded (1.86.3-arm64-darwin)
@@ -711,11 +711,11 @@ GEM
711711
sassc-embedded (1.80.4)
712712
sass-embedded (~> 1.80)
713713
securerandom (0.4.1)
714-
selenium-webdriver (4.34.0)
714+
selenium-webdriver (4.35.0)
715715
base64 (~> 0.2)
716716
logger (~> 1.4)
717717
rexml (~> 3.2, >= 3.2.5)
718-
rubyzip (>= 1.2.2, < 3.0)
718+
rubyzip (>= 1.2.2, < 4.0)
719719
websocket (~> 1.0)
720720
sentry-rails (5.26.0)
721721
railties (>= 5.0)

app/controllers/better_together/application_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ def valid_platform_invitation_token_present?
129129

130130
private
131131

132+
def disallow_robots
133+
view_context.content_for(:meta_robots, 'noindex,nofollow')
134+
end
135+
132136
def render_not_found
133137
render 'errors/404', status: :not_found
134138
end

app/controllers/better_together/content/blocks_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module Content
55
# CRUD for content blocks independently of pages
66
class BlocksController < ResourceController
77
before_action :authenticate_user!
8+
before_action :disallow_robots
89
before_action :set_block, only: %i[show edit update destroy]
910
before_action only: %i[index], if: -> { Rails.env.development? } do
1011
# Make sure that all BLock subclasses are loaded in dev to generate new block buttons

app/controllers/better_together/content/page_blocks_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module Content
55
# CRUD for page blocks
66
class PageBlocksController < ApplicationController
77
before_action :authenticate_user!
8+
before_action :disallow_robots
89
before_action :set_page
910

1011
def new

app/controllers/better_together/conversations_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module BetterTogether
44
# Handles managing conversations
55
class ConversationsController < ApplicationController
66
before_action :authenticate_user!
7+
before_action :disallow_robots
78
before_action :set_conversations, only: %i[index new show]
89
before_action :set_conversation, only: %i[show]
910

app/controllers/better_together/messages_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module BetterTogether
44
# handles managing messages
55
class MessagesController < ApplicationController
66
before_action :authenticate_user!
7+
before_action :disallow_robots
78
before_action :set_conversation
89

910
def create

app/controllers/better_together/notifications_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module BetterTogether
44
# handles rendering and marking notifications as read
55
class NotificationsController < ApplicationController
66
before_action :authenticate_user!
7+
before_action :disallow_robots
78

89
def index
910
@notifications = helpers.current_person.notifications.includes(:event).order(created_at: :desc)

app/helpers/better_together/application_helper.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ def seo_meta_tags # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
102102
end
103103
# rubocop:enable Metrics/MethodLength
104104

105+
def robots_meta_tag(content = 'index,follow')
106+
meta_content = content_for?(:meta_robots) ? content_for(:meta_robots) : content
107+
tag.meta(name: 'robots', content: meta_content)
108+
end
109+
105110
# Builds Open Graph meta tags for the current view using content blocks when
106111
# provided. Falls back to localized defaults and the host community logo.
107112
# rubocop:todo Metrics/PerceivedComplexity

app/models/better_together/event.rb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,23 @@ class Event < ApplicationRecord
2727
translates :description, backend: :action_text
2828

2929
validates :name, presence: true
30+
validates :starts_at, presence: true
3031
validates :registration_url, format: { with: URI::DEFAULT_PARSER.make_regexp(%w[http https]) }, allow_blank: true,
3132
allow_nil: true
33+
validate :ends_at_after_starts_at
3234

3335
scope :draft, lambda {
3436
start_query = arel_table[:starts_at].eq(nil)
3537
where(start_query)
3638
}
3739

3840
scope :upcoming, lambda {
39-
start_query = arel_table[:starts_at].gteq(DateTime.now)
41+
start_query = arel_table[:starts_at].gteq(Time.current)
4042
where(start_query)
4143
}
4244

4345
scope :past, lambda {
44-
start_query = arel_table[:starts_at].lt(DateTime.now)
46+
start_query = arel_table[:starts_at].lt(Time.current)
4547
where(start_query)
4648
}
4749

@@ -74,5 +76,14 @@ def to_s
7476
end
7577

7678
configure_attachment_cleanup
79+
80+
private
81+
82+
def ends_at_after_starts_at
83+
return if ends_at.blank? || starts_at.blank?
84+
return if ends_at > starts_at
85+
86+
errors.add(:ends_at, I18n.t('errors.models.ends_at_before_starts_at'))
87+
end
7788
end
7889
end

0 commit comments

Comments
 (0)