diff --git a/spec/controllers/steps_controller_spec.rb b/spec/controllers/steps_controller_spec.rb index d67049212..9a5aae59e 100644 --- a/spec/controllers/steps_controller_spec.rb +++ b/spec/controllers/steps_controller_spec.rb @@ -20,7 +20,7 @@ describe StepsController, type: :controller do context 'when in protocol repository' do let(:params) do { protocol_id: protocol_repo.id, - step: { name: 'test', description: 'description' } } + step: { name: 'test', description: 'description' }, position: 1 } end it 'calls create activity for creating step in protocol repository' do @@ -40,7 +40,7 @@ describe StepsController, type: :controller do context 'when in protocol on task' do let(:params) do { protocol_id: my_module.protocol.id, - step: { name: 'test', description: 'description' } } + step: { name: 'test', description: 'description' }, position: 1 } end it 'calls create activity for creating step in protocol on task' do diff --git a/spec/factories/team_repositories.rb b/spec/factories/team_shared_objects.rb similarity index 76% rename from spec/factories/team_repositories.rb rename to spec/factories/team_shared_objects.rb index b7db29b1b..23cc8ab15 100644 --- a/spec/factories/team_repositories.rb +++ b/spec/factories/team_shared_objects.rb @@ -1,7 +1,9 @@ # frozen_string_literal: true +# frozen_string_literal: true + FactoryBot.define do - factory :team_repository do + factory :team_shared_object do repository trait :read do permission_level { :shared_read } diff --git a/spec/models/team_repository_spec.rb b/spec/models/team_repository_spec.rb deleted file mode 100644 index 954f5161d..000000000 --- a/spec/models/team_repository_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -describe TeamRepository, type: :model do - let(:user) { create :user } - let(:team) { create :team, created_by: user } - let(:another_team) { create :team, created_by: user } - let(:repository) { create :repository, team: team, created_by: user } - let(:team_repository) { build :team_repository, :read, team: another_team, repository: repository } - - it 'is valid' do - expect(team_repository).to be_valid - end - - describe 'Validations' do - describe '#permission_level' do - it { is_expected.to validate_presence_of(:permission_level) } - end - describe '#repository' do - it { expect(team_repository).to validate_uniqueness_of(:repository).scoped_to(:team_id) } - end - describe '#team' do - it { expect(team_repository).to validate_uniqueness_of(:repository).scoped_to(:team_id) } - - it 'invalid when repo team is same as sharring team' do - repo = create :repository, team: team, created_by: user - invalid_team_repository = build :team_repository, :read, repository: repo, team: repo.team - - expect(invalid_team_repository).to be_invalid - end - end - end - - describe 'Associations' do - it { is_expected.to belong_to(:team) } - it { is_expected.to belong_to(:repository) } - end -end diff --git a/spec/models/team_shared_object_spec.rb b/spec/models/team_shared_object_spec.rb new file mode 100644 index 000000000..bd33c089b --- /dev/null +++ b/spec/models/team_shared_object_spec.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe TeamSharedObject, type: :model do + let(:user) { create :user } + let(:team) { create :team, created_by: user } + let(:another_team) { create :team, created_by: user } + let(:repository) { create :repository, team: team, created_by: user } + let(:team_shared_object) { build :team_shared_object, :read, team: another_team, shared_repository: repository } + + it 'is valid' do + expect(team_shared_object).to be_valid + end + + + describe 'Associations' do + it { is_expected.to belong_to(:team) } + it { is_expected.to belong_to(:shared_repository) } + it { is_expected.to belong_to(:shared_object) } + end +end diff --git a/spec/services/repositories/multiple_share_update_service_spec.rb b/spec/services/repositories/multiple_share_update_service_spec.rb index 9a410d270..e8115fe62 100644 --- a/spec/services/repositories/multiple_share_update_service_spec.rb +++ b/spec/services/repositories/multiple_share_update_service_spec.rb @@ -18,7 +18,7 @@ describe Repositories::MultipleShareUpdateService do end it 'adds TeamRepository record' do - expect { service_call }.to change { TeamRepository.count }.by(1) + expect { service_call }.to change { TeamSharedObject.count }.by(1) end it 'adds Activity record' do @@ -48,13 +48,13 @@ describe Repositories::MultipleShareUpdateService do end it 'removes TeamRepository record' do - create :team_repository, :write, team: team2, repository: repository + create :team_shared_object, :write, team: team2, shared_repository: repository expect { service_call }.to change { TeamRepository.count }.by(-1) end it 'adds Activity record' do - create :team_repository, :write, team: team2, repository: repository + create :team_shared_object, :write, team: team2, shared_repository: repository expect { service_call }.to(change { Activity.all.count }.by(1)) end @@ -84,13 +84,13 @@ describe Repositories::MultipleShareUpdateService do end it 'updates permission for share record' do - tr = create :team_repository, :write, team: team2, repository: repository + tr = create :team_shared_object, :write, team: team2, shared_repository: repository expect { service_call }.to(change { tr.reload.permission_level }) end it 'adds Activity record' do - create :team_repository, :write, team: team2, repository: repository + create :team_shared_object, :write, team: team2, shared_repository: repository expect { service_call }.to(change { Activity.all.count }.by(1)) end diff --git a/spec/services/smart_annotations/html_preview_spec.rb b/spec/services/smart_annotations/html_preview_spec.rb index d9a443081..a797c0464 100644 --- a/spec/services/smart_annotations/html_preview_spec.rb +++ b/spec/services/smart_annotations/html_preview_spec.rb @@ -18,7 +18,7 @@ describe SmartAnnotations::HtmlPreview do it 'returns a html snippet' do snippet = subject.html(nil, 'prj', project) expect(snippet).to eq( - "" \ + "" \ "Prjmy project" ) end @@ -28,7 +28,7 @@ describe SmartAnnotations::HtmlPreview do it 'returns a html snippet' do snippet = subject.html(nil, 'exp', experiment) expect(snippet).to eq( - "" \ + "" \ "Expmy experiment" ) end @@ -38,7 +38,7 @@ describe SmartAnnotations::HtmlPreview do it 'returns a html snippet' do snippet = subject.html(nil, 'tsk', task) expect(snippet).to eq( - "" \ + "" \ "Tsktask" ) end diff --git a/spec/services/smart_annotations/tag_to_html_spec.rb b/spec/services/smart_annotations/tag_to_html_spec.rb index 2252b6880..35c450b8d 100644 --- a/spec/services/smart_annotations/tag_to_html_spec.rb +++ b/spec/services/smart_annotations/tag_to_html_spec.rb @@ -25,7 +25,7 @@ describe SmartAnnotations::TagToHtml do describe 'Parsed text' do it 'returns a existing string with smart annotation' do expect(subject.html).to eq( - "My annotation of " \ + "My annotation of " \ "Prjmy project" ) end