curupira 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of curupira might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d98c87ceff0b90c91a113a0b4f9e76b9a653dd5a
4
- data.tar.gz: ac0828d2f4c76b0ff16736c039238001c308d64f
3
+ metadata.gz: 629cf0ce02edf0ffc9eac62be232bcbed54f7761
4
+ data.tar.gz: 422e25f7a5554fde550ae3cea1708e740f1facf6
5
5
  SHA512:
6
- metadata.gz: 10d5bca583f38e6f517c988c25ac5f6874762d735e00a005511d6a49669f27c13da0b52c1fe768d0dd455c26dc9386f3085d6b1ac213c31714382191431cc2ec
7
- data.tar.gz: f0c0d4a748ddeefe1d535a26567b695cfb807df29bdec30cc4b63fbf0666a2eb8e8ddc75dd191fb5a31b7d54dc79326142a8361551f9b55eeaa3380082fc0bdc
6
+ metadata.gz: 2fd99c051f4be4ce32c9063b9dc163acbd29f7db11d383b1269ec076231ae0286dc8388e9bd3add8f90b40eb321b25d996c53f8d302b74907f0871198973cffe
7
+ data.tar.gz: a0bc4d7597fdd0af5810ad735a7d8588dffff4f524d6cfba4119b020a1d9dd6f3db11e0066ca3b9f8f554f8393c80dc2b407161d6f4125fb4b61ba7079942128
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- curupira (0.1.0)
4
+ curupira (0.1.1)
5
5
  cocoon
6
6
  jquery-rails
7
7
  rails (~> 4.2.0)
data/README.md CHANGED
@@ -63,6 +63,20 @@ If the customization at the views level is not enough, you can customize each co
63
63
  rails generate curupira:controllers
