rename :parse_work_package to :extract_work_package_ids

pull/6827/head
Philipp Tessenow 11 years ago
parent f9be4c9b96
commit 0bddc9c3a7
  1. 2
      lib/open_project/github_integration/notification_handlers.rb
  2. 8
      spec/lib/notification_handlers_spec.rb

@ -32,7 +32,7 @@ module OpenProject::GithubIntegration
# source: string
# Returns:
# Array<int>
def self.parse_work_package(source)
def self.extract_work_package_ids(source)
# matches the following things (given that `Setting.host_name` equals 'www.openproject.org')
# - http://www.openproject.org/wp/1234
# - https://www.openproject.org/wp/1234

@ -8,28 +8,28 @@ describe OpenProject::GithubIntegration do
describe '.parse_work_package' do
it 'should return an empty array for an empty source' do
result = OpenProject::GithubIntegration::NotificationHandlers.send(
:parse_work_package, '')
:extract_work_package_ids, '')
expect(result).to eql([])
end
it 'should find a plain work package url' do
source = 'Blabla\nhttps://example.net/work_packages/234\n'
result = OpenProject::GithubIntegration::NotificationHandlers.send(
:parse_work_package, source)
:extract_work_package_ids, source)
expect(result).to eql([234])
end
it 'should find a work package url in markdown link syntax' do
source = 'Blabla\n[WP 234](https://example.net/work_packages/234)\n'
result = OpenProject::GithubIntegration::NotificationHandlers.send(
:parse_work_package, source)
:extract_work_package_ids, source)
expect(result).to eql([234])
end
it 'should find multiple work package urls' do
source = "I reference https://example.net/work_packages/434\n and Blabla\n[WP 234](https://example.net/wp/234)\n"
result = OpenProject::GithubIntegration::NotificationHandlers.send(
:parse_work_package, source)
:extract_work_package_ids, source)
expect(result).to eql([434, 234])
end

Loading…
Cancel
Save