sumoheavy / jira-ruby

A Ruby gem for the JIRA REST API
MIT License
657 stars 412 forks source link

Project versions do not report correctly #219

Open NigelThorne opened 7 years ago

NigelThorne commented 7 years ago

I think this is something to do with the url for one version being "rest/api/2/version/xxx" and the list of versions for a project being "rest/api/2/project/123/versions"

issues = client.Issue.jql(query)
projects = issues.map{|i| i.project}.uniq{|i| i.id}
    projects[0].versions.all # this fails with No Method  as there is no API method for Get on rest/api/2/version
SimonMiaou commented 7 years ago

We could override Resource::Version.collection_path to provide the correct path

SimonMiaou commented 7 years ago

Actually, do you need the method all? .versions should return an instance of JIRA::HasManyProxy that act as an array.

lemingos commented 7 years ago

Same problem here, looks like searching for project versions similar to issues solves it


      def versions(options={})
        versions_url = client.options[:rest_base_path] + "/project/#{id}/versions"
        response = client.get(url_with_query_params(versions_url, Base.query_params_for_search(options)))
        json = self.class.parse_json(response.body)
        json.map do |version|
          client.Version.build(version)
        end
      end```