Skip to content

Commit

Permalink
[fix_wrong_credential] Renamed method
Browse files Browse the repository at this point in the history
  • Loading branch information
thangnc committed Sep 21, 2017
1 parent 4f9684a commit f4af064
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/embulk/input/jira.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def self.guess(config)
retryer = retryer(retry_limit, retry_initial_wait_sec)

# Get credential before going to search issue
jira.get_user_credential(username)
jira.check_user_credential(username)

# TODO: we use 0..10 issues to guess config?
records = retryer.with_retry do
Expand Down Expand Up @@ -97,7 +97,7 @@ def init
def run
return preview if preview?

@jira.get_user_credential(task[:username])
@jira.check_user_credential(task[:username])
options = {}
total_count = @jira.total_count(@jql)
last_page = (total_count.to_f / PER_PAGE).ceil
Expand Down Expand Up @@ -141,7 +141,7 @@ def logger
private

def preview
@jira.get_user_credential(task[:username])
@jira.check_user_credential(task[:username])

logger.debug "For preview mode, JIRA input plugin fetches records at most #{PREVIEW_RECORDS_COUNT}"
@jira.search_issues(@jql, max_results: PREVIEW_RECORDS_COUNT).each do |issue|
Expand Down
2 changes: 1 addition & 1 deletion lib/embulk/input/jira_api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def total_count(jql)
search(jql, max_results: 1).num_results
end

def get_user_credential(username)
def check_user_credential(username)
Jiralicious::Issue.find(username)
rescue Jiralicious::JqlError, Jiralicious::AuthenticationError, Jiralicious::NotLoggedIn, Jiralicious::InvalidLogin => e
raise Embulk::ConfigError.new(e.message)
Expand Down
6 changes: 3 additions & 3 deletions spec/embulk/input/jira_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
end

before do
allow(jira_api).to receive(:get_user_credential).with(username).and_return(username)
allow(jira_api).to receive(:check_user_credential).with(username).and_return(username)
allow(jira_api).to receive(:search_issues).with(jql, max_results: described_class::GUESS_RECORDS_COUNT).and_return(jira_issues)

allow(config).to receive(:param).with(:username, :string).and_return(username)
Expand Down Expand Up @@ -219,7 +219,7 @@

# TODO: create stubs without each `it` expected
allow(Embulk::Input::JiraApi::Client).to receive(:setup).and_return(jira_api)
allow(jira_api).to receive(:get_user_credential).and_return(username)
allow(jira_api).to receive(:check_user_credential).and_return(username)

0.step(total_count, max_result) do |start_at|
issues = jira_issues[start_at..(start_at + max_result - 1)]
Expand Down Expand Up @@ -285,7 +285,7 @@
allow(Embulk::Input::JiraApi::Client).to receive(:setup).and_return(jira_api)
allow(plugin).to receive(:logger).and_return(::Logger.new(File::NULL))
allow(plugin).to receive(:preview?).and_return(true)
allow(jira_api).to receive(:get_user_credential).and_return(username)
allow(jira_api).to receive(:check_user_credential).and_return(username)
allow(jira_api).to receive(:search_issues).and_return(jira_issues)
allow(page_builder).to receive(:add)
allow(page_builder).to receive(:finish)
Expand Down

0 comments on commit f4af064

Please sign in to comment.