Skip to content

Commit 44d799f

Browse files
author
root
committed
Add tests for patched UsersController
1 parent ca93a78 commit 44d799f

File tree

2 files changed

+42
-9
lines changed

2 files changed

+42
-9
lines changed

Diff for: lib/redmine_git_hosting/patches/users_controller_patch.rb

-9
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ def self.included(base)
99
base.class_eval do
1010
unloadable
1111

12-
alias_method_chain :update, :git_hosting
1312
alias_method_chain :edit, :git_hosting
1413

1514
helper :gitolite_public_keys
@@ -19,14 +18,6 @@ def self.included(base)
1918

2019
module InstanceMethods
2120

22-
def update_with_git_hosting(&block)
23-
# Set public key values for view
24-
set_public_key_values
25-
26-
# Previous routine
27-
update_without_git_hosting(&block)
28-
end
29-
3021

3122
def edit_with_git_hosting(&block)
3223
# Set public key values for view

Diff for: spec/controllers/users_controller_spec.rb

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2+
3+
describe UsersController do
4+
5+
USER_KEY1 = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCZiNOKQtOrBEPGpLC7KZ+dx4zAGEupIWZMuLBbRZJEAjx959b2AcvK5BH1iQ8z6NkBw64MAnXhXY+cwh8HDKg+7ONnf7U+zyWZ/DTuh9DU1k5EQOAq7QXcZWxXgWIhGlNwu4jgxiyilAG0OfLZcNGZO4vP6cMRhdTuvst1PBxR6htQh2EJaeIiW1BsFcB2RR1x5tJIteAJ2NvBolsSPijVmolsX+y1URL3Pt8W8/jlxnscogZpOQHsDZByUBWEiUZNheVCpCsVUM1LkbL0sIIB40B8rKhchlzJYlRCm8axLbbs2lUtSKZBy0Rk1SiERlnGIGuzIda2h1Dbg7vqbMf3 nicolas@tchoum'
6+
DEPLOY_KEY1 = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0B/TiFjjGdLJko8/cZoQyL1Z9BMOjeQfpI45ofq6ROy5jFsfvY8hjBUHnmSFxzRsGLNWK9lWbAhW2WLjPomgcv5RrowJsLFlhVJLAgQ6q4g+4i/PccYcZHXqPLqJLIO1Yxvze7eQvOMtzPt2IYljM4kcR47YnwfbvU40Rq+ezdaIUCaQ4ZjRn879htRKt5SPO6qi8Kgd2s8sUjgJqrFZt9dkzwW+frn5VHgmlO5WT3HrmxF5U6un+uIoiMfX5TjNogn1WQm42vd8Q4f6mAQ9EmK5RK24R24m4YT91Q1b5QBb0qoGap0OJWjmNxX4tvuZ8SSRYXzqLERp7Jcy/r11J nicolas@tchoum'
7+
8+
def create_ssh_key(opts = {})
9+
FactoryGirl.create(:gitolite_public_key, opts)
10+
end
11+
12+
13+
before(:all) do
14+
@user = FactoryGirl.create(:user, :admin => true)
15+
User.current = @user
16+
@user_key = create_ssh_key(:user_id => @user.id, :title => 'user_key', key: USER_KEY1, :key_type => 0)
17+
@deploy_key = create_ssh_key(:user_id => @user.id, :title => 'deploy_key', key: DEPLOY_KEY1, :key_type => 1)
18+
end
19+
20+
21+
describe "GET #edit" do
22+
context "with git hosting patch" do
23+
before do
24+
request.session[:user_id] = @user.id
25+
get :edit, :id => @user.id
26+
end
27+
28+
it "populates an array of gitolite_user_keys" do
29+
expect(assigns(:gitolite_user_keys)).to eq [@user_key]
30+
end
31+
32+
it "populates an array of gitolite_deploy_keys" do
33+
expect(assigns(:gitolite_deploy_keys)).to eq [@deploy_key]
34+
end
35+
36+
it "populates an empty gitolite_public_key" do
37+
expect(assigns(:gitolite_public_key)).to be_an_instance_of(GitolitePublicKey)
38+
end
39+
end
40+
end
41+
42+
end

0 commit comments

Comments
 (0)