@@ -69,17 +69,17 @@ def success_url
69
69
expect {
70
70
post :create , :repository_id => @repository_git . id ,
71
71
:repository_post_receive_url => {
72
- :url => 'http://example.com' ,
73
- :push_mode => 0
72
+ :url => 'http://example.com' ,
73
+ :mode => :github
74
74
}
75
75
} . to change ( RepositoryPostReceiveUrl , :count ) . by ( 1 )
76
76
end
77
77
78
78
it "redirects to the repository page" do
79
79
post :create , :repository_id => @repository_git . id ,
80
80
:repository_post_receive_url => {
81
- :url => 'http://example2.com' ,
82
- :push_mode => 0
81
+ :url => 'http://example2.com' ,
82
+ :mode => :github
83
83
}
84
84
expect ( response ) . to redirect_to ( success_url )
85
85
end
@@ -94,17 +94,17 @@ def success_url
94
94
expect {
95
95
post :create , :repository_id => @repository_git . id ,
96
96
:repository_post_receive_url => {
97
- :url => 'example.com' ,
98
- :push_mode => 0
97
+ :url => 'example.com' ,
98
+ :mode => :github
99
99
}
100
- } . to_not change ( RepositoryMirror , :count )
100
+ } . to_not change ( RepositoryPostReceiveUrl , :count )
101
101
end
102
102
103
103
it "re-renders the :new template" do
104
104
post :create , :repository_id => @repository_git . id ,
105
105
:repository_post_receive_url => {
106
- :url => 'example.com' ,
107
- :push_mode => 0
106
+ :url => 'example.com' ,
107
+ :mode => :github
108
108
}
109
109
expect ( response ) . to render_template ( :new )
110
110
end
@@ -113,17 +113,41 @@ def success_url
113
113
114
114
115
115
describe "GET #edit" do
116
- before do
117
- request . session [ :user_id ] = @user . id
118
- get :edit , :repository_id => @repository_git . id , :id => @post_receive_url . id
116
+ context "with existing post_receive_url" do
117
+ before do
118
+ request . session [ :user_id ] = @user . id
119
+ get :edit , :repository_id => @repository_git . id , :id => @post_receive_url . id
120
+ end
121
+
122
+ it "assigns the requested post_receive_url to @post_receive_url" do
123
+ expect ( assigns ( :post_receive_url ) ) . to eq @post_receive_url
124
+ end
125
+
126
+ it "renders the :edit template" do
127
+ expect ( response ) . to render_template ( :edit )
128
+ end
119
129
end
120
130
121
- it "assigns the requested post_receive_url to @post_receive_url" do
122
- expect ( assigns ( :post_receive_url ) ) . to eq @post_receive_url
131
+ context "with non-existing post_receive_url" do
132
+ before do
133
+ request . session [ :user_id ] = @user . id
134
+ get :edit , :repository_id => @repository_git . id , :id => 100
135
+ end
136
+
137
+ it "renders 404" do
138
+ expect ( response . status ) . to eq 404
139
+ end
123
140
end
124
141
125
- it "renders the :edit template" do
126
- expect ( response ) . to render_template ( :edit )
142
+ context "with unsufficient permissions" do
143
+ before do
144
+ request . session [ :user_id ] = FactoryGirl . create ( :user ) . id
145
+ get :edit , :repository_id => @repository_git . id , :id => @post_receive_url . id
146
+ end
147
+
148
+ it "renders 403" do
149
+ expect ( response . status ) . to eq 403
150
+ end
127
151
end
128
152
end
129
153
@@ -171,7 +195,7 @@ def success_url
171
195
172
196
it "does not change @post_receive_url's attributes" do
173
197
@post_receive_url . reload
174
- expect ( @post_receive_url . url ) . to eq 'http://example.com/toto .php'
198
+ expect ( @post_receive_url . url ) . to eq 'http://example.com/toto1 .php'
175
199
end
176
200
177
201
it "re-renders the :edit template" do
@@ -180,4 +204,22 @@ def success_url
180
204
end
181
205
end
182
206
207
+
208
+ describe 'DELETE destroy' do
209
+ before :each do
210
+ request . session [ :user_id ] = @user . id
211
+ @post_receive_url = FactoryGirl . create ( :repository_post_receive_url , :repository_id => @repository_git . id )
212
+ end
213
+
214
+ it "deletes the post_receive_url" do
215
+ expect {
216
+ delete :destroy , :repository_id => @repository_git . id , :id => @post_receive_url . id , :format => 'js'
217
+ } . to change ( RepositoryPostReceiveUrl , :count ) . by ( -1 )
218
+ end
219
+
220
+ it "redirects to repositories#edit" do
221
+ delete :destroy , :repository_id => @repository_git . id , :id => @post_receive_url . id , :format => 'js'
222
+ expect ( response . status ) . to eq 200
223
+ end
224
+ end
183
225
end
0 commit comments