Class: JiraMetrics::Testing::MockIssue
- Defined in:
- lib/jirametrics/testing/mock_issue.rb
Overview
An Issue you can build without a fixture file and then add history to.
MockIssue.new keeps Issue's own signature (raw:, board:) so that a MockIssue is substitutable for an Issue everywhere, including MockCycleTimeConfig's is_a?(Issue) check. The friendly constructor is MockIssue.empty, which builds the minimal raw hash for you.
Constant Summary collapse
- FIRST_GENERATED_KEY_NUMBER =
Generated keys start well clear of the hand-written SP-1 and SP-2 that fixtures use.
1000- DEFAULT_CREATED =
A leap day on purpose. Anything that does its own date arithmetic, assumes 365-day years, or round-trips through a format that cannot represent Feb 29 will trip over this default rather than sailing past on a date that hides the bug.
'2024-02-29'
Instance Attribute Summary
Attributes inherited from Issue
#board, #changes, #discarded_change_times, #discarded_changes, #github_prs, #parent, #raw, #status, #subtasks
Class Method Summary collapse
-
.empty(board:, created: DEFAULT_CREATED, key: nil, creation_status: nil, current_sprint_ids: nil) ⇒ Object
board has no default.
Instance Method Summary collapse
-
#add_change(field:, value:, time:, value_id: nil, old_value: nil, old_value_id: nil, artificial: false, field_id: nil) ⇒ Object
The change is built and appended in one step, and returned for tests that need to hold on to it.
Methods inherited from Issue
#<=>, #all_subtask_activity_times, #artificial?, #assigned_to, #assigned_to_icon_url, #author, #blocked_on_date?, #blocked_stalled_by_date, #blocked_stalled_changes, #compact_text, #component_names, #counts_as_sprint_start?, #created, #currently_in_status, #currently_in_status_category, #discard_changes_before, #discardable_before?, #done?, #due_date, #dump, #expedited?, #expedited_on_date?, #expedited_ranges, #find_or_create_status, #find_sprint_start_end, #first_resolution, #first_status_change_after_created, #first_time_added_to_active_sprint, #first_time_in_or_right_of_column, #first_time_in_status, #first_time_in_status_category, #first_time_label_added, #first_time_not_in_status, #first_time_visible_on_board, #fix_versions, #flow_efficiency_numbers, #in_done_status_at?, #in_initial_query?, #initialize, #inspect, #issue_links, #key, #key_as_i, #labels, #last_activity, #last_resolution, #looks_like_issue_key?, #most_recent_status_change, #parent_from_custom_fields, #parent_key, #parse_time, #priority_name, #priority_url, #raw_fields, #reasons_not_visible_on_board, #resolution, #sprint_entries_while_in_visible_status, #sprint_times_from_board, #sprint_times_from_issue, #sprints, #started_sprints, #started_stopped_dates, #started_stopped_times, #status_changes, #status_resolution_at_done, #still_in_or_right_of_column, #still_in_status, #still_in_status_category, #summary, #time_created, #type, #type_icon_url, #updated, #url, #visible_on_board?, #visible_status_changes_in_active_sprint
Constructor Details
This class inherits a constructor from Issue
Class Method Details
.empty(board:, created: DEFAULT_CREATED, key: nil, creation_status: nil, current_sprint_ids: nil) ⇒ Object
board has no default. Supplying one would mean either packaging a sample board or reading from this repo's spec directory, and neither belongs in a shipped gem. MockBoard.load builds one from the files jirametrics already downloads.
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/jirametrics/testing/mock_issue.rb', line 34 def empty board:, created: DEFAULT_CREATED, key: nil, creation_status: nil, current_sprint_ids: nil new( raw: raw_for( created: created, key: key || next_generated_key, creation_status: resolve_creation_status(creation_status, board), current_sprint_ids: current_sprint_ids, board_id: board.id ), board: board ) end |
Instance Method Details
#add_change(field:, value:, time:, value_id: nil, old_value: nil, old_value_id: nil, artificial: false, field_id: nil) ⇒ Object
The change is built and appended in one step, and returned for tests that need to hold on to it.
20 21 22 23 24 25 26 27 28 |
# File 'lib/jirametrics/testing/mock_issue.rb', line 20 def add_change field:, value:, time:, value_id: nil, old_value: nil, old_value_id: nil, artificial: false, field_id: nil change = MockChangeItem.new( issue: self, field: field, time: time, value: value, value_id: value_id, old_value: old_value, old_value_id: old_value_id, artificial: artificial, field_id: field_id ).to_change_item changes << change change end |