2019-07-26 18:40:36 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-04-24 20:53:49 +08:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe SmartAnnotations::TextPreview do
|
|
|
|
let(:subject) { described_class }
|
|
|
|
let(:user) { create :user }
|
2022-03-09 21:12:16 +08:00
|
|
|
let(:project) { create :project, name: 'my project', created_by: user }
|
2018-04-24 20:53:49 +08:00
|
|
|
let(:experiment) do
|
|
|
|
create :experiment, name: 'my experiment',
|
|
|
|
project: project,
|
|
|
|
created_by: user,
|
|
|
|
last_modified_by: user
|
|
|
|
end
|
2021-09-30 17:32:11 +08:00
|
|
|
let(:task) { create :my_module, name: 'task', experiment: experiment, created_by: experiment.created_by }
|
2018-04-24 20:53:49 +08:00
|
|
|
|
|
|
|
describe 'Project annotations' do
|
|
|
|
it 'returns a text snippet' do
|
|
|
|
snippet = subject.text(nil, 'prj', project)
|
|
|
|
expect(snippet).to eq(project.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'Experiment annotations' do
|
|
|
|
it 'returns a text snippet' do
|
|
|
|
snippet = subject.text(nil, 'exp', experiment)
|
|
|
|
expect(snippet).to eq(experiment.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'MyModule annotations' do
|
|
|
|
it 'returns a text snippet' do
|
|
|
|
snippet = subject.text(nil, 'tsk', task)
|
|
|
|
expect(snippet).to eq(task.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'Repository item annotations with type rep_item' do
|
|
|
|
it 'returns a html snippet' do
|
|
|
|
snippet = subject.text('my item', 'rep_item', nil)
|
|
|
|
expect(snippet).to eq('my item (deleted)')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|