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 # source: string
# Returns: # Returns:
# Array<int> # 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') # matches the following things (given that `Setting.host_name` equals 'www.openproject.org')
# - http://www.openproject.org/wp/1234 # - http://www.openproject.org/wp/1234
# - https://www.openproject.org/wp/1234 # - https://www.openproject.org/wp/1234

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

Loading…
Cancel
Save