saucy 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/app/views/projects/_form.html.erb +3 -0
- data/app/views/projects/edit.html.erb +0 -9
- data/config/routes.rb +1 -3
- data/lib/generators/saucy/features/templates/features/manage_projects.feature +6 -3
- data/lib/saucy/project.rb +8 -0
- data/spec/models/project_spec.rb +14 -0
- metadata +4 -6
- data/app/controllers/archives_controller.rb +0 -27
- data/spec/controllers/archives_controller_spec.rb +0 -41
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,9 @@
|
|
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
|
+
<% if form.object.persisted? -%>
|
5
|
+
<%= form.input :archived, :hint => t('project.archived.hint', :default => "Archived project don't count against your project total. You cannot create or edit stories or discussions.") %>
|
6
|
+
<% end -%>
|
4
7
|
<%= form.input :users, :label => "Admins",
|
5
8
|
:as => :check_boxes,
|
6
9
|
:collection => admins,
|
@@ -3,15 +3,6 @@
|
|
3
3
|
<% end -%>
|
4
4
|
|
5
5
|
<div class="actions">
|
6
|
-
<% if !@project.archived? -%>
|
7
|
-
<%= link_to account_project_archive_path(@project.account, @project), :method => 'post', :confirm => 'Are you sure you want to archive this project?', :class => 'action' do %>
|
8
|
-
<span class="archive_item">Archive this project</span>
|
9
|
-
<% end -%>
|
10
|
-
<% else -%>
|
11
|
-
<%= link_to account_project_archive_path(@project.account, @project), :method => 'delete', :class => 'action' do %>
|
12
|
-
<span class="unarchive_item">Unarchive this project</span>
|
13
|
-
<% end -%>
|
14
|
-
<% end -%>
|
15
6
|
<%= link_to project_path(@project), :method => 'delete', :confirm => 'Are you sure you want to delete this project and all associated content?', :class => 'action' do %>
|
16
7
|
<span class="delete_item">Remove this project</span>
|
17
8
|
<% end -%>
|
data/config/routes.rb
CHANGED
@@ -6,9 +6,7 @@ Rails.application.routes.draw do
|
|
6
6
|
through :accounts do
|
7
7
|
resource :billing
|
8
8
|
resource :plan
|
9
|
-
resources :projects
|
10
|
-
resource :archive, :only => [:create, :destroy]
|
11
|
-
end
|
9
|
+
resources :projects
|
12
10
|
resources :memberships, :only => [:index, :edit, :update, :destroy]
|
13
11
|
resources :invitations, :only => [:show, :update, :new, :create]
|
14
12
|
end
|
@@ -40,7 +40,8 @@ Feature: Manage Projects
|
|
40
40
|
| name: Test | Project 1 |
|
41
41
|
When I go to the projects page for the "Test" account
|
42
42
|
And I follow "Project 1" within "ul.projects"
|
43
|
-
And I
|
43
|
+
And I check "Archived"
|
44
|
+
And I press "Update"
|
44
45
|
And I should see "Project 1" within "ul.projects.archived"
|
45
46
|
|
46
47
|
Scenario: Unarchive a project
|
@@ -49,7 +50,8 @@ Feature: Manage Projects
|
|
49
50
|
| name: Test | Project 1 | true |
|
50
51
|
When I go to the projects page for the "Test" account
|
51
52
|
And I follow "Project 1" within "ul.projects.archived"
|
52
|
-
And I
|
53
|
+
And I uncheck "Archived"
|
54
|
+
And I press "Update"
|
53
55
|
And I should see "Project 1" within "ul.projects.active"
|
54
56
|
|
55
57
|
Scenario: Unarchive a project when at the account limit
|
@@ -62,7 +64,8 @@ Feature: Manage Projects
|
|
62
64
|
| name: Test | Project 2 | true |
|
63
65
|
When I go to the projects page for the "Test" account
|
64
66
|
And I follow "Project 2"
|
65
|
-
And I
|
67
|
+
And I uncheck "Archived"
|
68
|
+
And I press "Update"
|
66
69
|
Then I should see "at your limit"
|
67
70
|
When I go to the projects page for the "Test" account
|
68
71
|
And I should see "Project 1" within "ul.projects.active"
|
data/lib/saucy/project.rb
CHANGED
@@ -16,6 +16,8 @@ module Saucy
|
|
16
16
|
:message => "must be only lower case letters or underscores."
|
17
17
|
|
18
18
|
|
19
|
+
validate :ensure_account_within_limit, :on => :update
|
20
|
+
|
19
21
|
after_create :setup_memberships
|
20
22
|
after_update :update_memberships
|
21
23
|
|
@@ -106,6 +108,12 @@ module Saucy
|
|
106
108
|
select(:user_id).
|
107
109
|
map(&:user_id)
|
108
110
|
end
|
111
|
+
|
112
|
+
def ensure_account_within_limit
|
113
|
+
if archived_changed? && !archived? && !Limit.can_add_one?("projects", account)
|
114
|
+
errors.add(:archived, I18n.t("saucy.errors.limited", :default => "You are at your limit of %{name} for your current plan.", :name => 'projects'))
|
115
|
+
end
|
116
|
+
end
|
109
117
|
end
|
110
118
|
end
|
111
119
|
end
|
data/spec/models/project_spec.rb
CHANGED
@@ -51,6 +51,20 @@ describe Project do
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
+
context "archived project for an account at its project limit" do
|
55
|
+
before do
|
56
|
+
@archived = Factory(:project, :archived => true)
|
57
|
+
@account = @archived.account
|
58
|
+
Limit.stubs(:can_add_one?).with("projects", @account).returns(false)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "cannot be unarchived" do
|
62
|
+
@archived.archived = false
|
63
|
+
@archived.save.should_not be
|
64
|
+
@archived.errors[:archived].first.should match(/at your limit/)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
54
68
|
it "should give its keyword for to_param" do
|
55
69
|
project = Factory(:project)
|
56
70
|
project.to_param.should == project.keyword
|
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:
|
4
|
+
hash: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 4
|
10
|
+
version: 0.5.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- thoughtbot, inc.
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2011-04-
|
21
|
+
date: 2011-04-28 00:00:00 -04:00
|
22
22
|
default_executable:
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
@@ -133,7 +133,6 @@ files:
|
|
133
133
|
- config/locales/en.yml
|
134
134
|
- config/routes.rb
|
135
135
|
- app/controllers/accounts_controller.rb
|
136
|
-
- app/controllers/archives_controller.rb
|
137
136
|
- app/controllers/billings_controller.rb
|
138
137
|
- app/controllers/invitations_controller.rb
|
139
138
|
- app/controllers/memberships_controller.rb
|
@@ -240,7 +239,6 @@ files:
|
|
240
239
|
- lib/generators/saucy/features/templates/README
|
241
240
|
- spec/controllers/accounts_controller_spec.rb
|
242
241
|
- spec/controllers/application_controller_spec.rb
|
243
|
-
- spec/controllers/archives_controller_spec.rb
|
244
242
|
- spec/controllers/invitations_controller_spec.rb
|
245
243
|
- spec/controllers/memberships_controller_spec.rb
|
246
244
|
- spec/controllers/plans_controller_spec.rb
|
@@ -1,27 +0,0 @@
|
|
1
|
-
class ArchivesController < ApplicationController
|
2
|
-
before_filter :authenticate
|
3
|
-
before_filter :authorize_admin
|
4
|
-
before_filter :ensure_account_within_projects_limit
|
5
|
-
|
6
|
-
def create
|
7
|
-
@project = current_project
|
8
|
-
@project.archived = true
|
9
|
-
@project.save
|
10
|
-
flash[:success] = "Project has been archived"
|
11
|
-
redirect_to account_projects_url(current_project.account)
|
12
|
-
end
|
13
|
-
|
14
|
-
def destroy
|
15
|
-
@project = current_project
|
16
|
-
@project.archived = false
|
17
|
-
@project.save
|
18
|
-
flash[:success] = "Project unarchived"
|
19
|
-
redirect_to account_projects_url(current_project.account)
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def ensure_account_within_projects_limit
|
25
|
-
ensure_account_within_limit("projects")
|
26
|
-
end
|
27
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ArchivesController, "routes" do
|
4
|
-
it { should route(:delete, "/accounts/abc/projects/def/archive").
|
5
|
-
to(:action => :destroy, :account_id => 'abc', :project_id => 'def') }
|
6
|
-
it { should route(:post, "/accounts/abc/projects/def/archive").
|
7
|
-
to(:action => :create, :account_id => 'abc', :project_id => 'def') }
|
8
|
-
end
|
9
|
-
|
10
|
-
describe ArchivesController, "destroy", :as => :project_admin do
|
11
|
-
before do
|
12
|
-
delete :destroy, :project_id => project.to_param, :account_id => account.to_param
|
13
|
-
end
|
14
|
-
|
15
|
-
it { should set_the_flash.to(/unarchived/) }
|
16
|
-
|
17
|
-
it "should redirect to account_projects_url" do
|
18
|
-
should redirect_to(account_projects_url(account))
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe ArchivesController, "archive", :as => :project_admin do
|
23
|
-
before do
|
24
|
-
post :create, :project_id => project.to_param, :account_id => account.to_param
|
25
|
-
end
|
26
|
-
|
27
|
-
it { should set_the_flash.to(/archived/) }
|
28
|
-
|
29
|
-
it "should redirect to account_projects_url" do
|
30
|
-
should redirect_to(account_projects_url(account))
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe ArchivesController, "as a non-admin", :as => :project_member do
|
35
|
-
it { should deny_access.on(:delete, :destroy, :project_id => project.to_param,
|
36
|
-
:account_id => account.to_param).
|
37
|
-
flash(/admin/) }
|
38
|
-
|
39
|
-
it { should deny_access.on(:post, :create, :account_id => account.to_param, :project_id => project.to_param).
|
40
|
-
flash(/admin/) }
|
41
|
-
end
|