Skip to content

Commit

Permalink
Prepare for 0.6.8 (#2052)
Browse files Browse the repository at this point in the history
* Fix impersonation

* Version bump

* Update changelog

* Bump version

* Update version in CircleCI
  • Loading branch information
josepjaume committed Oct 17, 2017
1 parent c580b0f commit 480baeb
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
build:
docker:
- image: codegram/decidim:0.6.7
- image: codegram/decidim:0.6.8
environment:
SIMPLECOV: true
DATABASE_USERNAME: postgres
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## [v0.6.8](https://github.com/decidim/decidim/tree/v0.6.7) (2017-10-06)
[Full Changelog](https://github.com/decidim/decidim/compare/v0.6.7...v0.6.8)

**Fixed**
- **decidim-admin**: Fix impersonation being disallowed when there's another user impersonating.

## [v0.6.7](https://github.com/decidim/decidim/tree/v0.6.7) (2017-10-06)
[Full Changelog](https://github.com/decidim/decidim/compare/v0.6.6...v0.6.7)

Expand Down
88 changes: 44 additions & 44 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
PATH
remote: .
specs:
decidim (0.6.7)
decidim-admin (= 0.6.7)
decidim-api (= 0.6.7)
decidim-budgets (= 0.6.7)
decidim-comments (= 0.6.7)
decidim-core (= 0.6.7)
decidim-meetings (= 0.6.7)
decidim-pages (= 0.6.7)
decidim-participatory_processes (= 0.6.7)
decidim-proposals (= 0.6.7)
decidim-results (= 0.6.7)
decidim-surveys (= 0.6.7)
decidim-system (= 0.6.7)
decidim-admin (0.6.7)
decidim (0.6.8)
decidim-admin (= 0.6.8)
decidim-api (= 0.6.8)
decidim-budgets (= 0.6.8)
decidim-comments (= 0.6.8)
decidim-core (= 0.6.8)
decidim-meetings (= 0.6.8)
decidim-pages (= 0.6.8)
decidim-participatory_processes (= 0.6.8)
decidim-proposals (= 0.6.8)
decidim-results (= 0.6.8)
decidim-surveys (= 0.6.8)
decidim-system (= 0.6.8)
decidim-admin (0.6.8)
active_link_to (~> 1.0.0)
decidim-core (= 0.6.7)
decidim-core (= 0.6.8)
devise (~> 4.2)
devise-i18n (~> 1.1.0)
devise_invitable (~> 1.7.0)
Expand All @@ -26,29 +26,29 @@ PATH
rectify (~> 0.9.1)
sassc-rails (~> 1.3.0)
select2-rails (~> 4.0.3)
decidim-api (0.6.7)
decidim-api (0.6.8)
graphiql-rails (= 1.4.4)
graphql (~> 1.6.0)
rack-cors (~> 0.4.0)
rails (~> 5.1.3)
sprockets-es6 (~> 0.9.2)
decidim-budgets (0.6.7)
decidim-comments (= 0.6.7)
decidim-core (= 0.6.7)
decidim-budgets (0.6.8)
decidim-comments (= 0.6.8)
decidim-core (= 0.6.8)
kaminari (~> 1.0.1)
rectify (~> 0.9.1)
searchlight (~> 4.1.0)
decidim-comments (0.6.7)
decidim-core (= 0.6.7)
decidim-comments (0.6.8)
decidim-core (= 0.6.8)
jquery-rails (~> 4.0)
rails (~> 5.1.3)
decidim-core (0.6.7)
decidim-core (0.6.8)
active_link_to (~> 1.0.4)
autoprefixer-rails (~> 7.1.1)
cancancan (~> 2.0.0)
carrierwave (~> 1.1.0)
date_validator (~> 0.9.0)
decidim-api (= 0.6.7)
decidim-api (= 0.6.8)
devise (~> 4.3)
devise-i18n (~> 1.1.0)
file_validators (~> 2.1.0)
Expand Down Expand Up @@ -76,14 +76,14 @@ PATH
sprockets-es6 (~> 0.9.2)
truncato (~> 0.7.9)
wisper (~> 2.0.0)
decidim-dev (0.6.7)
decidim-dev (0.6.8)
byebug
capybara (~> 2.15.0)
capybara-screenshot (~> 1.0.14)
codecov (~> 0.1.9)
database_cleaner (~> 1.6.0)
db-query-matchers (~> 0.9.0)
decidim (= 0.6.7)
decidim (= 0.6.8)
factory_girl_rails
faker (~> 1.8.4)
i18n-tasks (= 0.9.18)
Expand All @@ -98,39 +98,39 @@ PATH
simplecov (~> 0.13)
webmock (~> 3.0.1)
wisper-rspec (~> 0.0.3)
decidim-meetings (0.6.7)
decidim-meetings (0.6.8)
date_validator (~> 0.9)
decidim-core (= 0.6.7)
decidim-core (= 0.6.8)
httparty (~> 0.15.0)
icalendar (~> 2.4.1)
jquery-tmpl-rails (~> 1.1.0)
kaminari (~> 1.0.1)
rectify (~> 0.8)
searchlight (~> 4.1.0)
decidim-pages (0.6.7)
decidim-core (= 0.6.7)
decidim-pages (0.6.8)
decidim-core (= 0.6.8)
rectify (~> 0.9.1)
decidim-participatory_processes (0.6.7)
decidim-core (= 0.6.7)
decidim-participatory_processes (0.6.8)
decidim-core (= 0.6.8)
rails (~> 5.1.3)
decidim-proposals (0.6.7)
decidim-comments (= 0.6.7)
decidim-core (= 0.6.7)
decidim-proposals (0.6.8)
decidim-comments (= 0.6.8)
decidim-core (= 0.6.8)
kaminari (~> 1.0.1)
rectify (~> 0.9.1)
social-share-button (~> 0.10.0)
decidim-results (0.6.7)
decidim-comments (= 0.6.7)
decidim-core (= 0.6.7)
decidim-results (0.6.8)
decidim-comments (= 0.6.8)
decidim-core (= 0.6.8)
kaminari (~> 1.0.1)
rectify (~> 0.9.1)
searchlight (~> 4.1.0)
decidim-surveys (0.6.7)
decidim-core (= 0.6.7)
decidim-surveys (0.6.8)
decidim-core (= 0.6.8)
jquery-tmpl-rails (~> 1.1.0)
decidim-system (0.6.7)
decidim-system (0.6.8)
active_link_to (~> 1.0.0)
decidim-core (= 0.6.7)
decidim-core (= 0.6.8)
devise (~> 4.2)
devise-i18n (~> 1.1.0)
devise_invitable (~> 1.7.1)
Expand Down Expand Up @@ -187,7 +187,7 @@ GEM
public_suffix (>= 2.0.2, < 4.0)
arel (8.0.0)
ast (2.3.0)
autoprefixer-rails (7.1.4.1)
autoprefixer-rails (7.1.5)
execjs
axiom-types (0.1.1)
descendants_tracker (~> 0.0.4)
Expand All @@ -202,7 +202,7 @@ GEM
builder (3.2.3)
byebug (9.1.0)
cancancan (2.0.0)
capybara (2.15.3)
capybara (2.15.4)
addressable
mini_mime (>= 0.1.3)
nokogiri (>= 1.3.3)
Expand Down Expand Up @@ -293,7 +293,7 @@ GEM
graphiql-rails (1.4.4)
rails
graphql (1.6.8)
hashdiff (0.3.6)
hashdiff (0.3.7)
hashie (3.5.6)
high_voltage (3.0.0)
highline (1.7.8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,22 @@ def define_abilities
super

can :manage, :managed_users

cannot [:new, :create], :managed_users if empty_available_authorizations?

can :impersonate, Decidim::User do |user_to_impersonate|
user_to_impersonate.managed? && Decidim::ImpersonationLog.active.empty?
user_to_impersonate.managed? && Decidim::ImpersonationLog.active.where(admin: user).empty?
end

can :promote, Decidim::User do |user_to_promote|
user_to_promote.managed? && Decidim::ImpersonationLog.active.empty?
user_to_promote.managed? && Decidim::ImpersonationLog.active.where(admin: user).empty?
end
end

private

def empty_available_authorizations?
@context[:current_organization] && @context[:current_organization].available_authorizations.empty?
user.organization.available_authorizations.empty?
end
end
end
Expand Down
51 changes: 49 additions & 2 deletions decidim-admin/spec/models/abilities/user_manager_ability_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,65 @@
require "spec_helper"

describe Decidim::Admin::Abilities::UserManagerAbility do
let(:user) { build(:user, :user_manager) }
let(:organization) { create(:organization, available_authorizations: ["dummy"]) }
let(:user) { create(:user, :user_manager, organization: organization) }

subject { described_class.new(user, {}) }

context "when the organization has authorizations" do
it "can create new managed users" do
expect(subject).to be_able_to(:new, :managed_users)
expect(subject).to be_able_to(:create, :managed_users)
end
end

context "when the organization doesn't have authorizations" do
let(:organization) { create(:organization, available_authorizations: []) }

it "can't create new managed users" do
expect(subject).to_not be_able_to(:new, :managed_users)
expect(subject).to_not be_able_to(:create, :managed_users)
end
end

context "when the user is not a user manager" do
let(:user) { build(:user) }
let(:user) { create(:user, organization: organization) }

it "doesn't have any permission" do
expect(subject.permissions[:can]).to be_empty
expect(subject.permissions[:cannot]).to be_empty
end
end

context "when the user doesn't have an impersonation log" do
let(:managed) { create(:user, :managed, organization: organization) }

before do
create(:impersonation_log, admin: create(:user, organization: organization))
end

it { is_expected.to be_able_to(:impersonate, managed) }
end

context "when the user doesn't have an active impersonation log" do
let(:managed) { create(:user, :managed, organization: organization) }

before do
create(:impersonation_log, admin: user, started_at: 2.days.ago, ended_at: 1.day.ago)
end

it { is_expected.to be_able_to(:impersonate, managed) }
end

context "when the user has an active impersonation log" do
let(:managed) { create(:user, :managed, organization: organization) }

before do
create(:impersonation_log, admin: user, started_at: 10.minutes.ago)
end

it { is_expected.to_not be_able_to(:impersonate, managed) }
end

it { is_expected.to be_able_to(:manage, :managed_users) }
end
2 changes: 1 addition & 1 deletion decidim-core/lib/decidim/core/test/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
factory :impersonation_log, class: Decidim::ImpersonationLog do
admin { build(:user, :admin) }
user { build(:user, :managed, organization: admin.organization) }
started_at Time.current
started_at { 10.minutes.ago }
end

factory :follow, class: "Decidim::Follow" do
Expand Down
2 changes: 1 addition & 1 deletion decidim-core/lib/decidim/core/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This holds Decidim's version and the Rails version on which it depends.
module Decidim
def self.version
"0.6.7"
"0.6.8"
end

def self.rails_version
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "decidim",
"version": "0.6.7",
"version": "0.6.8",
"repository": {
"url": "git@github.com:decidim/decidim.git",
"type": "git"
Expand Down

0 comments on commit 480baeb

Please sign in to comment.