Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove references to social link profile fields (#13252)
* Remove references to social link profile fields * Add some dummy data * Remove special display social links * Remove unnecessary tests * Add tests for profile social icons * PR feedback * Remove nil check from erb * Move view method into helper * Don't render links in user settings
- Loading branch information
1 parent
393ba00
commit bb9780f
Showing
17 changed files
with
129 additions
and
97 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
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,16 @@ | ||
module ProfileHelper | ||
def social_authentication_links_for(user) | ||
# Returns a Hash containing URLs for social authentication providers | ||
# Currently supported: GitHub, Twitter, Facebook | ||
user_identities = user.identities_enabled | ||
return {} if user_identities.blank? | ||
|
||
urls = user_identities.pluck(:auth_data_dump).each_with_object({}) do |data, hash| | ||
if (data_urls = data.dig(:info, :urls)) | ||
hash.merge!(data_urls) | ||
end | ||
end | ||
|
||
{ github: urls["GitHub"], twitter: urls["Twitter"], facebook: urls["Facebook"] }.compact | ||
end | ||
end |
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
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,61 @@ | ||
require "rails_helper" | ||
|
||
describe ProfileHelper do | ||
before do | ||
allow(Settings::Authentication).to receive(:providers).and_return(Authentication::Providers.available) | ||
end | ||
|
||
describe "social_authentication_links_for" do | ||
let(:user) do | ||
create(:user) | ||
end | ||
let(:actual) { helper.social_authentication_links_for(user) } | ||
|
||
context "when a user has no social authentication providers linked" do | ||
it "does not return any links for a user without social authentication providers" do | ||
expect(actual).to eq({}) | ||
end | ||
end | ||
|
||
context "when a user has one social authentication provider linked" do | ||
let(:user) do | ||
omniauth_mock_github_payload | ||
create(:user, :with_identity, identities: ["github"]) | ||
end | ||
|
||
it "returns a link to the social authentication provider's link" do | ||
expect(actual).to eq({ github: "https://example.com" }) | ||
end | ||
end | ||
|
||
context "when a user has multiple social authentication providers linked" do | ||
let(:user) do | ||
omniauth_mock_github_payload | ||
omniauth_mock_twitter_payload | ||
omniauth_mock_facebook_payload | ||
omniauth_mock_apple_payload | ||
create(:user, :with_identity, identities: %w[github twitter facebook apple]) | ||
end | ||
|
||
it "returns all supported links" do | ||
expected = { github: "https://example.com", twitter: "https://example.com", facebook: "https://example.com" } | ||
expect(actual).to eq(expected) | ||
end | ||
end | ||
|
||
context "when third party authentication providers are not enabled" do | ||
let(:user) do | ||
omniauth_mock_github_payload | ||
create(:user, :with_identity, identities: ["github"]) | ||
end | ||
|
||
before do | ||
allow(Settings::Authentication).to receive(:providers).and_return([]) | ||
end | ||
|
||
it "returns a link to the social authentication provider's link" do | ||
expect(actual).to eq({}) | ||
end | ||
end | ||
end | ||
end |
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
14 changes: 0 additions & 14 deletions
14
spec/lib/data_update_scripts/fix_profile_field_edge_cases_spec.rb
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
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