2017-08-17 22:00:37 +05:30
|
|
|
shared_examples 'issuables list meta-data' do |issuable_type, action = nil|
|
|
|
|
before do
|
|
|
|
@issuable_ids = []
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
%w[fix improve/awesome].each do |source_branch|
|
2017-08-17 22:00:37 +05:30
|
|
|
issuable =
|
|
|
|
if issuable_type == :issue
|
|
|
|
create(issuable_type, project: project)
|
|
|
|
else
|
2018-03-17 18:26:18 +05:30
|
|
|
create(issuable_type, source_project: project, source_branch: source_branch)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
@issuable_ids << issuable.id
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "creates indexed meta-data object for issuable notes and votes count" do
|
|
|
|
if action
|
|
|
|
get action
|
|
|
|
else
|
|
|
|
get :index, namespace_id: project.namespace, project_id: project
|
|
|
|
end
|
|
|
|
|
|
|
|
meta_data = assigns(:issuable_meta_data)
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
aggregate_failures do
|
|
|
|
expect(meta_data.keys).to match_array(@issuable_ids)
|
|
|
|
expect(meta_data.values).to all(be_kind_of(Issuable::IssuableMeta))
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "when given empty collection" do
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:project2) { create(:project, :public) }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
it "doesn't execute any queries with false conditions" do
|
|
|
|
get_action =
|
|
|
|
if action
|
|
|
|
proc { get action }
|
|
|
|
else
|
|
|
|
proc { get :index, namespace_id: project2.namespace, project_id: project2 }
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(&get_action).not_to make_queries_matching(/WHERE (?:1=0|0=1)/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|