Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
moklidia committed Aug 15, 2023
2 parents 23f6d2e + aa90396 commit df05d7a
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
uffizzi-cli (2.0.19)
uffizzi-cli (2.0.20)
activesupport
awesome_print
faker
Expand Down
1 change: 1 addition & 0 deletions lib/uffizzi/auth_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def signed_in?
def sign_out
Uffizzi::ConfigFile.unset_option(:cookie)
Uffizzi::ConfigFile.unset_option(:account)
Uffizzi::ConfigFile.unset_option(:project)
Uffizzi::Token.delete if Uffizzi::Token.exists?
end

Expand Down
11 changes: 1 addition & 10 deletions lib/uffizzi/cli/login.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,14 @@ def initialize(options)
end

def run
logout
AuthHelper.sign_out if AuthHelper.signed_in?
return perform_email_login if @options[:email]

perform_browser_login
end

private

def logout
return unless Uffizzi::AuthHelper.signed_in?

server = ConfigFile.read_option(:server)
destroy_session(server)

AuthHelper.sign_out
end

def perform_email_login
Uffizzi.ui.say('Login to Uffizzi server.')
username = Uffizzi::LoginHelper.set_username(@options)
Expand Down
2 changes: 1 addition & 1 deletion lib/uffizzi/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Uffizzi
VERSION = '2.0.19'
VERSION = '2.0.20'
end
1 change: 1 addition & 0 deletions test/support/auth_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ def prepare_config_data(account, cookie)
def sign_out
Uffizzi::ConfigFile.unset_option(:cookie)
Uffizzi::ConfigFile.unset_option(:account)
Uffizzi::ConfigFile.unset_option(:project)
end
end
3 changes: 3 additions & 0 deletions test/uffizzi/cli/logout_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ def setup
end

def test_logout_success
Uffizzi::ConfigFile.write_option(:project, 'default')
assert(Uffizzi::ConfigFile.option_has_value?(:cookie))
assert(Uffizzi::ConfigFile.option_has_value?(:account))
assert(Uffizzi::ConfigFile.option_has_value?(:project))

stubbed_uffizzi_logout = stub_uffizzi_logout

Expand All @@ -20,6 +22,7 @@ def test_logout_success

refute(Uffizzi::ConfigFile.option_has_value?(:cookie))
refute(Uffizzi::ConfigFile.option_has_value?(:account))
refute(Uffizzi::ConfigFile.option_has_value?(:project))
end

def test_logout_when_not_logged_in
Expand Down

0 comments on commit df05d7a

Please sign in to comment.