2017-03-16 09:28:14 -04:00
|
|
|
require "spec_helper"
|
|
|
|
|
|
|
|
describe TodosHelper do
|
2017-06-09 18:12:00 -04:00
|
|
|
describe '#todos_count_format' do
|
|
|
|
it 'shows fuzzy count for 100 or more items' do
|
|
|
|
expect(helper.todos_count_format(100)).to eq '99+'
|
|
|
|
expect(helper.todos_count_format(1000)).to eq '99+'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows exact count for 99 or fewer items' do
|
|
|
|
expect(helper.todos_count_format(99)).to eq '99'
|
|
|
|
expect(helper.todos_count_format(50)).to eq '50'
|
|
|
|
expect(helper.todos_count_format(1)).to eq '1'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-03-16 09:28:14 -04:00
|
|
|
describe '#todo_projects_options' do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:projects) { create_list(:project, 3) }
|
2017-03-16 09:28:14 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
it 'returns users authorised projects in json format' do
|
|
|
|
projects.first.add_developer(user)
|
|
|
|
projects.second.add_developer(user)
|
|
|
|
|
|
|
|
allow(helper).to receive(:current_user).and_return(user)
|
|
|
|
|
|
|
|
expected_results = [
|
|
|
|
{ 'id' => '', 'text' => 'Any Project' },
|
|
|
|
{ 'id' => projects.second.id, 'text' => projects.second.name_with_namespace },
|
|
|
|
{ 'id' => projects.first.id, 'text' => projects.first.name_with_namespace }
|
|
|
|
]
|
|
|
|
|
|
|
|
expect(JSON.parse(helper.todo_projects_options)).to match_array(expected_results)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|