Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZ.J. van de Weg <git@zjvandeweg.nl>2016-12-15 16:32:50 +0300
committerZ.J. van de Weg <git@zjvandeweg.nl>2016-12-15 22:21:35 +0300
commit4b23764da7622ae6bc40697c7c623df901cae01b (patch)
treef5d11a2a67e65692997bbcc3de45460731b08e3c /lib/mattermost
parent429c9220f0ce49fa54ea640cbfc78e3591202138 (diff)
Improve session tests
Diffstat (limited to 'lib/mattermost')
-rw-r--r--lib/mattermost/session.rb (renamed from lib/mattermost/mattermost.rb)9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/mattermost/mattermost.rb b/lib/mattermost/session.rb
index 84d016bb197..d14121c91a0 100644
--- a/lib/mattermost/mattermost.rb
+++ b/lib/mattermost/session.rb
@@ -13,13 +13,14 @@ module Mattermost
# This class however skips the button click, and also the approval phase to
# speed up the process and keep it without manual action and get a session
# going.
- class Mattermost
+ class Session
include Doorkeeper::Helpers::Controller
include HTTParty
attr_accessor :current_resource_owner
def initialize(uri, current_user)
+ # Sets the base uri for HTTParty, so we can use paths
self.class.base_uri(uri)
@current_resource_owner = current_user
@@ -27,8 +28,10 @@ module Mattermost
def with_session
raise NoSessionError unless create
- yield
+ result = yield
destroy
+
+ result
end
# Next methods are needed for Doorkeeper
@@ -85,7 +88,7 @@ module Mattermost
end
def request_token
- @request_token ||= if @token_uri
+ @request_token ||= begin
response = get(@token_uri, follow_redirects: false)
response.headers['token'] if 200 <= response.code && response.code < 400
end