diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 15:40:28 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 15:40:28 +0000 |
commit | b595cb0c1dec83de5bdee18284abe86614bed33b (patch) | |
tree | 8c3d4540f193c5ff98019352f554e921b3a41a72 /spec/lib/gitlab/github_import/importer/events/reopened_spec.rb | |
parent | 2f9104a328fc8a4bddeaa4627b595166d24671d0 (diff) | |
download | gitlab-ce-b595cb0c1dec83de5bdee18284abe86614bed33b.tar.gz |
Add latest changes from gitlab-org/gitlab@15-2-stable-eev15.2.0-rc42
Diffstat (limited to 'spec/lib/gitlab/github_import/importer/events/reopened_spec.rb')
-rw-r--r-- | spec/lib/gitlab/github_import/importer/events/reopened_spec.rb | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/lib/gitlab/github_import/importer/events/reopened_spec.rb b/spec/lib/gitlab/github_import/importer/events/reopened_spec.rb new file mode 100644 index 00000000000..81653b0ecdc --- /dev/null +++ b/spec/lib/gitlab/github_import/importer/events/reopened_spec.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::GithubImport::Importer::Events::Reopened, :aggregate_failures do + subject(:importer) { described_class.new(project, user.id) } + + let_it_be(:project) { create(:project, :repository) } + let_it_be(:user) { create(:user) } + + let(:issue) { create(:issue, project: project) } + + let(:issue_event) do + Gitlab::GithubImport::Representation::IssueEvent.from_json_hash( + 'id' => 6501124486, + 'node_id' => 'CE_lADOHK9fA85If7x0zwAAAAGDf0mG', + 'url' => 'https://api.github.com/repos/elhowm/test-import/issues/events/6501124486', + 'actor' => { 'id' => 4, 'login' => 'alice' }, + 'event' => 'reopened', + 'created_at' => '2022-04-26 18:30:53 UTC', + 'issue_db_id' => issue.id + ) + end + + let(:expected_event_attrs) do + { + project_id: project.id, + author_id: user.id, + target_id: issue.id, + target_type: Issue.name, + action: 'reopened', + created_at: issue_event.created_at, + updated_at: issue_event.created_at + }.stringify_keys + end + + let(:expected_state_event_attrs) do + { + user_id: user.id, + state: 'reopened', + created_at: issue_event.created_at + }.stringify_keys + end + + it 'creates expected event and state event' do + importer.execute(issue_event) + + expect(issue.events.count).to eq 1 + expect(issue.events[0].attributes) + .to include expected_event_attrs + + expect(issue.resource_state_events.count).to eq 1 + expect(issue.resource_state_events[0].attributes) + .to include expected_state_event_attrs + end +end |