saucy 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/Gemfile +15 -1
  2. data/Gemfile.lock +67 -1
  3. data/Rakefile +26 -0
  4. data/app/controllers/memberships_controller.rb +33 -1
  5. data/app/models/invitation.rb +1 -1
  6. data/app/models/membership.rb +22 -0
  7. data/app/models/permission.rb +17 -0
  8. data/app/models/signup.rb +3 -3
  9. data/app/views/memberships/edit.html.erb +18 -0
  10. data/app/views/memberships/index.html.erb +4 -4
  11. data/config/routes.rb +2 -3
  12. data/features/run_features.feature +4 -3
  13. data/features/step_definitions/rails_steps.rb +3 -0
  14. data/lib/generators/saucy/features/templates/factories.rb +4 -4
  15. data/lib/generators/saucy/features/templates/step_definitions/session_steps.rb +6 -3
  16. data/lib/generators/saucy/features/templates/step_definitions/user_steps.rb +6 -4
  17. data/lib/generators/saucy/install/templates/create_saucy_tables.rb +8 -6
  18. data/lib/saucy/account.rb +9 -5
  19. data/lib/saucy/project.rb +28 -5
  20. data/lib/saucy/user.rb +5 -12
  21. data/spec/controllers/memberships_controller_spec.rb +87 -5
  22. data/spec/environment.rb +91 -0
  23. data/spec/models/account_spec.rb +17 -6
  24. data/spec/models/membership_spec.rb +37 -0
  25. data/spec/models/permission_spec.rb +19 -0
  26. data/spec/models/project_spec.rb +39 -9
  27. data/spec/models/user_spec.rb +16 -42
  28. data/spec/scaffold/config/routes.rb +5 -0
  29. data/spec/spec_helper.rb +8 -1
  30. data/spec/support/authentication_helpers.rb +16 -6
  31. metadata +75 -74
  32. data/app/controllers/permissions_controller.rb +0 -17
  33. data/app/models/account_membership.rb +0 -8
  34. data/app/models/project_membership.rb +0 -14
  35. data/app/views/permissions/edit.html.erb +0 -15
  36. data/spec/controllers/permissions_controller_spec.rb +0 -69
  37. data/spec/models/account_membership_spec.rb +0 -13
  38. data/spec/models/project_membership_spec.rb +0 -22
@@ -1,15 +0,0 @@
1
- <h2>Permissions for <span><%= @user.name %></span> on <%= current_account.name %></h2>
2
-
3
- <%= render :partial => 'accounts/tab_bar' %>
4
-
5
- <%= semantic_form_for @user,
6
- :as => :permissions,
7
- :url => account_user_permissions_path(current_account, @user) do |form| -%>
8
- <%= form.inputs do -%>
9
- <%= form.input :projects, :as => :check_boxes, :collection => @projects %>
10
- <% end -%>
11
- <%= form.buttons do -%>
12
- <%= form.commit_button "Update" %>
13
- <% end -%>
14
- <% end -%>
15
-
@@ -1,69 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe PermissionsController, "routes" do
4
- it { should route(:get, "/accounts/abc/users/def/permissions/edit").
5
- to(:action => :edit, :account_id => 'abc', :user_id => 'def') }
6
- it { should route(:put, "/accounts/abc/users/def/permissions").
7
- to(:action => :update, :account_id => 'abc', :user_id => 'def') }
8
- end
9
-
10
- describe PermissionsController, "permissions", :as => :account_member do
11
- let(:user) { Factory.stub(:user) }
12
- it { should deny_access.
13
- on(:get, :edit, :account_id => account.to_param,
14
- :user_id => user.to_param).
15
- flash(/admin/) }
16
- end
17
-
18
- describe PermissionsController, "edit", :as => :account_admin do
19
- let(:edited_user) { Factory.stub(:user) }
20
- let(:projects) { [Factory.stub(:project)] }
21
-
22
- before do
23
- Account.stubs(:find_by_url! => account)
24
- User.stubs(:find => edited_user)
25
- account.stubs(:projects_by_name => projects)
26
- get :edit, :account_id => account.to_param, :user_id => edited_user.to_param
27
- end
28
-
29
- it "renders the edit template" do
30
- should respond_with(:success)
31
- should render_template(:edit)
32
- end
33
-
34
- it "assigns projects by name" do
35
- account.should have_received(:projects_by_name)
36
- should assign_to(:projects).with(projects)
37
- end
38
-
39
- it "assigns the user being edited" do
40
- should assign_to(:user).with(edited_user)
41
- end
42
- end
43
-
44
- describe PermissionsController, "update", :as => :account_admin do
45
- let(:edited_user) { Factory.stub(:user) }
46
- let(:project_ids) { [1, 2, 3] }
47
-
48
- before do
49
- Account.stubs(:find_by_url! => account)
50
- User.stubs(:find => edited_user)
51
- edited_user.stubs(:update_permissions_for)
52
- put :update, :account_id => account.to_param,
53
- :user_id => edited_user.to_param,
54
- :permissions => { :project_ids => project_ids }
55
- end
56
-
57
- it "redirects to the memberships index" do
58
- should redirect_to(account_memberships_url(account))
59
- end
60
-
61
- it "update permissions" do
62
- edited_user.should have_received(:update_permissions_for).with(account, project_ids)
63
- end
64
-
65
- it "sets a flash message" do
66
- should set_the_flash.to(/update/i)
67
- end
68
- end
69
-
@@ -1,13 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe AccountMembership do
4
- it { should belong_to(:account) }
5
- it { should belong_to(:user) }
6
- it { should validate_presence_of(:account_id) }
7
- it { should validate_presence_of(:user_id) }
8
-
9
- describe "given an existing account membership" do
10
- before { Factory(:account_membership) }
11
- it { should validate_uniqueness_of(:user_id).scoped_to(:account_id) }
12
- end
13
- end
@@ -1,22 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ProjectMembership do
4
- it { should belong_to(:project) }
5
- it { should belong_to(:user) }
6
- end
7
-
8
- describe ProjectMembership, "for a user that isn't an account member" do
9
- let!(:account) { Factory(:account) }
10
- let!(:other_account) { Factory(:account) }
11
- let!(:project) { Factory(:project, :account => account) }
12
- let!(:user) { Factory(:user) }
13
- subject { Factory.build(:project_membership, :project => project,
14
- :user => user) }
15
-
16
- before { Factory(:account_membership, :user => user, :account => other_account) }
17
-
18
- it "isn't valid" do
19
- should_not be_valid
20
- subject.errors[:base].first.should =~ /account/i
21
- end
22
- end