|
|
@ -102,48 +102,6 @@ describe ProjectsHelper, type: :helper do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe '#projects_level_list_json' do |
|
|
|
|
|
|
|
subject { helper.projects_level_list_json(projects).to_json } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let(:projects) { [] } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe 'with no project available' do |
|
|
|
|
|
|
|
it 'renders an empty projects document' do |
|
|
|
|
|
|
|
expect(subject).to have_json_size(0).at_path('projects') |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe 'with some projects available' do |
|
|
|
|
|
|
|
let(:projects) do |
|
|
|
|
|
|
|
p1 = build(:project, name: 'P1') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# a result from Project.project_level_list |
|
|
|
|
|
|
|
[{ project: p1, |
|
|
|
|
|
|
|
level: 0 }, |
|
|
|
|
|
|
|
{ project: build(:project, name: 'P2', parent: p1), |
|
|
|
|
|
|
|
level: 1 }, |
|
|
|
|
|
|
|
{ project: build(:project, name: 'P3'), |
|
|
|
|
|
|
|
level: 0 }] |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'renders a projects document with the size of 3 of type array' do |
|
|
|
|
|
|
|
expect(subject).to have_json_size(3).at_path('projects') |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'renders all three projects' do |
|
|
|
|
|
|
|
expect(subject).to be_json_eql('P1'.to_json).at_path('projects/0/name') |
|
|
|
|
|
|
|
expect(subject).to be_json_eql('P2'.to_json).at_path('projects/1/name') |
|
|
|
|
|
|
|
expect(subject).to be_json_eql('P3'.to_json).at_path('projects/2/name') |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'renders the project levels' do |
|
|
|
|
|
|
|
expect(subject).to be_json_eql(0.to_json).at_path('projects/0/level') |
|
|
|
|
|
|
|
expect(subject).to be_json_eql(1.to_json).at_path('projects/1/level') |
|
|
|
|
|
|
|
expect(subject).to be_json_eql(0.to_json).at_path('projects/2/level') |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe '#short_project_description' do |
|
|
|
describe '#short_project_description' do |
|
|
|
let(:project) { build_stubbed(:project, description: (('Abcd ' * 5) + "\n") * 11) } |
|
|
|
let(:project) { build_stubbed(:project, description: (('Abcd ' * 5) + "\n") * 11) } |
|
|
|
|
|
|
|
|
|
|
|