-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Move RetrieveSlackUserInfo to minitest * Add method to HistoricalMatch for getting profiled members * Add historical match filter
- Loading branch information
Showing
16 changed files
with
144 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,5 @@ | |
!/app/assets/builds/.keep | ||
|
||
.irb_history | ||
|
||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rvices/slack/retrieves_slack_user_info.rb → ...ervices/slack/retrieve_slack_user_info.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<div id="historical_match_<%= historical_match.id %>" class="my-4 px-4"> | ||
<div class="flex flex-col space-y-4 border border-black"> | ||
<div class="flex flex-wrap"> | ||
<% historical_match.profiled_members.each do |member| %> | ||
<%= link_to profile_path(member.slack_user_id) do %> | ||
<div class="flex flex-row p-2"> | ||
<img class="w-8 h-8" src="<%= member.avatar_url %>" /> | ||
<span class="leading-8 px-2"><%= member.name %></span> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
<div class="flex flex-row justify-between"> | ||
<div class="text-sm text-slate-500 m-1"> | ||
<%= historical_match.grouping.titleize %> | ||
</div> | ||
<div class="text-sm text-slate-500 m-1"> | ||
<div> | ||
<span><%= historical_match.matched_on.strftime("%b %d, %Y") %></span> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<div class="w-full"> | ||
<div class="flex justify-between items-center"> | ||
<h1 class="font-bold text-4xl">Historical matches</h1> | ||
</div> | ||
|
||
<div id="historical_matches" class="min-w-full"> | ||
<% if @historical_matches.empty? %> | ||
<p class="px-4">No matches made yet</p> | ||
<% else %> | ||
<%= render partial: "historical_match", collection: @historical_matches %> | ||
<% end %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ class UseEmailToDeliverNotificationTest < ActiveSupport::TestCase | |
# Mocktail wasn't working for a class like GroupingMailer. It was returning nil | ||
# and it wasn't clear why. I decided to use Minitest::Mock instead. | ||
@mailer = Minitest::Mock.new | ||
@retrieves_slack_user_info = Mocktail.of_next(Slack::RetrievesSlackUserInfo) | ||
@retrieve_slack_user_info = Mocktail.of_next(Slack::RetrieveSlackUserInfo) | ||
@build_group_mailer_message = Mocktail.of_next(Mailer::BuildGroupMailerMessage) | ||
|
||
@group = group_with(name: "test", slack_channel_name: "test-channel") | ||
|
@@ -22,10 +22,10 @@ class UseEmailToDeliverNotificationTest < ActiveSupport::TestCase | |
pending_notifications: [notification] | ||
) | ||
|
||
stubs { @retrieves_slack_user_info.call(user: "USER_ID_1") }.with { | ||
stubs { @retrieve_slack_user_info.call(user: "USER_ID_1") }.with { | ||
slack_user_message("USER_ID_1", "Luke", "[email protected]") | ||
} | ||
stubs { @retrieves_slack_user_info.call(user: "USER_ID_2") }.with { | ||
stubs { @retrieve_slack_user_info.call(user: "USER_ID_2") }.with { | ||
slack_user_message("USER_ID_2", "Leia", "[email protected]") | ||
} | ||
stubs { |m| | ||
|
@@ -63,7 +63,7 @@ class UseEmailToDeliverNotificationTest < ActiveSupport::TestCase | |
pending_notifications: [notification] | ||
) | ||
|
||
stubs { |m| @retrieves_slack_user_info.call(user: m.any) } | ||
stubs { |m| @retrieve_slack_user_info.call(user: m.any) } | ||
.with { raise "Should not be called" } | ||
stubs { |m| | ||
@build_group_mailer_message.render( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
require "test_helper" | ||
|
||
module Slack | ||
class RetrieveSlackUserInfoTest < ActiveSupport::TestCase | ||
setup do | ||
@subject = RetrieveSlackUserInfo.new | ||
end | ||
|
||
test "loads a user's information from slack" do | ||
stub_slack_client do |slack_client| | ||
@subject.call(user: "USER_ID") | ||
|
||
verify { slack_client.users_info(user: "USER_ID") } | ||
end | ||
end | ||
|
||
test "stores some user profile information to the database" do | ||
stub_slack_client do |slack_client| | ||
stubs { slack_client.users_info(user: "USER_ID") }.with do | ||
slack_user_response("USER_ID") | ||
end | ||
|
||
assert_difference -> { SlackUserProfile.count } do | ||
@subject.call(user: "USER_ID") | ||
end | ||
|
||
user_profile = SlackUserProfile.find_by(slack_user_id: "USER_ID") | ||
assert_equal "Luke", user_profile.name | ||
end | ||
end | ||
|
||
private | ||
|
||
def slack_user_response(id) | ||
Slack::Messages::Message.new( | ||
id: id, | ||
user: Slack::Messages::Message.new( | ||
id: id, | ||
profile: Slack::Messages::Message.new( | ||
real_name: "Luke", | ||
image_512: "https://example.com/x/512/512" | ||
) | ||
) | ||
) | ||
end | ||
end | ||
end |