diff --git a/app/models/group.rb b/app/models/group.rb index f766f9c372c..41ca0a3e6e9 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -803,22 +803,12 @@ class Group < ActiveRecord::Base end def flair_url - return if members_visibility_level != Group.visibility_levels[:public] - return if visibility_level != Group.visibility_levels[:public] - return flair_icon if flair_type == :icon return upload_cdn_path(flair_upload.url) if flair_type == :image nil end - def flair_bg_color - return if members_visibility_level != Group.visibility_levels[:public] - return if visibility_level != Group.visibility_levels[:public] - - read_attribute(:flair_bg_color) - end - [:muted, :regular, :tracking, :watching, :watching_first_post].each do |level| define_method("#{level}_category_ids=") do |category_ids| @category_notifications ||= {} diff --git a/app/serializers/site_serializer.rb b/app/serializers/site_serializer.rb index fba550565df..c7d8d5d66c2 100644 --- a/app/serializers/site_serializer.rb +++ b/app/serializers/site_serializer.rb @@ -63,7 +63,7 @@ class SiteSerializer < ApplicationSerializer def groups cache_anon_fragment("group_names") do object.groups.order(:name) - .select(:id, :name, :flair_icon, :flair_upload_id, :flair_bg_color, :flair_color, :visibility_level, :members_visibility_level) + .select(:id, :name, :flair_icon, :flair_upload_id, :flair_bg_color, :flair_color) .map do |g| { id: g.id, @@ -71,8 +71,6 @@ class SiteSerializer < ApplicationSerializer flair_url: g.flair_url, flair_bg_color: g.flair_bg_color, flair_color: g.flair_color, - visibility_level: g.visibility_level, - members_visibility_level: g.members_visibility_level, } end.as_json end diff --git a/lib/user_lookup.rb b/lib/user_lookup.rb index 3ed0da73a32..590c6e27545 100644 --- a/lib/user_lookup.rb +++ b/lib/user_lookup.rb @@ -6,7 +6,7 @@ class UserLookup end def self.group_lookup_columns - @group_lookup_columns ||= %i{id name flair_icon flair_upload_id flair_bg_color flair_color visibility_level members_visibility_level} + @group_lookup_columns ||= %i{id name flair_icon flair_upload_id flair_bg_color flair_color} end def initialize(user_ids = []) diff --git a/spec/components/user_lookup_spec.rb b/spec/components/user_lookup_spec.rb index e96cf117335..b9fce92e67f 100644 --- a/spec/components/user_lookup_spec.rb +++ b/spec/components/user_lookup_spec.rb @@ -53,33 +53,4 @@ describe UserLookup do expect(user_lookup_group.name).to eq("testgroup") end end - - describe '#flair_groups' do - fab!(:group) { Fabricate(:group, name: "flair_group", flair_icon: "icon", flair_bg_color: "40E0D0", visibility_level: Group.visibility_levels[:public], members_visibility_level: Group.visibility_levels[:public]) } - fab!(:user2) { Fabricate(:user, flair_group: group) } - - before do - @user_lookup = UserLookup.new([user.id, user2.id, nil]) - end - - it 'returns nil if user_id does not exists' do - expect(@user_lookup.flair_groups[0]).to eq(nil) - end - - it 'returns nil if user_id is nil' do - expect(@user_lookup.flair_groups[nil]).to eq(nil) - end - - it 'returns nil if user has no flair group' do - expect(@user_lookup.flair_groups[user.id]).to eq(nil) - end - - it 'returns group if user has flair group' do - user_lookup_group = @user_lookup.flair_groups[user2.id] - expect(user_lookup_group).to eq(group) - expect(user_lookup_group.name).to eq("flair_group") - expect(user_lookup_group.flair_url).to eq("icon") - expect(user_lookup_group.flair_bg_color).to eq("40E0D0") - end - end end diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 3d9bacb095c..4a839950e74 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -1308,14 +1308,4 @@ describe Group do expect(Group.find_by_email("nope@test.com")).to eq(nil) end end - - it "fetches flair_url based on group visibility" do - public_group = Fabricate(:group, flair_icon: "icon", flair_bg_color: "40E0D0", visibility_level: Group.visibility_levels[:public], members_visibility_level: Group.visibility_levels[:public]) - private_group = Fabricate(:group, flair_icon: "icon", flair_bg_color: "40E0D0", visibility_level: Group.visibility_levels[:logged_on_users], members_visibility_level: Group.visibility_levels[:public]) - - expect(public_group.flair_url).to eq("icon") - expect(private_group.flair_url).to eq(nil) - expect(public_group.flair_bg_color).to eq("40E0D0") - expect(private_group.flair_bg_color).to eq(nil) - end end diff --git a/spec/requests/groups_controller_spec.rb b/spec/requests/groups_controller_spec.rb index d933a7d4819..22af48cd592 100644 --- a/spec/requests/groups_controller_spec.rb +++ b/spec/requests/groups_controller_spec.rb @@ -723,9 +723,9 @@ describe GroupsController do group.reload - expect(group.flair_bg_color).to eq(nil) + expect(group.flair_bg_color).to eq('FFF') expect(group.flair_color).to eq('BBB') - expect(group.flair_url).to eq(nil) + expect(group.flair_url).to eq('fa-adjust') expect(group.bio_raw).to eq('testing') expect(group.full_name).to eq('awesome team') expect(group.public_admission).to eq(true) @@ -834,10 +834,10 @@ describe GroupsController do expect(response.status).to eq(200) group.reload - expect(group.flair_bg_color).to eq(nil) + expect(group.flair_bg_color).to eq('FFF') expect(group.flair_color).to eq('BBB') expect(group.flair_icon).to eq('fa-adjust') - expect(group.flair_url).to eq(nil) + expect(group.flair_url).to eq('fa-adjust') expect(group.name).to eq('admins') expect(group.visibility_level).to eq(1) expect(group.mentionable_level).to eq(1) @@ -1006,10 +1006,10 @@ describe GroupsController do expect(response.status).to eq(200) group.reload - expect(group.flair_bg_color).to eq(nil) + expect(group.flair_bg_color).to eq('FFF') expect(group.flair_color).to eq('BBB') expect(group.flair_icon).to eq('fa-adjust') - expect(group.flair_url).to eq(nil) + expect(group.flair_url).to eq('fa-adjust') expect(group.name).to eq('trust_level_4') expect(group.mentionable_level).to eq(1) expect(group.messageable_level).to eq(1)