64
64
  ```
65
65
 
66
+ ## Partials
67
+
68
+ You should add in application.html.erb partials for menu, and helper for dispaly flash messages:
69
+
70
+ ```ruby
71
+ <%- flash.each do |name, msg| -%>
72
+ <%= content_tag :div, msg, id: "flash_#{name}" %>
73
+ <%- end -%>
74
+
75
+ <%= render "curupira/shared/session_links" %>
76
+ <%= render "curupira/shared/model_links" %>
77
+ <%= yield %>
78
+ ```
79
+
66
80
  * Add to your application.js
67
81
  //= require jquery
68
82
  //= require cocoon
@@ -40,7 +40,7 @@ class Curupira::UsersController < Curupira::AuthorizedController
40
40
  end
41
41
 
42
42
  private
43
-
43
+
44
44
  def user_params
45
45
  params.require(:user).permit(:email, :name, :username, :password, group_users_attributes: [:id, :group_id, :_destroy, role_group_users_attributes: [:id, :role_id]])
46
46
  end
@@ -1,6 +1,6 @@
1
1
  module Curupira::RelationshipSelectOptionsHelper
2
2
  def active_user_groups_select_options(user)
3
- [["Selecione um grupo", nil]] + Group.joins(:users).where(users: { id: user }, active: true).map { |g| [g.name, g.id] }
3
+ [["Selecione um grupo", nil]] + groups_by(user).map { |g| [g.name, g.id] }
4
4
  end
5
5
 
6
6
  def active_features_select_options
@@ -14,4 +14,14 @@ module Curupira::RelationshipSelectOptionsHelper
14
14
  def active_role_groups_select_options(group)
15
15
  [["Selecione um perfil", nil]] + Role.joins(:groups).where(groups:{id:group}).map { |r| [r.name, r.id] }
16
16
  end
17
+
18
+ private
19
+
20
+ def groups_by(user)
21
+ if user.admin
22
+ Group.all
23
+ else
24
+ Group.joins(:users).where(users: { id: user }, active: true)
25
+ end
26
+ end
17
27
  end
@@ -16,7 +16,7 @@
16
16
 
17
17
  <ul>
18
18
  <% @user.group_users.each do |group_user| %>
19
- <li><%= group_user.group.name %>
19
+ <li><%= group_user.group.name %> <%= link_to "Editar grupo", edit_user_path(@user) %>
20
20
  <% group_user.role_group_users.each do |role_group_user|%>
21
21
  <p><%= role_group_user.role.name %></p>
22
22
  <% end %>
@@ -1,3 +1,3 @@
1
1
  module Curupira
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -206,11 +206,7 @@ module Curupira
206
206
 
207
207
  def feature_model_content
208
208
  <<-CONTENT
209
- validates_presence_of :name
210
- has_many :feature_services
211
- has_many :services, through: :feature_services
212
- has_many :feature_action_labels
213
- has_many :action_labels, through: :feature_action_labels
209
+ has_many :action_labels
214
210
  CONTENT
215
211
  end
216
212
 
@@ -2,17 +2,42 @@ require "rails_helper"
2
2
 
3
3
  describe Curupira::RelationshipSelectOptionsHelper do
4
4
  describe "#active_user_groups_select_options" do
5
- let!(:active_group1) { FactoryGirl.create(:group, active: true) }
6
- let!(:active_group2) { FactoryGirl.create(:group, active: true) }
7
- let!(:inactive_group) { FactoryGirl.create(:group, active: false) }
8
- let!(:user) { FactoryGirl.create(:user, groups: [active_group1, active_group2]) }
9
5
 
10
- it "returns default with active groups" do
11
- expect(helper.active_user_groups_select_options(user)).to eql [
12
- ["Selecione um grupo", nil],
13
- [active_group1.name, active_group1.id],
14
- [active_group2.name, active_group2.id]
15
- ]
6
+ context 'when user is admin' do
7
+ let!(:user){FactoryGirl.create(:user, admin:true)}
8
+ let!(:active_group1) { FactoryGirl.create(:group, active: true) }
9
+ let!(:active_group2) { FactoryGirl.create(:group, active: true) }
10
+
11
+ it "return groups" do
12
+ expect(helper.active_user_groups_select_options(user)).to eql [
13
+ ["Selecione um grupo", nil],
14
+ [active_group1.name, active_group1.id],
15
+ [active_group2.name, active_group2.id]
16
+ ]
17
+ end
18
+ end
19
+
20
+ context 'when user is not admin' do
21
+ let!(:active_group1) { FactoryGirl.create(:group, active: true) }
22
+ let!(:active_group2) { FactoryGirl.create(:group, active: true) }
23
+ let!(:inactive_group) { FactoryGirl.create(:group, active: false) }
24
+ let!(:user) { FactoryGirl.create(:user, groups: [active_group1, active_group2]) }
25
+
26
+ it "returns default with active groups" do
27
+ expect(helper.active_user_groups_select_options(user)).to eql [
28
+ ["Selecione um grupo", nil],
29
+ [active_group1.name, active_group1.id],
30
+ [active_group2.name, active_group2.id]
31
+ ]
32
+ end
33
+ context "when doesnt belongs to any group" do
34
+ let!(:user2) { FactoryGirl.create(:user)}
35
+ it "doesnt return any groups" do
36
+ expect(helper.active_user_groups_select_options(user2)).to eql [
37
+ ["Selecione um grupo", nil]
38
+ ]
39
+ end
40
+ end
16
41
  end
17
42
  end
18
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: curupira
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paulo Moura
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-03-18 00:00:00.000000000 Z
14
+ date: 2015-03-19 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -349,15 +349,15 @@ files:
349
349
  - spec/tmp/app/models/user.rb
350
350
  - spec/tmp/config/initializers/sorcery.rb
351
351
  - spec/tmp/config/routes.rb
352
- - spec/tmp/db/migrate/20150318190312_create_role_group_users.rb
353
- - spec/tmp/db/migrate/20150318190313_create_authorizations.rb
354
- - spec/tmp/db/migrate/20150318190314_create_features.rb
355
- - spec/tmp/db/migrate/20150318190315_create_groups.rb
356
- - spec/tmp/db/migrate/20150318190316_create_roles.rb
357
- - spec/tmp/db/migrate/20150318190317_sorcery_core.rb
358
- - spec/tmp/db/migrate/20150318190318_create_group_users.rb
359
- - spec/tmp/db/migrate/20150318190319_create_role_groups.rb
360
- - spec/tmp/db/migrate/20150318190320_create_action_labels.rb
352
+ - spec/tmp/db/migrate/20150319143755_create_role_group_users.rb
353
+ - spec/tmp/db/migrate/20150319143756_create_authorizations.rb
354
+ - spec/tmp/db/migrate/20150319143757_create_features.rb
355
+ - spec/tmp/db/migrate/20150319143758_create_groups.rb
356
+ - spec/tmp/db/migrate/20150319143759_create_roles.rb
357
+ - spec/tmp/db/migrate/20150319143760_sorcery_core.rb
358
+ - spec/tmp/db/migrate/20150319143761_create_group_users.rb
359
+ - spec/tmp/db/migrate/20150319143762_create_role_groups.rb
360
+ - spec/tmp/db/migrate/20150319143763_create_action_labels.rb
361
361
  homepage: https://rubygems.org/gems/curupira
362
362
  licenses:
363
363
  - MIT
@@ -528,12 +528,12 @@ test_files:
528
528
  - spec/tmp/app/models/user.rb
529
529
  - spec/tmp/config/initializers/sorcery.rb
530
530
  - spec/tmp/config/routes.rb
531
- - spec/tmp/db/migrate/20150318190312_create_role_group_users.rb
532
- - spec/tmp/db/migrate/20150318190313_create_authorizations.rb
533
- - spec/tmp/db/migrate/20150318190314_create_features.rb
534
- - spec/tmp/db/migrate/20150318190315_create_groups.rb
535
- - spec/tmp/db/migrate/20150318190316_create_roles.rb
536
- - spec/tmp/db/migrate/20150318190317_sorcery_core.rb
537
- - spec/tmp/db/migrate/20150318190318_create_group_users.rb
538
- - spec/tmp/db/migrate/20150318190319_create_role_groups.rb
539
- - spec/tmp/db/migrate/20150318190320_create_action_labels.rb
531
+ - spec/tmp/db/migrate/20150319143755_create_role_group_users.rb
532
+ - spec/tmp/db/migrate/20150319143756_create_authorizations.rb
533
+ - spec/tmp/db/migrate/20150319143757_create_features.rb
534
+ - spec/tmp/db/migrate/20150319143758_create_groups.rb
535
+ - spec/tmp/db/migrate/20150319143759_create_roles.rb
536
+ - spec/tmp/db/migrate/20150319143760_sorcery_core.rb
537
+ - spec/tmp/db/migrate/20150319143761_create_group_users.rb
538
+ - spec/tmp/db/migrate/20150319143762_create_role_groups.rb
539
+ - spec/tmp/db/migrate/20150319143763_create_action_labels.rb