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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
e6637259
Commit
e6637259
authored
Dec 16, 2016
by
Kamil Trzcinski
Committed by
Z.J. van de Weg
Dec 17, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Store mattermost_url in settings
parent
48ebfaa4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
13 deletions
+35
-13
config/gitlab.yml.example
config/gitlab.yml.example
+6
-0
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+7
-0
lib/mattermost/session.rb
lib/mattermost/session.rb
+9
-8
spec/lib/mattermost/session_spec.rb
spec/lib/mattermost/session_spec.rb
+13
-5
No files found.
config/gitlab.yml.example
View file @
e6637259
...
@@ -153,6 +153,12 @@ production: &base
...
@@ -153,6 +153,12 @@ production: &base
# The location where LFS objects are stored (default: shared/lfs-objects).
# The location where LFS objects are stored (default: shared/lfs-objects).
# storage_path: shared/lfs-objects
# storage_path: shared/lfs-objects
## Mattermost
## For enabling Add to Mattermost button
mattermost:
enabled: false
host: 'https://mattermost.example.com'
## Gravatar
## Gravatar
## For Libravatar see: http://doc.gitlab.com/ce/customization/libravatar.html
## For Libravatar see: http://doc.gitlab.com/ce/customization/libravatar.html
gravatar:
gravatar:
...
...
config/initializers/1_settings.rb
View file @
e6637259
...
@@ -261,6 +261,13 @@ Settings['lfs'] ||= Settingslogic.new({})
...
@@ -261,6 +261,13 @@ Settings['lfs'] ||= Settingslogic.new({})
Settings
.
lfs
[
'enabled'
]
=
true
if
Settings
.
lfs
[
'enabled'
].
nil?
Settings
.
lfs
[
'enabled'
]
=
true
if
Settings
.
lfs
[
'enabled'
].
nil?
Settings
.
lfs
[
'storage_path'
]
=
File
.
expand_path
(
Settings
.
lfs
[
'storage_path'
]
||
File
.
join
(
Settings
.
shared
[
'path'
],
"lfs-objects"
),
Rails
.
root
)
Settings
.
lfs
[
'storage_path'
]
=
File
.
expand_path
(
Settings
.
lfs
[
'storage_path'
]
||
File
.
join
(
Settings
.
shared
[
'path'
],
"lfs-objects"
),
Rails
.
root
)
#
# Mattermost
#
Settings
[
'mattermost'
]
||=
Settingslogic
.
new
({})
Settings
.
mattermost
[
'enabled'
]
=
false
if
Settings
.
mattermost
[
'enabled'
].
nil?
Settings
.
mattermost
[
'host'
]
=
nil
unless
Settings
.
mattermost
.
enabled
#
#
# Gravatar
# Gravatar
#
#
...
...
lib/mattermost/session.rb
View file @
e6637259
...
@@ -17,12 +17,11 @@ module Mattermost
...
@@ -17,12 +17,11 @@ module Mattermost
include
Doorkeeper
::
Helpers
::
Controller
include
Doorkeeper
::
Helpers
::
Controller
include
HTTParty
include
HTTParty
attr_accessor
:current_resource_owner
,
:token
base_uri
Settings
.
mattermost
.
host
def
initialize
(
uri
,
current_user
)
attr_accessor
:current_resource_owner
,
:token
# Sets the base uri for HTTParty, so we can use paths
self
.
class
.
base_uri
(
uri
)
def
initialize
(
current_user
)
@current_resource_owner
=
current_user
@current_resource_owner
=
current_user
end
end
...
@@ -30,7 +29,7 @@ module Mattermost
...
@@ -30,7 +29,7 @@ module Mattermost
raise
NoSessionError
unless
create
raise
NoSessionError
unless
create
begin
begin
yield
yield
self
ensure
ensure
destroy
destroy
end
end
...
@@ -65,7 +64,9 @@ module Mattermost
...
@@ -65,7 +64,9 @@ module Mattermost
return
unless
token_uri
return
unless
token_uri
self
.
token
=
request_token
self
.
token
=
request_token
self
.
class
.
headers
(
"Cookie"
=>
"MMAUTHTOKEN=
#{
self
.
token
}
"
)
@headers
=
{
"Authorization"
:
"Bearer
#{
self
.
token
}
"
}
self
.
token
self
.
token
end
end
...
@@ -98,11 +99,11 @@ module Mattermost
...
@@ -98,11 +99,11 @@ module Mattermost
end
end
def
get
(
path
,
options
=
{})
def
get
(
path
,
options
=
{})
self
.
class
.
get
(
path
,
options
)
self
.
class
.
get
(
path
,
options
.
merge
(
headers:
@headers
)
)
end
end
def
post
(
path
,
options
=
{})
def
post
(
path
,
options
=
{})
self
.
class
.
post
(
path
,
options
)
self
.
class
.
post
(
path
,
options
.
merge
(
headers:
@headers
)
)
end
end
end
end
end
end
spec/lib/mattermost/session_spec.rb
View file @
e6637259
...
@@ -6,7 +6,7 @@ describe Mattermost::Session, type: :request do
...
@@ -6,7 +6,7 @@ describe Mattermost::Session, type: :request do
let
(
:gitlab_url
)
{
"http://gitlab.com"
}
let
(
:gitlab_url
)
{
"http://gitlab.com"
}
let
(
:mattermost_url
)
{
"http://mattermost.com"
}
let
(
:mattermost_url
)
{
"http://mattermost.com"
}
subject
{
described_class
.
new
(
mattermost_url
,
user
)
}
subject
{
described_class
.
new
(
user
)
}
# Needed for doorkeeper to function
# Needed for doorkeeper to function
it
{
is_expected
.
to
respond_to
(
:current_resource_owner
)
}
it
{
is_expected
.
to
respond_to
(
:current_resource_owner
)
}
...
@@ -14,6 +14,10 @@ describe Mattermost::Session, type: :request do
...
@@ -14,6 +14,10 @@ describe Mattermost::Session, type: :request do
it
{
is_expected
.
to
respond_to
(
:authorization
)
}
it
{
is_expected
.
to
respond_to
(
:authorization
)
}
it
{
is_expected
.
to
respond_to
(
:strategy
)
}
it
{
is_expected
.
to
respond_to
(
:strategy
)
}
before
do
described_class
.
base_uri
(
mattermost_url
)
end
describe
'#with session'
do
describe
'#with session'
do
let
(
:location
)
{
'http://location.tld'
}
let
(
:location
)
{
'http://location.tld'
}
let!
(
:stub
)
do
let!
(
:stub
)
do
...
@@ -72,18 +76,22 @@ describe Mattermost::Session, type: :request do
...
@@ -72,18 +76,22 @@ describe Mattermost::Session, type: :request do
end
end
WebMock
.
stub_request
(
:post
,
"
#{
mattermost_url
}
/api/v3/users/logout"
).
WebMock
.
stub_request
(
:post
,
"
#{
mattermost_url
}
/api/v3/users/logout"
).
to_return
(
headers:
{
Cookie
:
'MMAUTHTOKEN=
thisworksnow'
},
status:
200
)
to_return
(
headers:
{
Authorization
:
'token
thisworksnow'
},
status:
200
)
end
end
it
'can setup a session'
do
it
'can setup a session'
do
subject
.
with_session
{
1
+
1
}
subject
.
with_session
do
|
session
|
end
expect
(
subject
.
token
).
not_to
be_nil
expect
(
subject
.
token
).
not_to
be_nil
end
end
it
'returns the value of the block'
do
it
'returns the value of the block'
do
value
=
subject
.
with_session
{
1
+
1
}
result
=
subject
.
with_session
do
|
session
|
"value"
end
expect
(
value
).
to
be
(
2
)
expect
(
result
).
to
eq
(
"value"
)
end
end
end
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