Skip to content

Commit

Permalink
Remove to_slack_attachment.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Nov 24, 2024
1 parent 930c645 commit 3d9e48b
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 144 deletions.
6 changes: 3 additions & 3 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-11-24 16:50:24 UTC using RuboCop version 1.68.0.
# on 2024-11-24 16:52:43 UTC using RuboCop version 1.68.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -114,7 +114,7 @@ RSpec/EmptyExampleGroup:
Exclude:
- 'spec/models/athlete_spec.rb'

# Offense count: 171
# Offense count: 165
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 36
Expand Down Expand Up @@ -339,7 +339,7 @@ Style/StringConcatenation:
- 'slack-strava/api/helpers/error_helpers.rb'
- 'slack-strava/models/team.rb'

# Offense count: 233
# Offense count: 232
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Expand Down
12 changes: 0 additions & 12 deletions slack-strava/models/club_activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,6 @@ def to_slack_blocks
blocks
end

def to_slack_attachment
result = {}
result[:fallback] = "#{name} by #{athlete_name} via #{club.name}, #{distance_s} #{moving_time_in_hours_s} #{pace_s}"
result[:title] = name
result[:title_link] = club.strava_url
result[:text] = "#{athlete_name}, #{club.name}"
fields = slack_fields
result[:fields] = fields if fields
result[:thumb_url] = club.logo
result
end

def validate_team
return if team_id && club.team_id == team_id

Expand Down
14 changes: 0 additions & 14 deletions slack-strava/models/user_activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,20 +196,6 @@ def to_slack_blocks
blocks
end

def to_slack_attachment
result = {}
result[:title] = name || strava_id
result[:title_link] = strava_url
result[:fallback] = "#{name} via #{user.slack_mention} #{distance_s} #{moving_time_in_hours_s} #{pace_s}"
result[:text] = ["<@#{user.user_name}> on #{start_date_local_s}", description].compact.join("\n\n")
result[:image_url] = map.proxy_image_url
result[:fields] = slack_fields
result[:author_name] = user.athlete&.name
result[:author_link] = user.athlete&.strava_url
result[:author_icon] = user.athlete&.profile_medium
result
end

def to_s
"id=#{strava_id}, name=#{name}, date=#{start_date_local&.iso8601}, distance=#{distance_s}, moving time=#{moving_time_in_hours_s}, pace=#{pace_s}, #{map}"
end
Expand Down
92 changes: 0 additions & 92 deletions spec/models/club_activity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,27 +181,6 @@
]
)
end

it 'to_slack_attachment' do
expect(activity.to_slack_attachment).to eq(
{
fallback: "#{activity.name} by #{activity.athlete_name} via #{club.name}, 14.01mi 2h6m26s 9m02s/mi",
title: activity.name,
title_link: club.strava_url,
text: "#{activity.athlete_name}, #{club.name}",
fields: [
{ title: 'Type', value: 'Run 🏃', short: true },
{ title: 'Distance', value: '14.01mi', short: true },
{ title: 'Moving Time', value: '2h6m26s', short: true },
{ title: 'Elapsed Time', value: '2h8m6s', short: true },
{ title: 'Pace', value: '9m02s/mi', short: true },
{ title: 'Speed', value: '6.6mph', short: true },
{ title: 'Elevation', value: '475.4ft', short: true }
],
thumb_url: club.logo
}
)
end
end

context 'km' do
Expand Down Expand Up @@ -234,27 +213,6 @@
]
)
end

it 'to_slack_attachment' do
expect(activity.to_slack_attachment).to eq(
{
fallback: "#{activity.name} by #{activity.athlete_name} via #{club.name}, 22.54km 2h6m26s 5m37s/km",
title: activity.name,
title_link: club.strava_url,
text: "#{activity.athlete_name}, #{club.name}",
fields: [
{ title: 'Type', value: 'Run 🏃', short: true },
{ title: 'Distance', value: '22.54km', short: true },
{ title: 'Moving Time', value: '2h6m26s', short: true },
{ title: 'Elapsed Time', value: '2h8m6s', short: true },
{ title: 'Pace', value: '5m37s/km', short: true },
{ title: 'Speed', value: '10.7km/h', short: true },
{ title: 'Elevation', value: '144.9m', short: true }
],
thumb_url: club.logo
}
)
end
end

context 'both' do
Expand Down Expand Up @@ -287,27 +245,6 @@
]
)
end

it 'to_slack_attachment' do
expect(activity.to_slack_attachment).to eq(
{
fallback: "#{activity.name} by #{activity.athlete_name} via #{club.name}, 14.01mi 22.54km 2h6m26s 9m02s/mi 5m37s/km",
title: activity.name,
title_link: club.strava_url,
text: "#{activity.athlete_name}, #{club.name}",
fields: [
{ title: 'Type', value: 'Run 🏃', short: true },
{ title: 'Distance', value: '14.01mi 22.54km', short: true },
{ title: 'Moving Time', value: '2h6m26s', short: true },
{ title: 'Elapsed Time', value: '2h8m6s', short: true },
{ title: 'Pace', value: '9m02s/mi 5m37s/km', short: true },
{ title: 'Speed', value: '6.6mph 10.7km/h', short: true },
{ title: 'Elevation', value: '475.4ft 144.9m', short: true }
],
thumb_url: club.logo
}
)
end
end

context 'fields' do
Expand All @@ -326,18 +263,6 @@
]
)
end

it 'to_slack_attachment' do
expect(activity.to_slack_attachment).to eq(
{
fallback: "#{activity.name} by #{activity.athlete_name} via #{club.name}, 14.01mi 2h6m26s 9m02s/mi",
title: activity.name,
title_link: club.strava_url,
text: "#{activity.athlete_name}, #{club.name}",
thumb_url: club.logo
}
)
end
end

context 'some' do
Expand All @@ -364,23 +289,6 @@
]
)
end

it 'to_slack_attachment' do
expect(activity.to_slack_attachment).to eq(
{
fallback: "#{activity.name} by #{activity.athlete_name} via #{club.name}, 14.01mi 2h6m26s 9m02s/mi",
title: activity.name,
title_link: club.strava_url,
text: "#{activity.athlete_name}, #{club.name}",
fields: [
{ title: 'Pace', value: '9m02s/mi', short: true },
{ title: 'Elevation', value: '475.4ft', short: true },
{ title: 'Type', value: 'Run 🏃', short: true }
],
thumb_url: club.logo
}
)
end
end
end
end
23 changes: 0 additions & 23 deletions spec/models/user_activity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,29 +198,6 @@
let(:user) { Fabricate(:user, team: team) }
let(:activity) { Fabricate(:user_activity, user: user) }

it 'to_slack_attachment' do
expect(activity.to_slack_attachment).to eq(
fallback: "#{activity.name} via #{activity.user.slack_mention} 14.01mi 2h6m26s 9m02s/mi",
title: activity.name,
title_link: "https://www.strava.com/activities/#{activity.strava_id}",
text: "<@#{activity.user.user_name}> on Tuesday, February 20, 2018 at 10:02 AM\n\nGreat run!",
image_url: "https://slava.playplay.io/api/maps/#{activity.map.id}.png",
fields: [
{ title: 'Type', value: 'Run 🏃', short: true },
{ title: 'Distance', value: '14.01mi', short: true },
{ title: 'Moving Time', value: '2h6m26s', short: true },
{ title: 'Elapsed Time', value: '2h8m6s', short: true },
{ title: 'Pace', value: '9m02s/mi', short: true },
{ title: 'Speed', value: '6.6mph', short: true },
{ title: 'Elevation', value: '475.4ft', short: true },
{ title: 'Weather', value: '70°F Rain', short: true }
],
author_name: user.athlete.name,
author_link: user.athlete.strava_url,
author_icon: user.athlete.profile_medium
)
end

it 'to_slack' do
expect(activity.to_slack).to eq(
attachments: [],
Expand Down

0 comments on commit 3d9e48b

Please sign in to comment.