Skip to content

Commit

Permalink
fix broken github login
Browse files Browse the repository at this point in the history
  • Loading branch information
evsasse committed Jan 7, 2025
1 parent fd3b0c8 commit bbc2f97
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions app/controllers/api/reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ def simplecov
report.generate_bundled_html if report.parts_complete?
general_coverage = report.results["general_coverage"]

coverage_diff = general_coverage - report.project.last_main_branch_general_coverage
coverage_diff = (general_coverage - report.project.last_main_branch_general_coverage).round(2)
markdown_diff = if coverage_diff.zero?
"(Same as the main branch)"
elsif coverage_diff.positive?
"(+#{coverage_diff}% coverage improved)"
else
"(-#{coverage_diff}% coverage decreased 😢)"
"(#{coverage_diff}% coverage decreased 😢)"
end

markdown = <<~MARKDOWN
Expand Down
2 changes: 2 additions & 0 deletions app/services/users/omniauth_upserter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def call
end

enroll_from_organization_queues

@user
end

private
Expand Down
27 changes: 13 additions & 14 deletions test/services/users/omniauth_upserter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ def setup

def test_creates_new_user_if_not_existing
assert_difference "User.count", 1 do
::Users::OmniauthUpserter.new(@auth).call
@returned_user = ::Users::OmniauthUpserter.new(@auth).call
end

user = User.find_by(uid: @auth.uid)
assert_equal "github", user.provider
assert_equal "12345", user.uid
assert_equal "testuser", user.handle
assert_equal "[email protected]", user.email
assert_equal "github", @returned_user.provider
assert_equal "12345", @returned_user.uid
assert_equal "testuser", @returned_user.handle
assert_equal "[email protected]", @returned_user.email
end

def test_finds_existing_user_if_already_exists
Expand All @@ -42,26 +41,26 @@ def test_finds_existing_user_if_already_exists
)

assert_no_difference "User.count" do
::Users::OmniauthUpserter.new(@auth).call
@returned_user = ::Users::OmniauthUpserter.new(@auth).call
end

user = User.find_by(uid: @auth.uid)
assert_equal existing_user.id, user.id
assert_equal existing_user.id, @returned_user.id
end

def test_enrolls_user_from_organization_queues
::Users::OmniauthUpserter.new(@auth).call
user = User.find_by(uid: @auth.uid)
@returned_user = ::Users::OmniauthUpserter.new(@auth).call

assert @organization.reload.user_queue.exclude?(user.handle)
assert OrganizationUser.exists?(organization: @organization, user: user)
assert @organization.reload.user_queue.exclude?(@returned_user.handle)
assert OrganizationUser.exists?(organization: @organization, user: @returned_user)
end

def test_does_not_fail_when_handle_not_in_queue
@organization.update!(user_queue: [])

assert_nothing_raised do
::Users::OmniauthUpserter.new(@auth).call
@returned_user = ::Users::OmniauthUpserter.new(@auth).call
end

assert existing_user.is_a?(User)
end
end

0 comments on commit bbc2f97

Please sign in to comment.