+
+
+<%= javascript_packs_with_chunks_tag "followButtons", defer: true %>
diff --git a/config/locales/views/organizations/en.yml b/config/locales/views/organizations/en.yml
index 0fd130edb..0859a3b1f 100644
--- a/config/locales/views/organizations/en.yml
+++ b/config/locales/views/organizations/en.yml
@@ -39,5 +39,6 @@ en:
other: "%{count} members"
support: Support email
team: Meet the team
+ all_members: See All Members
twitter:
icon: Twitter logo
diff --git a/config/locales/views/organizations/fr.yml b/config/locales/views/organizations/fr.yml
index 2cbad6f30..dc471871c 100644
--- a/config/locales/views/organizations/fr.yml
+++ b/config/locales/views/organizations/fr.yml
@@ -39,5 +39,6 @@ fr:
other: "%{count} members"
support: Support email
team: Meet the team
+ all_members: See All Members
twitter:
icon: Twitter logo
diff --git a/config/routes.rb b/config/routes.rb
index 8682e08d8..dee4a665d 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -235,6 +235,7 @@ Rails.application.routes.draw do
get "/💸", to: redirect("t/hiring")
get "/survey", to: redirect("https://dev.to/ben/final-thoughts-on-the-state-of-the-web-survey-44nn")
get "/search", to: "stories/articles_search#index"
+ get "/:slug/members", to: "organizations#members", as: :organization_members
post "articles/preview", to: "articles#preview"
post "comments/preview", to: "comments#preview"
diff --git a/spec/system/organization/user_views_an_organization_spec.rb b/spec/system/organization/user_views_an_organization_spec.rb
index fa5302f06..e5fb95779 100644
--- a/spec/system/organization/user_views_an_organization_spec.rb
+++ b/spec/system/organization/user_views_an_organization_spec.rb
@@ -74,7 +74,7 @@ RSpec.describe "Organization index" do
end
end
- context "when there are multiple members in the organization" do
+ context "when there are multiple members in the organization within a limit" do
let(:many_members_org) { create(:organization) }
let(:some_badges_member) { create(:user, badge_achievements_count: 15) }
@@ -101,5 +101,53 @@ RSpec.describe "Organization index" do
expect(page.find(nth_avatar(4))).to have_link(nil, href: no_badges_member.path)
end
end
+
+ it "does not show the 'See all members' link" do
+ within("#sidebar-left") do
+ expect(page).not_to have_content("See All Members")
+ end
+ end
+ end
+
+ context "when there are more than 50 members in the organization" do
+ let(:many_members_org) { create(:organization) }
+
+ before do
+ 55.times do
+ user = create(:user, badge_achievements_count: rand(1..100))
+ create(:organization_membership, user: user, organization: many_members_org)
+ end
+ visit "/#{many_members_org.slug}"
+ end
+
+ def nth_avatar(user_position)
+ ".org-sidebar-widget-user-pic:nth-child(#{user_position})"
+ end
+
+ it "shows the sidebar till 50th user only" do
+ within("#sidebar-left") do
+ expect(page).to have_content("Meet the team")
+
+ # This checks that first 50 users are available and 51st item is not.
+ (1..50).each do |i|
+ expect(page).to have_css(nth_avatar(i))
+ end
+
+ expect(page).not_to have_css(nth_avatar(51))
+ end
+ end
+
+ it "shows the 'See All Members' link" do
+ within(".org-sidebar-widget") do
+ expect(page).to have_content("See All Members")
+ end
+ end
+
+ it "displays the members on the '/members' page" do
+ visit "/#{many_members_org.slug}/members"
+ within(".grid-cols-1") do
+ expect(page).to have_selector(".member-item", count: 55)
+ end
+ end
end
end