forge-cli 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/bin/cucumber +16 -0
- data/bin/erubis +16 -0
- data/bin/htmldiff +16 -0
- data/bin/ldiff +16 -0
- data/bin/rackup +16 -0
- data/bin/rake +16 -0
- data/bin/rdoc +16 -0
- data/bin/ri +16 -0
- data/bin/sprockets +16 -0
- data/bin/thor +16 -0
- data/bin/tilt +16 -0
- data/bin/tt +16 -0
- data/lib/forge-cli/modules/base/manifest.yml +18 -0
- data/lib/forge-cli/modules/base/routes.rb +1 -2
- data/lib/forge-cli/modules/events/routes.rb +6 -1
- data/lib/forge-cli/version.rb +1 -1
- data/lib/forge/Gemfile +2 -0
- data/lib/forge/app/controllers/events_controller.rb +11 -0
- data/lib/forge/app/controllers/pages_controller.rb +1 -1
- data/lib/forge/app/controllers/products_controller.rb +1 -1
- data/lib/forge/app/views/forge/dispatches/_form.html.haml +0 -13
- data/lib/forge/app/views/forge/events/_form.html.haml +14 -10
- data/lib/forge/app/views/forge/posts/_form.html.haml +2 -2
- data/lib/forge/app/views/forge/products/_form.html.haml +10 -4
- data/lib/forge/config/routes.rb +8 -3
- data/lib/forge/features/authentication.feature +8 -0
- data/lib/forge/features/step_definitions/web_steps.rb +24 -0
- data/lib/forge/features/support/env.rb +60 -0
- data/lib/forge/features/support/paths.rb +20 -0
- data/lib/forge/lib/assets/javascripts/forge/features/asset_uploads.js.erb +1 -1
- data/lib/forge/lib/generators/forge/scaffold/templates/controller_spec.rb +48 -48
- data/lib/forge/lib/generators/forge/scaffold_small/templates/controller_spec.rb +42 -42
- data/lib/forge/spec/controllers/forge/banners_controller_spec.rb +47 -47
- data/lib/forge/spec/controllers/forge/dispatches_controller_spec.rb +45 -45
- data/lib/forge/spec/controllers/forge/events_controller_spec.rb +45 -45
- data/lib/forge/spec/controllers/forge/galleries_controller_spec.rb +44 -44
- data/lib/forge/spec/controllers/forge/orders_controller_spec.rb +45 -45
- data/lib/forge/spec/controllers/forge/pages_controller_spec.rb +46 -46
- data/lib/forge/spec/controllers/forge/post_categories_controller_spec.rb +41 -41
- data/lib/forge/spec/controllers/forge/posts_controller_spec.rb +45 -45
- data/lib/forge/spec/controllers/forge/product_categories_controller_spec.rb +42 -42
- data/lib/forge/spec/controllers/forge/products_controller_spec.rb +47 -47
- data/lib/forge/spec/controllers/forge/sales_controller_spec.rb +45 -45
- data/lib/forge/spec/controllers/forge/subscriber_groups_controller_spec.rb +45 -45
- data/lib/forge/spec/controllers/forge/subscribers_controller_spec.rb +40 -40
- data/lib/forge/spec/controllers/forge/tax_rates_controller_spec.rb +41 -41
- data/lib/forge/spec/controllers/forge/users_controller_spec.rb +58 -58
- data/lib/forge/spec/controllers/forge/videos_controller_spec.rb +9 -9
- data/lib/forge/spec/models/reorderable_spec.rb +5 -5
- metadata +31 -21
- data/lib/forge/config/database.yml +0 -24
- data/lib/forge/config/deploy.rb +0 -53
- data/lib/forge/config/dispatch_daemon.yml +0 -23
- data/lib/forge/config/s3.yml +0 -19
- data/lib/forge/log/development.log +0 -2
- data/lib/forge/script/dispatch_daemon_fetcher +0 -28
@@ -2,9 +2,9 @@ describe Forge::SubscribersController do
|
|
2
2
|
describe "As an admin, " do
|
3
3
|
fixtures :roles, :users
|
4
4
|
before do
|
5
|
-
controller.stub
|
5
|
+
controller.stub(:current_user).and_return(users(:admin))
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
# EDIT
|
9
9
|
describe "GET subscribers/:id/edit" do
|
10
10
|
before do
|
@@ -12,134 +12,134 @@ describe Forge::SubscribersController do
|
|
12
12
|
Subscriber.should_receive(:find).with("1").and_return(@subscriber)
|
13
13
|
get :edit, :id => 1
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
it "should assign @subscriber" do
|
17
17
|
assigns[:subscriber].should == @subscriber
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
it "should render the edit template" do
|
21
21
|
response.should render_template('edit')
|
22
22
|
end
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
|
26
26
|
# CREATE
|
27
27
|
describe "POST subscribers/" do
|
28
28
|
def do_create
|
29
29
|
post :create, :subscriber => {}
|
30
30
|
end
|
31
|
-
|
32
|
-
describe "with valid attributes" do
|
31
|
+
|
32
|
+
describe "with valid attributes" do
|
33
33
|
before do
|
34
34
|
@subscriber = mock_model(Subscriber, :save => true)
|
35
|
-
Subscriber.stub
|
35
|
+
Subscriber.stub(:new).and_return(@subscriber)
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
it "should assign @subscriber" do
|
39
39
|
do_create
|
40
40
|
assigns[:subscriber].should == @subscriber
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
it "should set the flash notice" do
|
44
44
|
do_create
|
45
45
|
flash[:notice].should_not be_nil
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
it "should redirect to the index" do
|
49
49
|
do_create
|
50
50
|
response.should redirect_to(forge_subscribers_path)
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
it "should be valid" do
|
54
54
|
@subscriber.should_receive(:save).and_return(:true)
|
55
55
|
do_create
|
56
56
|
end
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
describe "with invalid attributes" do
|
60
60
|
before do
|
61
61
|
@subscriber = mock_model(Subscriber, :save => false)
|
62
|
-
Subscriber.stub
|
62
|
+
Subscriber.stub(:new).and_return(@subscriber)
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
it "should assign @subscriber" do
|
66
66
|
do_create
|
67
67
|
assigns[:subscriber].should == @subscriber
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
it "should not set the flash notice" do
|
71
71
|
do_create
|
72
72
|
flash[:notice].should be_nil
|
73
73
|
end
|
74
|
-
|
74
|
+
|
75
75
|
it "should render the index template" do
|
76
76
|
do_create
|
77
77
|
response.should render_template('index')
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
it "should not save" do
|
81
81
|
@subscriber.should_receive(:save).and_return(:false)
|
82
82
|
do_create
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
# UPDATE
|
88
88
|
describe "PUT subscribers/:id" do
|
89
89
|
def do_update
|
90
90
|
put :update, :id => "1", :subscriber => {}
|
91
|
-
end
|
92
|
-
|
91
|
+
end
|
92
|
+
|
93
93
|
describe "with valid params" do
|
94
94
|
before(:each) do
|
95
95
|
@subscriber = mock_model(Subscriber, :update_attributes => true)
|
96
|
-
Subscriber.stub
|
96
|
+
Subscriber.stub(:find).with("1").and_return(@subscriber)
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
99
|
it "should find subscriber and return object" do
|
100
100
|
do_update
|
101
101
|
assigns[:subscriber].should == @subscriber
|
102
102
|
end
|
103
|
-
|
103
|
+
|
104
104
|
it "should update the subscriber object's attributes" do
|
105
105
|
@subscriber.should_receive(:update_attributes)
|
106
106
|
do_update
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
it "should redirect to the subscriber index page" do
|
110
110
|
do_update
|
111
111
|
response.should redirect_to(forge_subscribers_path)
|
112
112
|
end
|
113
113
|
end
|
114
|
-
|
114
|
+
|
115
115
|
describe "with invalid params" do
|
116
116
|
before(:each) do
|
117
117
|
@subscriber = mock_model(Subscriber, :update_attributes => false)
|
118
|
-
Subscriber.stub
|
118
|
+
Subscriber.stub(:find).with("1").and_return(@subscriber)
|
119
119
|
end
|
120
|
-
|
120
|
+
|
121
121
|
it "should find subscriber and return object" do
|
122
122
|
do_update
|
123
123
|
assigns[:subscriber].should == @subscriber
|
124
124
|
end
|
125
|
-
|
125
|
+
|
126
126
|
it "should update the subscriber object's attributes" do
|
127
127
|
@subscriber.should_receive(:update_attributes)
|
128
128
|
do_update
|
129
129
|
end
|
130
|
-
|
130
|
+
|
131
131
|
it "should render the edit form" do
|
132
132
|
do_update
|
133
133
|
response.should render_template('edit')
|
134
134
|
end
|
135
|
-
|
135
|
+
|
136
136
|
it "should not have a flash notice" do
|
137
137
|
do_update
|
138
138
|
flash[:notice].should be_blank
|
139
139
|
end
|
140
140
|
end
|
141
141
|
end
|
142
|
-
|
142
|
+
|
143
143
|
# EXPORT
|
144
144
|
describe "GET /subscribers/export" do
|
145
145
|
it "should return a csv file on export" do
|
@@ -150,38 +150,38 @@ describe Forge::SubscribersController do
|
|
150
150
|
# controller.should_receive(:send_data)
|
151
151
|
end
|
152
152
|
end
|
153
|
-
|
153
|
+
|
154
154
|
# DESTROY
|
155
155
|
describe "DELETE /subscribers/:id" do
|
156
156
|
it "should delete" do
|
157
157
|
@subscriber = mock_model(Subscriber)
|
158
|
-
Subscriber.stub
|
158
|
+
Subscriber.stub(:find).and_return(@subscriber)
|
159
159
|
@subscriber.should_receive(:destroy)
|
160
160
|
delete :destroy, :id => 1
|
161
161
|
end
|
162
162
|
end
|
163
163
|
end
|
164
|
-
|
164
|
+
|
165
165
|
describe "As someone who's not logged in" do
|
166
166
|
before do
|
167
|
-
controller.stub
|
167
|
+
controller.stub(:current_user).and_return(nil)
|
168
168
|
end
|
169
|
-
|
169
|
+
|
170
170
|
it "should not let you get the edit action" do
|
171
171
|
get :edit, :id => 1
|
172
172
|
response.should redirect_to('/login')
|
173
173
|
end
|
174
|
-
|
174
|
+
|
175
175
|
it "should not let you get the create action" do
|
176
176
|
post :create
|
177
177
|
response.should redirect_to('/login')
|
178
178
|
end
|
179
|
-
|
179
|
+
|
180
180
|
it "should not let you get the update action" do
|
181
181
|
put :update, :id => 1
|
182
182
|
response.should redirect_to('/login')
|
183
183
|
end
|
184
|
-
|
184
|
+
|
185
185
|
it "should not let you get the destroy action" do
|
186
186
|
delete :destroy, :id => 1
|
187
187
|
response.should redirect_to('/login')
|
@@ -4,10 +4,10 @@ describe Forge::TaxRatesController do
|
|
4
4
|
describe "As an admin" do
|
5
5
|
fixtures :users, :roles
|
6
6
|
before do
|
7
|
-
controller.stub
|
7
|
+
controller.stub(:current_user).and_return(users(:admin))
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
|
11
11
|
# EDIT
|
12
12
|
describe "GET tax_rates/:id/edit" do
|
13
13
|
before do
|
@@ -15,167 +15,167 @@ describe Forge::TaxRatesController do
|
|
15
15
|
TaxRate.should_receive(:find).with("1").and_return(@tax_rate)
|
16
16
|
get :edit, :id => 1
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
it "should assign @tax_rate" do
|
20
20
|
assigns[:tax_rate].should == @tax_rate
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
it "should render the edit template" do
|
24
24
|
response.should render_template('edit')
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
|
29
29
|
# CREATE
|
30
30
|
describe "POST tax_rates/" do
|
31
31
|
def do_create
|
32
32
|
post :create, :tax_rate => {}
|
33
33
|
end
|
34
|
-
|
35
|
-
describe "with valid attributes" do
|
34
|
+
|
35
|
+
describe "with valid attributes" do
|
36
36
|
before do
|
37
37
|
@tax_rate = mock_model(TaxRate, :save => true)
|
38
|
-
TaxRate.stub
|
38
|
+
TaxRate.stub(:new).and_return(@tax_rate)
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
it "should assign @tax_rate" do
|
42
42
|
do_create
|
43
43
|
assigns[:tax_rate].should == @tax_rate
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
it "should set the flash notice" do
|
47
47
|
do_create
|
48
48
|
flash[:notice].should_not be_nil
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
it "should redirect to the index" do
|
52
52
|
do_create
|
53
53
|
response.should redirect_to(forge_tax_rates_path)
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
it "should be valid" do
|
57
57
|
@tax_rate.should_receive(:save).and_return(:true)
|
58
58
|
do_create
|
59
59
|
end
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
describe "with invalid attributes" do
|
63
63
|
before do
|
64
64
|
@tax_rate = mock_model(TaxRate, :save => false)
|
65
|
-
TaxRate.stub
|
65
|
+
TaxRate.stub(:new).and_return(@tax_rate)
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
it "should assign @tax_rate" do
|
69
69
|
do_create
|
70
70
|
assigns[:tax_rate].should == @tax_rate
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
it "should not set the flash notice" do
|
74
74
|
do_create
|
75
75
|
flash[:notice].should be_nil
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
it "should render the index template" do
|
79
79
|
do_create
|
80
80
|
response.should render_template('index')
|
81
81
|
end
|
82
|
-
|
82
|
+
|
83
83
|
it "should not save" do
|
84
84
|
@tax_rate.should_receive(:save).and_return(:false)
|
85
85
|
do_create
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
# UPDATE
|
91
91
|
describe "PUT tax_rates/:id" do
|
92
92
|
def do_update
|
93
93
|
put :update, :id => "1", :tax_rate => {}
|
94
|
-
end
|
95
|
-
|
94
|
+
end
|
95
|
+
|
96
96
|
describe "with valid params" do
|
97
97
|
before(:each) do
|
98
98
|
@tax_rate = mock_model(TaxRate, :update_attributes => true)
|
99
|
-
TaxRate.stub
|
99
|
+
TaxRate.stub(:find).with("1").and_return(@tax_rate)
|
100
100
|
end
|
101
|
-
|
101
|
+
|
102
102
|
it "should find tax_rate and return object" do
|
103
103
|
do_update
|
104
104
|
assigns[:tax_rate].should == @tax_rate
|
105
105
|
end
|
106
|
-
|
106
|
+
|
107
107
|
it "should update the tax_rate object's attributes" do
|
108
108
|
@tax_rate.should_receive(:update_attributes)
|
109
109
|
do_update
|
110
110
|
end
|
111
|
-
|
111
|
+
|
112
112
|
it "should redirect to the tax_rate index page" do
|
113
113
|
do_update
|
114
114
|
response.should redirect_to(forge_tax_rates_path)
|
115
115
|
end
|
116
116
|
end
|
117
|
-
|
117
|
+
|
118
118
|
describe "with invalid params" do
|
119
119
|
before(:each) do
|
120
120
|
@tax_rate = mock_model(TaxRate, :update_attributes => false)
|
121
|
-
TaxRate.stub
|
121
|
+
TaxRate.stub(:find).with("1").and_return(@tax_rate)
|
122
122
|
end
|
123
|
-
|
123
|
+
|
124
124
|
it "should find tax_rate and return object" do
|
125
125
|
do_update
|
126
126
|
assigns[:tax_rate].should == @tax_rate
|
127
127
|
end
|
128
|
-
|
128
|
+
|
129
129
|
it "should update the tax_rate object's attributes" do
|
130
130
|
@tax_rate.should_receive(:update_attributes)
|
131
131
|
do_update
|
132
132
|
end
|
133
|
-
|
133
|
+
|
134
134
|
it "should render the edit form" do
|
135
135
|
do_update
|
136
136
|
response.should render_template('edit')
|
137
137
|
end
|
138
|
-
|
138
|
+
|
139
139
|
it "should not have a flash notice" do
|
140
140
|
do_update
|
141
141
|
flash[:notice].should be_blank
|
142
142
|
end
|
143
143
|
end
|
144
|
-
|
144
|
+
|
145
145
|
end
|
146
|
-
|
146
|
+
|
147
147
|
# DESTROY
|
148
148
|
describe "DELETE /tax_rates/:id" do
|
149
149
|
it "should delete" do
|
150
150
|
@tax_rate = mock_model(TaxRate)
|
151
|
-
TaxRate.stub
|
151
|
+
TaxRate.stub(:find).and_return(@tax_rate)
|
152
152
|
@tax_rate.should_receive(:destroy)
|
153
153
|
delete :destroy, :id => 1
|
154
154
|
end
|
155
155
|
end
|
156
156
|
end
|
157
|
-
|
158
|
-
|
157
|
+
|
158
|
+
|
159
159
|
describe "As someone who's not logged in" do
|
160
160
|
before do
|
161
|
-
controller.stub
|
161
|
+
controller.stub(:current_user).and_return(nil)
|
162
162
|
end
|
163
|
-
|
163
|
+
|
164
164
|
it "should not let you get the edit action" do
|
165
165
|
get :edit, :id => 1
|
166
166
|
response.should redirect_to('/login')
|
167
167
|
end
|
168
|
-
|
168
|
+
|
169
169
|
it "should not let you get the create action" do
|
170
170
|
post :create
|
171
171
|
response.should redirect_to('/login')
|
172
172
|
end
|
173
|
-
|
173
|
+
|
174
174
|
it "should not let you get the update action" do
|
175
175
|
put :update, :id => 1
|
176
176
|
response.should redirect_to('/login')
|
177
177
|
end
|
178
|
-
|
178
|
+
|
179
179
|
it "should not let you get the destroy action" do
|
180
180
|
delete :destroy, :id => 1
|
181
181
|
response.should redirect_to('/login')
|
@@ -4,24 +4,24 @@ describe Forge::UsersController do
|
|
4
4
|
describe "As an admin" do
|
5
5
|
fixtures :users, :roles
|
6
6
|
before do
|
7
|
-
controller.stub
|
7
|
+
controller.stub(:current_user).and_return(users(:admin))
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
# NEW
|
11
11
|
describe "GET users/new" do
|
12
12
|
before do
|
13
13
|
get :new
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
it "should assign @user" do
|
17
17
|
assigns[:user].should_not be_nil
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
it "should render the new template" do
|
21
21
|
response.should render_template('new')
|
22
22
|
end
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
# EDIT
|
26
26
|
describe "GET users/:id/edit" do
|
27
27
|
before do
|
@@ -29,180 +29,180 @@ describe Forge::UsersController do
|
|
29
29
|
User.should_receive(:find).with("1").and_return(@user)
|
30
30
|
get :edit, :id => 1
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
it "should assign @user" do
|
34
34
|
assigns[:user].should == @user
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
it "should render the edit template" do
|
38
38
|
response.should render_template('edit')
|
39
39
|
end
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
|
43
43
|
# CREATE
|
44
44
|
describe "POST users/" do
|
45
45
|
def do_create
|
46
46
|
post :create, :user => {}
|
47
47
|
end
|
48
|
-
|
49
|
-
describe "with valid attributes" do
|
48
|
+
|
49
|
+
describe "with valid attributes" do
|
50
50
|
before do
|
51
|
-
@user = mock_model(User, :save => true)
|
52
|
-
@user.stub
|
53
|
-
@user.stub
|
54
|
-
User.stub
|
55
|
-
|
56
|
-
|
51
|
+
@user = mock_model(User, :save => true)
|
52
|
+
@user.stub(:role_ids).and_return([])
|
53
|
+
@user.stub(:role_ids=).and_return([])
|
54
|
+
User.stub(:new).and_return(@user)
|
55
|
+
|
56
|
+
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
it "should assign @user" do
|
60
60
|
do_create
|
61
61
|
assigns[:user].should == @user
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
it "should set the flash notice" do
|
65
65
|
do_create
|
66
66
|
flash[:notice].should_not be_nil
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
it "should redirect to the index" do
|
70
70
|
do_create
|
71
71
|
response.should redirect_to(forge_users_path)
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
it "should be valid" do
|
75
75
|
@user.should_receive(:save).and_return(:true)
|
76
76
|
do_create
|
77
77
|
end
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
describe "with invalid attributes" do
|
81
81
|
before do
|
82
82
|
@user = mock_model(User, :save => false)
|
83
|
-
@user.stub
|
84
|
-
@user.stub
|
85
|
-
|
86
|
-
User.stub
|
83
|
+
@user.stub(:role_ids).and_return([])
|
84
|
+
@user.stub(:role_ids=).and_return([])
|
85
|
+
|
86
|
+
User.stub(:new).and_return(@user)
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
89
|
it "should assign @user" do
|
90
90
|
do_create
|
91
91
|
assigns[:user].should == @user
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
94
|
it "should not set the flash notice" do
|
95
95
|
do_create
|
96
96
|
flash[:notice].should be_nil
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
99
|
it "should render the new template" do
|
100
100
|
do_create
|
101
101
|
response.should render_template('new')
|
102
102
|
end
|
103
|
-
|
103
|
+
|
104
104
|
it "should not save" do
|
105
105
|
@user.should_receive(:save).and_return(:false)
|
106
106
|
do_create
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
110
|
-
|
110
|
+
|
111
111
|
# UPDATE
|
112
112
|
describe "PUT users/:id" do
|
113
113
|
def do_update
|
114
114
|
put :update, :id => "1", :user => {}
|
115
|
-
end
|
116
|
-
|
115
|
+
end
|
116
|
+
|
117
117
|
describe "with valid params" do
|
118
118
|
before(:each) do
|
119
119
|
@user = mock_model(User, :update_attributes => true, :"is_admin?" => true)
|
120
|
-
@user.stub
|
121
|
-
User.stub
|
120
|
+
@user.stub(:role_ids=).and_return([])
|
121
|
+
User.stub(:find).with("1").and_return(@user)
|
122
122
|
end
|
123
|
-
|
123
|
+
|
124
124
|
it "should find user and return object" do
|
125
125
|
do_update
|
126
126
|
assigns[:user].should == @user
|
127
127
|
end
|
128
|
-
|
128
|
+
|
129
129
|
it "should update the user object's attributes" do
|
130
130
|
@user.should_receive(:update_attributes)
|
131
131
|
do_update
|
132
132
|
end
|
133
|
-
|
133
|
+
|
134
134
|
it "should redirect to the user index page" do
|
135
135
|
do_update
|
136
136
|
response.should redirect_to(forge_users_path)
|
137
137
|
end
|
138
138
|
end
|
139
|
-
|
139
|
+
|
140
140
|
describe "with invalid params" do
|
141
141
|
before(:each) do
|
142
142
|
@user = mock_model(User, :update_attributes => false, :"is_admin?" => true)
|
143
|
-
@user.stub
|
144
|
-
User.stub
|
143
|
+
@user.stub(:role_ids=).and_return([])
|
144
|
+
User.stub(:find).with("1").and_return(@user)
|
145
145
|
end
|
146
|
-
|
146
|
+
|
147
147
|
it "should find user and return object" do
|
148
148
|
do_update
|
149
149
|
assigns[:user].should == @user
|
150
150
|
end
|
151
|
-
|
151
|
+
|
152
152
|
it "should update the user object's attributes" do
|
153
153
|
@user.should_receive(:update_attributes)
|
154
154
|
do_update
|
155
155
|
end
|
156
|
-
|
156
|
+
|
157
157
|
it "should render the edit form" do
|
158
158
|
do_update
|
159
159
|
response.should render_template('edit')
|
160
160
|
end
|
161
|
-
|
161
|
+
|
162
162
|
it "should not have a flash notice" do
|
163
163
|
do_update
|
164
164
|
flash[:notice].should be_blank
|
165
165
|
end
|
166
166
|
end
|
167
|
-
|
167
|
+
|
168
168
|
end
|
169
|
-
|
169
|
+
|
170
170
|
# DESTROY
|
171
171
|
describe "DELETE /users/:id" do
|
172
172
|
it "should delete" do
|
173
173
|
@user = mock_model(User)
|
174
|
-
User.stub
|
174
|
+
User.stub(:find).and_return(@user)
|
175
175
|
@user.should_receive(:destroy)
|
176
176
|
delete :destroy, :id => 1
|
177
177
|
end
|
178
178
|
end
|
179
179
|
end
|
180
|
-
|
180
|
+
|
181
181
|
describe "As someone who's not logged in" do
|
182
182
|
before do
|
183
|
-
controller.stub
|
183
|
+
controller.stub(:current_user).and_return(nil)
|
184
184
|
end
|
185
|
-
|
185
|
+
|
186
186
|
it "should not let you get the new action" do
|
187
187
|
get :new
|
188
188
|
response.should redirect_to('/login')
|
189
189
|
end
|
190
|
-
|
190
|
+
|
191
191
|
it "should not let you get the edit action" do
|
192
192
|
get :edit, :id => 1
|
193
193
|
response.should redirect_to('/login')
|
194
194
|
end
|
195
|
-
|
195
|
+
|
196
196
|
it "should not let you get the create action" do
|
197
197
|
post :create
|
198
198
|
response.should redirect_to('/login')
|
199
199
|
end
|
200
|
-
|
200
|
+
|
201
201
|
it "should not let you get the update action" do
|
202
202
|
put :update, :id => 1
|
203
203
|
response.should redirect_to('/login')
|
204
204
|
end
|
205
|
-
|
205
|
+
|
206
206
|
it "should not let you get the destroy action" do
|
207
207
|
delete :destroy, :id => 1
|
208
208
|
response.should redirect_to('/login')
|
@@ -212,7 +212,7 @@ describe Forge::UsersController do
|
|
212
212
|
describe "As a a contributor" do
|
213
213
|
fixtures :users, :roles
|
214
214
|
before do
|
215
|
-
controller.stub
|
215
|
+
controller.stub(:current_user).and_return(users(:contributor))
|
216
216
|
end
|
217
217
|
|
218
218
|
it "should not let you get the edit action for the admin user" do
|
@@ -226,13 +226,13 @@ describe Forge::UsersController do
|
|
226
226
|
response.should redirect_to('/forge')
|
227
227
|
flash[:warning].should_not == nil
|
228
228
|
end
|
229
|
-
|
229
|
+
|
230
230
|
it "should not let you get the update action for the admin user" do
|
231
231
|
put :update, :id => users(:admin).id
|
232
232
|
response.should redirect_to('/forge')
|
233
233
|
flash[:warning].should_not == nil
|
234
234
|
end
|
235
|
-
|
235
|
+
|
236
236
|
it "should not let you get the destroy action" do
|
237
237
|
delete :destroy, :id => users(:admin).id
|
238
238
|
response.should redirect_to('/forge')
|
@@ -267,7 +267,7 @@ describe Forge::UsersController do
|
|
267
267
|
@user.roles.include?(roles(:contributor)).should be_true
|
268
268
|
@user.roles.include?(roles(:admin)).should_not be_true
|
269
269
|
end
|
270
|
-
|
270
|
+
|
271
271
|
end
|
272
272
|
|
273
273
|
end
|