Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
6ae25290
Commit
6ae25290
authored
Apr 02, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove KeysObserver
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
77c0a6db
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
43 deletions
+38
-43
app/models/key.rb
app/models/key.rb
+24
-0
app/observers/key_observer.rb
app/observers/key_observer.rb
+0
-19
config/application.rb
config/application.rb
+0
-1
spec/models/key_spec.rb
spec/models/key_spec.rb
+14
-0
spec/observers/key_observer_spec.rb
spec/observers/key_observer_spec.rb
+0
-23
No files found.
app/models/key.rb
View file @
6ae25290
...
@@ -29,6 +29,10 @@ class Key < ActiveRecord::Base
...
@@ -29,6 +29,10 @@ class Key < ActiveRecord::Base
delegate
:name
,
:email
,
to: :user
,
prefix:
true
delegate
:name
,
:email
,
to: :user
,
prefix:
true
after_create
:add_to_shell
after_create
:notify_user
after_destroy
:remove_from_shell
def
strip_white_space
def
strip_white_space
self
.
key
=
key
.
strip
unless
key
.
blank?
self
.
key
=
key
.
strip
unless
key
.
blank?
end
end
...
@@ -42,6 +46,26 @@ class Key < ActiveRecord::Base
...
@@ -42,6 +46,26 @@ class Key < ActiveRecord::Base
"key-
#{
id
}
"
"key-
#{
id
}
"
end
end
def
add_to_shell
GitlabShellWorker
.
perform_async
(
:add_key
,
shell_id
,
key
)
end
def
notify_user
NotificationService
.
new
.
new_key
(
self
)
end
def
remove_from_shell
GitlabShellWorker
.
perform_async
(
:remove_key
,
shell_id
,
key
,
)
end
private
private
def
generate_fingerpint
def
generate_fingerpint
...
...
app/observers/key_observer.rb
deleted
100644 → 0
View file @
77c0a6db
class
KeyObserver
<
BaseObserver
def
after_create
(
key
)
GitlabShellWorker
.
perform_async
(
:add_key
,
key
.
shell_id
,
key
.
key
)
notification
.
new_key
(
key
)
end
def
after_destroy
(
key
)
GitlabShellWorker
.
perform_async
(
:remove_key
,
key
.
shell_id
,
key
.
key
,
)
end
end
config/application.rb
View file @
6ae25290
...
@@ -21,7 +21,6 @@ module Gitlab
...
@@ -21,7 +21,6 @@ module Gitlab
# Activate observers that should always be running.
# Activate observers that should always be running.
config
.
active_record
.
observers
=
:milestone_observer
,
config
.
active_record
.
observers
=
:milestone_observer
,
:project_activity_cache_observer
,
:project_activity_cache_observer
,
:key_observer
,
:merge_request_observer
,
:merge_request_observer
,
:note_observer
,
:note_observer
,
:project_observer
,
:project_observer
,
...
...
spec/models/key_spec.rb
View file @
6ae25290
...
@@ -68,4 +68,18 @@ describe Key do
...
@@ -68,4 +68,18 @@ describe Key do
build
(
:invalid_key
).
should_not
be_valid
build
(
:invalid_key
).
should_not
be_valid
end
end
end
end
context
'callbacks'
do
it
'should add new key to authorized_file'
do
@key
=
build
(
:personal_key
,
id:
7
)
GitlabShellWorker
.
should_receive
(
:perform_async
).
with
(
:add_key
,
@key
.
shell_id
,
@key
.
key
)
@key
.
save
end
it
'should remove key from authorized_file'
do
@key
=
create
(
:personal_key
)
GitlabShellWorker
.
should_receive
(
:perform_async
).
with
(
:remove_key
,
@key
.
shell_id
,
@key
.
key
)
@key
.
destroy
end
end
end
end
spec/observers/key_observer_spec.rb
deleted
100644 → 0
View file @
77c0a6db
require
'spec_helper'
describe
KeyObserver
do
before
do
@key
=
create
(
:personal_key
)
@observer
=
KeyObserver
.
instance
end
context
:after_create
do
it
do
GitlabShellWorker
.
should_receive
(
:perform_async
).
with
(
:add_key
,
@key
.
shell_id
,
@key
.
key
)
@observer
.
after_create
(
@key
)
end
end
context
:after_destroy
do
it
do
GitlabShellWorker
.
should_receive
(
:perform_async
).
with
(
:remove_key
,
@key
.
shell_id
,
@key
.
key
)
@observer
.
after_destroy
(
@key
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment