Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add commented debates badge * Ad followers badge * Fix debates locales * Normalize locales * Improve badge display * Fix changelog * Fix rubocop issues * Fix rubocop issues * Lint erb
- Loading branch information
1 parent
b69d0e9
commit 83b96d2
Showing
18 changed files
with
434 additions
and
3 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
115 changes: 115 additions & 0 deletions
115
decidim-core/app/assets/images/decidim/gamification/badges/followers.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,5 @@ | ||
<%= | ||
image_tag badge.image, | ||
class: "badge__logo--small external-icon", | ||
title: "#{badge_name} (#{level_title}): #{description}" | ||
%> |
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,25 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
module Decidim | ||
describe CreateFollow do | ||
let!(:organization) { create(:organization) } | ||
let!(:user1) { create(:user, organization: organization) } | ||
let!(:user2) { create(:user, organization: organization) } | ||
|
||
let(:form) { double(followable: user2, invalid?: false) } | ||
|
||
it "creates a follow" do | ||
expect { described_class.new(form, user1).call }.to broadcast(:ok) | ||
expect(user2.reload.followers).to include(user1) | ||
end | ||
|
||
it "increments the user's score" do | ||
described_class.new(form, user1).call | ||
|
||
expect(Decidim::Gamification.status_for(user1, :followers).score).to eq(0) | ||
expect(Decidim::Gamification.status_for(user2, :followers).score).to eq(1) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
module Decidim | ||
describe DeleteFollow do | ||
let!(:organization) { create(:organization) } | ||
let!(:user1) { create(:user, organization: organization) } | ||
let!(:user2) { create(:user, organization: organization) } | ||
let!(:follow) { create(:follow, user: user1, followable: user2) } | ||
|
||
let(:form) { double(follow: follow, invalid?: false) } | ||
|
||
it "destroys a follow" do | ||
expect { described_class.new(form, user1).call }.to broadcast(:ok) | ||
|
||
expect(user2.reload.followers).not_to include(user1) | ||
end | ||
|
||
describe "gamification" do | ||
before do | ||
Decidim::Gamification.set_score(user1, :followers, 10) | ||
Decidim::Gamification.set_score(user2, :followers, 10) | ||
end | ||
|
||
it "decrements the user's score" do | ||
described_class.new(form, user1).call | ||
|
||
expect(Decidim::Gamification.status_for(user1, :followers).score).to eq(10) | ||
expect(Decidim::Gamification.status_for(user2, :followers).score).to eq(9) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
describe "followers badge" do | ||
let(:organization) { create(:organization) } | ||
|
||
describe "reset" do | ||
it "resets the score to the amount of followers of a user" do | ||
user = create(:user, organization: organization) | ||
users = create_list(:user, 5, organization: organization) | ||
|
||
users.each do |follower| | ||
create(:follow, user: follower, followable: user) | ||
end | ||
|
||
Decidim::Gamification.reset_badges(Decidim::User.where(id: user.id)) | ||
expect(Decidim::Gamification.status_for(user, :followers).score).to eq(5) | ||
end | ||
end | ||
end |
Oops, something went wrong.