saucy 0.2.35 → 0.2.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,12 @@
1
1
  <%= form.inputs do %>
2
2
  <%= form.input :name, :hint => project_url(Project.new(:account => current_account, :keyword => 'keyword')).html_safe %>
3
3
  <%= form.input :keyword, :wrapper_html => { :style => 'display: none' } %>
4
- <%= form.input :users, :as => :check_boxes, :collection => users %>
4
+ <%= form.input :users, :label => "Admins",
5
+ :as => :check_boxes,
6
+ :collection => admins,
7
+ :wrapper_html => { :id => "project_admins_input" },
8
+ :input_html => { :disabled => true } %>
9
+ <%= form.input :users, :as => :check_boxes, :collection => non_admins %>
5
10
  <% end %>
6
11
 
7
12
  <%= render :partial => "shared/saucy_javascript" %>
@@ -12,7 +12,9 @@
12
12
  <%= render :partial => 'accounts/tab_bar' %>
13
13
 
14
14
  <%= semantic_form_for @project do |form| %>
15
- <%= render 'form', :form => form, :users => current_account.users %>
15
+ <%= render 'form', :form => form,
16
+ :non_admins => current_account.non_admins,
17
+ :admins => current_account.admins %>
16
18
 
17
19
  <%= form.buttons do %>
18
20
  <%= form.commit_button %>
@@ -5,9 +5,11 @@
5
5
  <%= render :partial => 'accounts/tab_bar' %>
6
6
 
7
7
  <%= semantic_form_for(@project, :url => account_projects_url(current_account)) do |form| %>
8
- <%= render 'form', :form => form, :users => current_account.users %>
8
+ <%= render 'form', :form => form,
9
+ :non_admins => current_account.non_admins,
10
+ :admins => current_account.admins %>
9
11
  <%= form.buttons do -%>
10
12
  <%= form.commit_button %>
11
13
  <%= link_to 'Cancel', account_projects_path(current_account) %>
12
14
  <% end -%>
13
- <% end -%>
15
+ <% end -%>
@@ -13,14 +13,17 @@ Feature: edit permissions for a project
13
13
  | Bill | bill@example.com |
14
14
  | Jane | jane@example.com |
15
15
  | Jeff | jeff@example.com |
16
+ | Hank | hank@example.com |
16
17
  And I am signed in as an admin of the "Stocknames" project
17
18
  And "bill@example.com" is a member of the "Stocknames" project
18
19
  And "jane@example.com" is a member of the "thoughtbot" account
20
+ And "hank@example.com" is an admin of the "Stocknames" project
19
21
  When I go to the settings page for the "thoughtbot" account
20
22
  And I follow "Projects" within ".tabs"
21
23
  And I follow "Stocknames" within "ul.projects"
22
- Then the "Bill" checkbox should be checked
23
- And the "Jane" checkbox should not be checked
24
+ Then "Bill" should be listed as a member
25
+ And "Hank" should be listed as an admin
26
+ And "Jane" should be listed as a non-member
24
27
  And I should not see "Jeff"
25
28
  When I check "Jane"
26
29
  And I uncheck "Bill"
@@ -5,6 +5,15 @@ Given /^"([^"]*)" is a member of the "([^"]*)" project$/ do |email, project_name
5
5
  Factory(:permission, :membership => membership, :project => project)
6
6
  end
7
7
 
8
+ Given /^"([^"]*)" is an admin of the "([^"]*)" project$/ do |email, project_name|
9
+ user = User.find_by_email!(email)
10
+ project = Project.find_by_name!(project_name)
11
+ membership = Factory(:membership, :user => user,
12
+ :account => project.account,
13
+ :admin => true)
14
+ Factory(:permission, :membership => membership, :project => project)
15
+ end
16
+
8
17
  Given /^"([^"]*)" is a member of the "([^"]*)" account/ do |email, account_name|
9
18
  user = User.find_by_email!(email)
10
19
  account = Account.find_by_name!(account_name)
@@ -60,3 +69,27 @@ Then /^"([^"]*)" should not be a member of the "([^"]*)" project/ do |email, pro
60
69
  User.find_by_email!(email).should_not be_member_of(Project.find_by_name!(project_name))
61
70
  end
62
71
 
72
+ Then /^"([^"]+)" should be listed as an admin$/ do |name|
73
+ within("#project_admins_input") do
74
+ check_box = find_field(name)
75
+ check_box['checked'].should be_true
76
+ check_box['disabled'].should be_true
77
+ end
78
+ end
79
+
80
+ Then /^"([^"]+)" should be listed as a member/ do |name|
81
+ within("#project_users_input") do
82
+ check_box = find_field(name)
83
+ check_box['checked'].should be_true
84
+ check_box['disabled'].should be_false
85
+ end
86
+ end
87
+
88
+ Then /^"([^"]+)" should be listed as a non-member/ do |name|
89
+ within("#project_users_input") do
90
+ check_box = find_field(name)
91
+ check_box['checked'].should be_false
92
+ check_box['disabled'].should be_false
93
+ end
94
+ end
95
+
@@ -3,7 +3,7 @@ class CreateSaucyTables < ActiveRecord::Migration
3
3
  create_table :memberships do |table|
4
4
  table.integer :account_id
5
5
  table.integer :user_id
6
- table.boolean :admin
6
+ table.boolean :admin, :null => false, :default => false
7
7
  table.datetime :created_at
8
8
  table.datetime :updated_at
9
9
  end
@@ -34,7 +34,7 @@ class CreateSaucyTables < ActiveRecord::Migration
34
34
  create_table :invitations do |table|
35
35
  table.string :email
36
36
  table.integer :account_id
37
- table.boolean :admin
37
+ table.boolean :admin, :null => false, :default => false
38
38
  table.string :code
39
39
  table.boolean :used, :default => false, :null => false
40
40
  table.datetime :created_at
data/lib/saucy/account.rb CHANGED
@@ -11,6 +11,9 @@ module Saucy
11
11
  has_many :admins, :through => :memberships,
12
12
  :source => :user,
13
13
  :conditions => { 'memberships.admin' => true }
14
+ has_many :non_admins, :through => :memberships,
15
+ :source => :user,
16
+ :conditions => { 'memberships.admin' => false }
14
17
 
15
18
  belongs_to :plan
16
19
 
@@ -45,6 +45,20 @@ describe Account do
45
45
  result.to_a.should =~ admins
46
46
  end
47
47
 
48
+ it "finds non admin users" do
49
+ non_admins = [Factory(:user), Factory(:user)]
50
+ admin = Factory(:user)
51
+ non_member = Factory(:user)
52
+ non_admins.each do |non_admin|
53
+ Factory(:membership, :user => non_admin, :account => subject, :admin => false)
54
+ end
55
+ Factory(:membership, :user => admin, :account => subject, :admin => true)
56
+
57
+ result = subject.non_admins
58
+
59
+ result.to_a.should =~ non_admins
60
+ end
61
+
48
62
  it "finds emails for admin users" do
49
63
  admins = [Factory(:user), Factory(:user)]
50
64
  non_admin = Factory(:user)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saucy
3
3
  version: !ruby/object:Gem::Version
4
- hash: 81
4
+ hash: 95
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 35
10
- version: 0.2.35
9
+ - 36
10
+ version: 0.2.36
11
11
  platform: ruby
12
12
  authors:
13
13
  - thoughtbot, inc.