Skip to content

Commit 7372946

Browse files
mrcasalsoriolgual
authored andcommitted
[BACKPORT] Fix user presenter for user groups (#4974)
* Fix user presenter for user groups (#4973) * Fix user presenter for user groups The user groups do not have a `.deleted?` method defined for them which caused the user presenter to break the notifications view in case the notification was linking to a group user. * Add CHANGELOG entry * Fix changelog
1 parent c5b711d commit 7372946

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Upgrade notes
66

77
#### User follow counters
8+
89
After running the migrations, please run this code from a console:
910

1011
```ruby
@@ -62,7 +63,6 @@ end
6263
- **decidim-proposals** Don't count withdrawn proposals when publishing one [\#4875](https://github.com/decidim/decidim/pull/4875)
6364
- **decidim-core**: Fix process filters [\#4872](https://github.com/decidim/decidim/pull/4872)
6465

65-
6666
## [0.16.0](https://github.com/decidim/decidim/tree/v0.16.0)
6767

6868
**Upgrade notes**:
@@ -264,6 +264,7 @@ In order to generate Open Data exports you should add this to your crontab or re
264264
- **decidim-core**: Speed up `AddFollowingAndFollowersCountersToUsers` migration [\#4955](https://github.com/decidim/decidim/pull/4955/)
265265
- **decidim-admin**: Let admins visit the autrhorization workflows index page [\#4963](https://github.com/decidim/decidim/pull/4963/)
266266
- **decidim-admin**: Do not generate profile URL in officializations view if nickname is missing [\#4962](https://github.com/decidim/decidim/pull/4962/)
267+
- **decidim-core**: Fix user presenter for user groups breaking notifications views [\#4973](https://github.com/decidim/decidim/pull/4973/)
267268

268269
**Removed**:
269270

decidim-core/app/presenters/decidim/user_presenter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ def badge
2525
delegate :url, to: :avatar, prefix: true
2626

2727
def profile_url
28-
return "" if deleted?
28+
return "" if respond_to?(:deleted?) && deleted?
2929

3030
decidim.profile_url(__getobj__.nickname, host: __getobj__.organization.host)
3131
end
3232

3333
def profile_path
34-
return "" if deleted?
34+
return "" if respond_to?(:deleted?) && deleted?
3535

3636
decidim.profile_path(__getobj__.nickname)
3737
end

decidim-core/spec/presenters/decidim/user_presenter_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,23 @@ module Decidim
5555
have_selector(".user-mention")
5656
end
5757
end
58+
59+
context "when user is a group" do
60+
let(:user) { build(:user_group) }
61+
62+
describe "#profile_path" do
63+
subject { described_class.new(user).profile_path }
64+
65+
it { is_expected.to eq("/profiles/#{user.nickname}") }
66+
end
67+
68+
describe "#profile_url" do
69+
subject { described_class.new(user).profile_url }
70+
71+
let(:host) { user.organization.host }
72+
73+
it { is_expected.to eq("http://#{host}/profiles/#{user.nickname}") }
74+
end
75+
end
5876
end
5977
end

0 commit comments

Comments
 (0)