adds more comprehensive specs
This commit is contained in:
@@ -657,6 +657,31 @@ describe Proposal do
|
|||||||
expect(Proposal.for_summary.values.flatten).to_not include(proposal)
|
expect(Proposal.for_summary.values.flatten).to_not include(proposal)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should return proposals created this week" do
|
||||||
|
create(:tag, kind: 'category', name: 'Culture')
|
||||||
|
proposal = create(:proposal, tag_list: 'Culture')
|
||||||
|
expect(Proposal.for_summary.values.flatten).to include(proposal)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should not return proposals created more than a week ago" do
|
||||||
|
create(:tag, kind: 'category', name: 'Culture')
|
||||||
|
proposal = create(:proposal, tag_list: 'Culture', created_at: 8.days.ago)
|
||||||
|
expect(Proposal.for_summary.values.flatten).to_not include(proposal)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should order by votes" do
|
||||||
|
create(:tag, kind: 'category', name: 'Culture')
|
||||||
|
create(:proposal, tag_list: 'Culture').update_column(:confidence_score, 2)
|
||||||
|
create(:proposal, tag_list: 'Culture').update_column(:confidence_score, 10)
|
||||||
|
create(:proposal, tag_list: 'Culture').update_column(:confidence_score, 5)
|
||||||
|
|
||||||
|
results = Proposal.for_summary.values.flatten
|
||||||
|
|
||||||
|
expect(results.first.confidence_score).to be(10)
|
||||||
|
expect(results.second.confidence_score).to be(5)
|
||||||
|
expect(results.third.confidence_score).to be(2)
|
||||||
|
end
|
||||||
|
|
||||||
it "should return proposals grouped by tag" do
|
it "should return proposals grouped by tag" do
|
||||||
create(:tag, kind: 'category', name: 'Culture')
|
create(:tag, kind: 'category', name: 'Culture')
|
||||||
create(:tag, kind: 'category', name: 'Health')
|
create(:tag, kind: 'category', name: 'Health')
|
||||||
|
|||||||
Reference in New Issue
Block a user