lib/dradis/plugins/content_service/issues.rb in dradis-plugins-4.7.0 vs lib/dradis/plugins/content_service/issues.rb in dradis-plugins-4.8.0

- old
+ new

@@ -1,18 +1,29 @@ module Dradis::Plugins::ContentService module Issues extend ActiveSupport::Concern def all_issues - project.issues.where(category_id: default_issue_category.id) + issues = + case scope + when :all + project.issues + when :published + project.issues.published + else + raise 'Unsupported scope!' + end + + issues.where(category_id: default_issue_category.id) end def create_issue(args={}) text = args.fetch(:text, default_issue_text) # NOTE that ID is the unique issue identifier assigned by the plugin, # and is not to be confused with the Issue#id primary key id = args.fetch(:id, default_issue_id) + state = args.fetch(:state, @state) # Bail if we already have this issue in the cache uuid = [plugin::Engine::plugin_name, id] cache_key = uuid.join('-') @@ -23,12 +34,13 @@ "\n\n#[plugin]#\n#{uuid[0]}\n" \ "\n\n#[plugin_id]#\n#{uuid[1]}\n" text << plugin_details issue = Issue.new(text: text) do |i| - i.author = default_author - i.node = project.issue_library + i.author = default_author + i.node = project.issue_library i.category = default_issue_category + i.state = state end if issue.valid? issue.save else