2017-01-23 20:40:25 +00:00
|
|
|
shared_examples 'issuables list meta-data' do |issuable_type, action = nil|
|
|
|
|
before do
|
|
|
|
@issuable_ids = []
|
|
|
|
|
2017-08-09 13:41:45 +00:00
|
|
|
%w[fix improve/awesome].each do |source_branch|
|
2017-02-22 15:10:32 +00:00
|
|
|
issuable =
|
|
|
|
if issuable_type == :issue
|
|
|
|
create(issuable_type, project: project)
|
|
|
|
else
|
2017-08-09 13:41:45 +00:00
|
|
|
create(issuable_type, source_project: project, source_branch: source_branch)
|
2017-02-22 15:10:32 +00:00
|
|
|
end
|
2017-01-23 20:40:25 +00:00
|
|
|
|
|
|
|
@issuable_ids << issuable.id
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "creates indexed meta-data object for issuable notes and votes count" do
|
|
|
|
if action
|
|
|
|
get action
|
|
|
|
else
|
2017-02-23 23:55:01 +00:00
|
|
|
get :index, namespace_id: project.namespace, project_id: project
|
2017-01-23 20:40:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
meta_data = assigns(:issuable_meta_data)
|
|
|
|
|
2017-08-01 16:55:57 +00:00
|
|
|
aggregate_failures do
|
|
|
|
expect(meta_data.keys).to match_array(@issuable_ids)
|
|
|
|
expect(meta_data.values).to all(be_kind_of(Issuable::IssuableMeta))
|
2017-01-23 20:40:25 +00:00
|
|
|
end
|
|
|
|
end
|
2017-04-04 10:54:58 +00:00
|
|
|
|
|
|
|
describe "when given empty collection" do
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project2) { create(:project, :public) }
|
2017-04-04 10:54:58 +00:00
|
|
|
|
|
|
|
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
|
2017-01-23 20:40:25 +00:00
|
|
|
end
|