Merge pull request #5087 from G-Chubinidze/gc_SCI_7913

Fix automated tests [SCI-7913]
This commit is contained in:
artoscinote 2023-03-07 09:43:42 +01:00 committed by GitHub
commit 5e385a2bc0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 36 additions and 51 deletions

View file

@ -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

View file

@ -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 }

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -18,7 +18,7 @@ describe SmartAnnotations::HtmlPreview do
it 'returns a html snippet' do
snippet = subject.html(nil, 'prj', project)
expect(snippet).to eq(
"<a href='/projects/#{project.id}'>" \
"<a class='sa-link' href='/projects/#{project.id}'>" \
"<span class='sa-type'>Prj</span>my project</a>"
)
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(
"<a href='/experiments/#{experiment.id}/canvas'>" \
"<a class='sa-link' href='/experiments/#{experiment.id}/my_modules'>" \
"<span class='sa-type'>Exp</span>my experiment</a>"
)
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(
"<a href='/modules/#{task.id}/protocols'>" \
"<a class='sa-link' href='/modules/#{task.id}/protocols'>" \
"<span class='sa-type'>Tsk</span>task</a>"
)
end

View file

@ -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 <a href='/projects/#{project.id}'>" \
"My annotation of <a class='sa-link' href='/projects/#{project.id}'>" \
"<span class='sa-type'>Prj</span>my project</a>"
)
end