Replace category factory in tags with a trait
This commit is contained in:
@@ -539,7 +539,7 @@ FactoryGirl.define do
|
|||||||
featured false
|
featured false
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :category do
|
trait :category do
|
||||||
kind "category"
|
kind "category"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'rails_helper'
|
|||||||
feature 'Admin tags' do
|
feature 'Admin tags' do
|
||||||
|
|
||||||
background do
|
background do
|
||||||
@tag1 = create(:category)
|
@tag1 = create(:tag, :category)
|
||||||
login_as(create(:administrator).user)
|
login_as(create(:administrator).user)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ feature 'Admin tags' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Delete' do
|
scenario 'Delete' do
|
||||||
tag2 = create(:category, name: "bad tag")
|
tag2 = create(:tag, :category, name: "bad tag")
|
||||||
create(:debate, tag_list: tag2.name)
|
create(:debate, tag_list: tag2.name)
|
||||||
visit admin_tags_path
|
visit admin_tags_path
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ feature 'Admin tags' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Delete tag with hidden taggables' do
|
scenario 'Delete tag with hidden taggables' do
|
||||||
tag2 = create(:category, name: "bad tag")
|
tag2 = create(:tag, :category, name: "bad tag")
|
||||||
debate = create(:debate, tag_list: tag2.name)
|
debate = create(:debate, tag_list: tag2.name)
|
||||||
debate.hide
|
debate.hide
|
||||||
|
|
||||||
|
|||||||
@@ -1345,8 +1345,8 @@ feature 'Proposals' do
|
|||||||
context "Summary" do
|
context "Summary" do
|
||||||
|
|
||||||
scenario "Displays proposals grouped by category" do
|
scenario "Displays proposals grouped by category" do
|
||||||
create(:tag, kind: 'category', name: 'Culture')
|
create(:tag, :category, name: 'Culture')
|
||||||
create(:tag, kind: 'category', name: 'Social Services')
|
create(:tag, :category, name: 'Social Services')
|
||||||
|
|
||||||
3.times { create(:proposal, tag_list: 'Culture') }
|
3.times { create(:proposal, tag_list: 'Culture') }
|
||||||
3.times { create(:proposal, tag_list: 'Social Services') }
|
3.times { create(:proposal, tag_list: 'Social Services') }
|
||||||
@@ -1389,7 +1389,7 @@ feature 'Proposals' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Displays a maximum of 3 proposals per category" do
|
scenario "Displays a maximum of 3 proposals per category" do
|
||||||
create(:tag, kind: 'category', name: 'culture')
|
create(:tag, :category, name: 'culture')
|
||||||
4.times { create(:proposal, tag_list: 'culture') }
|
4.times { create(:proposal, tag_list: 'culture') }
|
||||||
|
|
||||||
visit summary_proposals_path
|
visit summary_proposals_path
|
||||||
@@ -1398,7 +1398,7 @@ feature 'Proposals' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Orders proposals by votes" do
|
scenario "Orders proposals by votes" do
|
||||||
create(:tag, kind: 'category', name: 'culture')
|
create(:tag, :category, name: 'culture')
|
||||||
create(:proposal, title: 'Best', tag_list: 'culture').update_column(:confidence_score, 10)
|
create(:proposal, title: 'Best', tag_list: 'culture').update_column(:confidence_score, 10)
|
||||||
create(:proposal, title: 'Worst', tag_list: 'culture').update_column(:confidence_score, 2)
|
create(:proposal, title: 'Worst', tag_list: 'culture').update_column(:confidence_score, 2)
|
||||||
create(:proposal, title: 'Medium', tag_list: 'culture').update_column(:confidence_score, 5)
|
create(:proposal, title: 'Medium', tag_list: 'culture').update_column(:confidence_score, 5)
|
||||||
@@ -1410,7 +1410,7 @@ feature 'Proposals' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Displays proposals from last week" do
|
scenario "Displays proposals from last week" do
|
||||||
create(:tag, kind: 'category', name: 'culture')
|
create(:tag, :category, name: 'culture')
|
||||||
proposal1 = create(:proposal, tag_list: 'culture', created_at: 1.day.ago)
|
proposal1 = create(:proposal, tag_list: 'culture', created_at: 1.day.ago)
|
||||||
proposal2 = create(:proposal, tag_list: 'culture', created_at: 5.days.ago)
|
proposal2 = create(:proposal, tag_list: 'culture', created_at: 5.days.ago)
|
||||||
proposal3 = create(:proposal, tag_list: 'culture', created_at: 8.days.ago)
|
proposal3 = create(:proposal, tag_list: 'culture', created_at: 8.days.ago)
|
||||||
|
|||||||
@@ -79,8 +79,8 @@ feature 'Tags' do
|
|||||||
scenario 'Category with category tags', :js do
|
scenario 'Category with category tags', :js do
|
||||||
login_as(author)
|
login_as(author)
|
||||||
|
|
||||||
education = create(:tag, name: 'Education', kind: 'category')
|
education = create(:tag, :category, name: 'Education')
|
||||||
health = create(:tag, name: 'Health', kind: 'category')
|
health = create(:tag, :category, name: 'Health')
|
||||||
|
|
||||||
visit new_budget_investment_path(budget_id: budget.id)
|
visit new_budget_investment_path(budget_id: budget.id)
|
||||||
|
|
||||||
@@ -221,8 +221,8 @@ feature 'Tags' do
|
|||||||
|
|
||||||
context "Categories" do
|
context "Categories" do
|
||||||
|
|
||||||
let!(:tag1) { create(:tag, kind: 'category', name: 'Medio Ambiente') }
|
let!(:tag1) { create(:tag, :category, name: 'Medio Ambiente') }
|
||||||
let!(:tag2) { create(:tag, kind: 'category', name: 'Economía') }
|
let!(:tag2) { create(:tag, :category, name: 'Economía') }
|
||||||
|
|
||||||
let!(:investment1) { create(:budget_investment, heading: heading, tag_list: 'Medio Ambiente') }
|
let!(:investment1) { create(:budget_investment, heading: heading, tag_list: 'Medio Ambiente') }
|
||||||
let!(:investment2) { create(:budget_investment, heading: heading, tag_list: 'Medio Ambiente') }
|
let!(:investment2) { create(:budget_investment, heading: heading, tag_list: 'Medio Ambiente') }
|
||||||
|
|||||||
@@ -91,8 +91,8 @@ feature 'Tags' do
|
|||||||
user = create(:user)
|
user = create(:user)
|
||||||
login_as(user)
|
login_as(user)
|
||||||
|
|
||||||
education = create(:tag, name: 'Education', kind: 'category')
|
education = create(:tag, :category, name: 'Education')
|
||||||
health = create(:tag, name: 'Health', kind: 'category')
|
health = create(:tag, :category, name: 'Health')
|
||||||
|
|
||||||
visit new_proposal_path
|
visit new_proposal_path
|
||||||
|
|
||||||
@@ -265,8 +265,8 @@ feature 'Tags' do
|
|||||||
context "Categories" do
|
context "Categories" do
|
||||||
|
|
||||||
scenario 'Display category tags' do
|
scenario 'Display category tags' do
|
||||||
create(:tag, kind: 'category', name: 'Medio Ambiente')
|
create(:tag, :category, name: 'Medio Ambiente')
|
||||||
create(:tag, kind: 'category', name: 'Economía')
|
create(:tag, :category, name: 'Economía')
|
||||||
|
|
||||||
earth = create(:proposal, tag_list: 'Medio Ambiente')
|
earth = create(:proposal, tag_list: 'Medio Ambiente')
|
||||||
money = create(:proposal, tag_list: 'Economía')
|
money = create(:proposal, tag_list: 'Economía')
|
||||||
@@ -280,8 +280,8 @@ feature 'Tags' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Filter by category tags" do
|
scenario "Filter by category tags" do
|
||||||
create(:tag, kind: 'category', name: 'Medio Ambiente')
|
create(:tag, :category, name: 'Medio Ambiente')
|
||||||
create(:tag, kind: 'category', name: 'Economía')
|
create(:tag, :category, name: 'Economía')
|
||||||
|
|
||||||
proposal1 = create(:proposal, tag_list: 'Medio Ambiente')
|
proposal1 = create(:proposal, tag_list: 'Medio Ambiente')
|
||||||
proposal2 = create(:proposal, tag_list: 'Medio Ambiente')
|
proposal2 = create(:proposal, tag_list: 'Medio Ambiente')
|
||||||
|
|||||||
@@ -148,8 +148,8 @@ feature 'Tags' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "scoped by category" do
|
scenario "scoped by category" do
|
||||||
create(:tag, kind: 'category', name: 'Medio Ambiente')
|
create(:tag, :category, name: 'Medio Ambiente')
|
||||||
create(:tag, kind: 'category', name: 'Economía')
|
create(:tag, :category, name: 'Economía')
|
||||||
|
|
||||||
earth = create(:proposal, tag_list: 'Medio Ambiente, Agua')
|
earth = create(:proposal, tag_list: 'Medio Ambiente, Agua')
|
||||||
money = create(:proposal, tag_list: 'Economía, Corrupción')
|
money = create(:proposal, tag_list: 'Economía, Corrupción')
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ describe 'ActsAsTaggableOn' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "returns tags whose kind is 'category' and have at least one tagging whose taggable is not hidden" do
|
it "returns tags whose kind is 'category' and have at least one tagging whose taggable is not hidden" do
|
||||||
tag = create(:tag, kind: 'category')
|
tag = create(:tag, :category)
|
||||||
proposal = create(:proposal)
|
proposal = create(:proposal)
|
||||||
proposal.tag_list.add(tag)
|
proposal.tag_list.add(tag)
|
||||||
proposal.save
|
proposal.save
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ describe 'ConsulSchema' do
|
|||||||
|
|
||||||
it 'only retruns tags with kind nil or category' do
|
it 'only retruns tags with kind nil or category' do
|
||||||
tag = create(:tag, name: 'Parks')
|
tag = create(:tag, name: 'Parks')
|
||||||
category_tag = create(:tag, name: 'Health', kind: 'category')
|
category_tag = create(:tag, :category, name: 'Health')
|
||||||
admin_tag = create(:tag, name: 'Admin tag', kind: 'admin')
|
admin_tag = create(:tag, name: 'Admin tag', kind: 'admin')
|
||||||
|
|
||||||
proposal = create(:proposal, tag_list: 'Parks, Health, Admin tag')
|
proposal = create(:proposal, tag_list: 'Parks, Health, Admin tag')
|
||||||
@@ -269,7 +269,7 @@ describe 'ConsulSchema' do
|
|||||||
|
|
||||||
it 'only retruns tags with kind nil or category' do
|
it 'only retruns tags with kind nil or category' do
|
||||||
tag = create(:tag, name: 'Parks')
|
tag = create(:tag, name: 'Parks')
|
||||||
category_tag = create(:tag, name: 'Health', kind: 'category')
|
category_tag = create(:tag, :category, name: 'Health')
|
||||||
admin_tag = create(:tag, name: 'Admin tag', kind: 'admin')
|
admin_tag = create(:tag, name: 'Admin tag', kind: 'admin')
|
||||||
|
|
||||||
debate = create(:debate, tag_list: 'Parks, Health, Admin tag')
|
debate = create(:debate, tag_list: 'Parks, Health, Admin tag')
|
||||||
@@ -453,7 +453,7 @@ describe 'ConsulSchema' do
|
|||||||
describe 'Tags' do
|
describe 'Tags' do
|
||||||
it 'only display tags with kind nil or category' do
|
it 'only display tags with kind nil or category' do
|
||||||
tag = create(:tag, name: 'Parks')
|
tag = create(:tag, name: 'Parks')
|
||||||
category_tag = create(:tag, name: 'Health', kind: 'category')
|
category_tag = create(:tag, :category, name: 'Health')
|
||||||
admin_tag = create(:tag, name: 'Admin tag', kind: 'admin')
|
admin_tag = create(:tag, name: 'Admin tag', kind: 'admin')
|
||||||
|
|
||||||
proposal = create(:proposal, tag_list: 'Parks')
|
proposal = create(:proposal, tag_list: 'Parks')
|
||||||
|
|||||||
@@ -703,14 +703,14 @@ describe Proposal do
|
|||||||
context "categories" do
|
context "categories" do
|
||||||
|
|
||||||
it "should return proposals tagged with a category" do
|
it "should return proposals tagged with a category" do
|
||||||
create(:tag, kind: 'category', name: 'culture')
|
create(:tag, :category, name: 'culture')
|
||||||
proposal = create(:proposal, tag_list: 'culture')
|
proposal = create(:proposal, tag_list: 'culture')
|
||||||
|
|
||||||
expect(Proposal.for_summary.values.flatten).to include(proposal)
|
expect(Proposal.for_summary.values.flatten).to include(proposal)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not return proposals tagged without a category" do
|
it "should not return proposals tagged without a category" do
|
||||||
create(:tag, kind: 'category', name: 'culture')
|
create(:tag, :category, name: 'culture')
|
||||||
proposal = create(:proposal, tag_list: 'parks')
|
proposal = create(:proposal, tag_list: 'parks')
|
||||||
|
|
||||||
expect(Proposal.for_summary.values.flatten).to_not include(proposal)
|
expect(Proposal.for_summary.values.flatten).to_not include(proposal)
|
||||||
@@ -735,19 +735,19 @@ describe Proposal do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "should return proposals created this week" do
|
it "should return proposals created this week" do
|
||||||
create(:tag, kind: 'category', name: 'culture')
|
create(:tag, :category, name: 'culture')
|
||||||
proposal = create(:proposal, tag_list: 'culture')
|
proposal = create(:proposal, tag_list: 'culture')
|
||||||
expect(Proposal.for_summary.values.flatten).to include(proposal)
|
expect(Proposal.for_summary.values.flatten).to include(proposal)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not return proposals created more than a week ago" do
|
it "should not return proposals created more than a week ago" do
|
||||||
create(:tag, kind: 'category', name: 'culture')
|
create(:tag, :category, name: 'culture')
|
||||||
proposal = create(:proposal, tag_list: 'culture', created_at: 8.days.ago)
|
proposal = create(:proposal, tag_list: 'culture', created_at: 8.days.ago)
|
||||||
expect(Proposal.for_summary.values.flatten).to_not include(proposal)
|
expect(Proposal.for_summary.values.flatten).to_not include(proposal)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should order proposals by votes" do
|
it "should order proposals by votes" do
|
||||||
create(:tag, kind: 'category', name: 'culture')
|
create(:tag, :category, name: 'culture')
|
||||||
create(:proposal, tag_list: 'culture').update_column(:confidence_score, 2)
|
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, 10)
|
||||||
create(:proposal, tag_list: 'culture').update_column(:confidence_score, 5)
|
create(:proposal, tag_list: 'culture').update_column(:confidence_score, 5)
|
||||||
@@ -760,9 +760,9 @@ describe Proposal do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "should order groups alphabetically" do
|
it "should order groups alphabetically" do
|
||||||
create(:tag, kind: 'category', name: 'health')
|
create(:tag, :category, name: 'health')
|
||||||
create(:tag, kind: 'category', name: 'culture')
|
create(:tag, :category, name: 'culture')
|
||||||
create(:tag, kind: 'category', name: 'social services')
|
create(:tag, :category, name: 'social services')
|
||||||
|
|
||||||
health_proposal = create(:proposal, tag_list: 'health')
|
health_proposal = create(:proposal, tag_list: 'health')
|
||||||
culture_proposal = create(:proposal, tag_list: 'culture')
|
culture_proposal = create(:proposal, tag_list: 'culture')
|
||||||
@@ -776,8 +776,8 @@ describe Proposal do
|
|||||||
end
|
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, :category, name: 'culture')
|
||||||
create(:tag, kind: 'category', name: 'health')
|
create(:tag, :category, name: 'health')
|
||||||
|
|
||||||
proposal1 = create(:proposal, tag_list: 'culture')
|
proposal1 = create(:proposal, tag_list: 'culture')
|
||||||
proposal2 = create(:proposal, tag_list: 'culture')
|
proposal2 = create(:proposal, tag_list: 'culture')
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ describe TagCloud do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "does not return category tags" do
|
it "does not return category tags" do
|
||||||
create(:tag, kind: 'category', name: 'Education')
|
create(:tag, :category, name: 'Education')
|
||||||
create(:tag, kind: 'category', name: 'Participation')
|
create(:tag, :category, name: 'Participation')
|
||||||
|
|
||||||
create(:proposal, tag_list: 'education, parks')
|
create(:proposal, tag_list: 'education, parks')
|
||||||
create(:proposal, tag_list: 'participation, water')
|
create(:proposal, tag_list: 'participation, water')
|
||||||
@@ -65,8 +65,8 @@ describe TagCloud do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "returns tags scoped by category" do
|
it "returns tags scoped by category" do
|
||||||
create(:tag, kind: 'category', name: 'Education')
|
create(:tag, :category, name: 'Education')
|
||||||
create(:tag, kind: 'category', name: 'Participation')
|
create(:tag, :category, name: 'Participation')
|
||||||
|
|
||||||
create(:proposal, tag_list: 'education, parks')
|
create(:proposal, tag_list: 'education, parks')
|
||||||
create(:proposal, tag_list: 'participation, water')
|
create(:proposal, tag_list: 'participation, water')
|
||||||
|
|||||||
Reference in New Issue
Block a user