diff --git a/spec/factories.rb b/spec/factories.rb index e046dc42d..7ff7e5a31 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -539,7 +539,7 @@ FactoryGirl.define do featured false end - factory :category do + trait :category do kind "category" end end diff --git a/spec/features/admin/tags_spec.rb b/spec/features/admin/tags_spec.rb index 3a2759490..90cfde90d 100644 --- a/spec/features/admin/tags_spec.rb +++ b/spec/features/admin/tags_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' feature 'Admin tags' do background do - @tag1 = create(:category) + @tag1 = create(:tag, :category) login_as(create(:administrator).user) end @@ -51,7 +51,7 @@ feature 'Admin tags' do end scenario 'Delete' do - tag2 = create(:category, name: "bad tag") + tag2 = create(:tag, :category, name: "bad tag") create(:debate, tag_list: tag2.name) visit admin_tags_path @@ -68,7 +68,7 @@ feature 'Admin tags' do end 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.hide diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index bd7cafee1..6fb298303 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -1345,8 +1345,8 @@ feature 'Proposals' do context "Summary" do scenario "Displays proposals grouped by category" do - create(:tag, kind: 'category', name: 'Culture') - create(:tag, kind: 'category', name: 'Social Services') + create(:tag, :category, name: 'Culture') + create(:tag, :category, name: 'Social Services') 3.times { create(:proposal, tag_list: 'Culture') } 3.times { create(:proposal, tag_list: 'Social Services') } @@ -1389,7 +1389,7 @@ feature 'Proposals' do end 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') } visit summary_proposals_path @@ -1398,7 +1398,7 @@ feature 'Proposals' do end 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: 'Worst', tag_list: 'culture').update_column(:confidence_score, 2) create(:proposal, title: 'Medium', tag_list: 'culture').update_column(:confidence_score, 5) @@ -1410,7 +1410,7 @@ feature 'Proposals' do end 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) proposal2 = create(:proposal, tag_list: 'culture', created_at: 5.days.ago) proposal3 = create(:proposal, tag_list: 'culture', created_at: 8.days.ago) diff --git a/spec/features/tags/budget_investments_spec.rb b/spec/features/tags/budget_investments_spec.rb index 4c978c740..ada2338b4 100644 --- a/spec/features/tags/budget_investments_spec.rb +++ b/spec/features/tags/budget_investments_spec.rb @@ -79,8 +79,8 @@ feature 'Tags' do scenario 'Category with category tags', :js do login_as(author) - education = create(:tag, name: 'Education', kind: 'category') - health = create(:tag, name: 'Health', kind: 'category') + education = create(:tag, :category, name: 'Education') + health = create(:tag, :category, name: 'Health') visit new_budget_investment_path(budget_id: budget.id) @@ -221,8 +221,8 @@ feature 'Tags' do context "Categories" do - let!(:tag1) { create(:tag, kind: 'category', name: 'Medio Ambiente') } - let!(:tag2) { create(:tag, kind: 'category', name: 'Economía') } + let!(:tag1) { create(:tag, :category, name: 'Medio Ambiente') } + let!(:tag2) { create(:tag, :category, name: 'Economía') } let!(:investment1) { create(:budget_investment, heading: heading, tag_list: 'Medio Ambiente') } let!(:investment2) { create(:budget_investment, heading: heading, tag_list: 'Medio Ambiente') } diff --git a/spec/features/tags/proposals_spec.rb b/spec/features/tags/proposals_spec.rb index dbab6a95f..cf5017d4f 100644 --- a/spec/features/tags/proposals_spec.rb +++ b/spec/features/tags/proposals_spec.rb @@ -91,8 +91,8 @@ feature 'Tags' do user = create(:user) login_as(user) - education = create(:tag, name: 'Education', kind: 'category') - health = create(:tag, name: 'Health', kind: 'category') + education = create(:tag, :category, name: 'Education') + health = create(:tag, :category, name: 'Health') visit new_proposal_path @@ -265,8 +265,8 @@ feature 'Tags' do context "Categories" do scenario 'Display category tags' do - create(:tag, kind: 'category', name: 'Medio Ambiente') - create(:tag, kind: 'category', name: 'Economía') + create(:tag, :category, name: 'Medio Ambiente') + create(:tag, :category, name: 'Economía') earth = create(:proposal, tag_list: 'Medio Ambiente') money = create(:proposal, tag_list: 'Economía') @@ -280,8 +280,8 @@ feature 'Tags' do end scenario "Filter by category tags" do - create(:tag, kind: 'category', name: 'Medio Ambiente') - create(:tag, kind: 'category', name: 'Economía') + create(:tag, :category, name: 'Medio Ambiente') + create(:tag, :category, name: 'Economía') proposal1 = create(:proposal, tag_list: 'Medio Ambiente') proposal2 = create(:proposal, tag_list: 'Medio Ambiente') diff --git a/spec/features/tags_spec.rb b/spec/features/tags_spec.rb index 4ca42f5eb..8497d5b63 100644 --- a/spec/features/tags_spec.rb +++ b/spec/features/tags_spec.rb @@ -148,8 +148,8 @@ feature 'Tags' do end scenario "scoped by category" do - create(:tag, kind: 'category', name: 'Medio Ambiente') - create(:tag, kind: 'category', name: 'Economía') + create(:tag, :category, name: 'Medio Ambiente') + create(:tag, :category, name: 'Economía') earth = create(:proposal, tag_list: 'Medio Ambiente, Agua') money = create(:proposal, tag_list: 'Economía, Corrupción') diff --git a/spec/lib/acts_as_taggable_on_spec.rb b/spec/lib/acts_as_taggable_on_spec.rb index d261bbad2..761e90553 100644 --- a/spec/lib/acts_as_taggable_on_spec.rb +++ b/spec/lib/acts_as_taggable_on_spec.rb @@ -77,7 +77,7 @@ describe 'ActsAsTaggableOn' do end 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.tag_list.add(tag) proposal.save diff --git a/spec/lib/graphql_spec.rb b/spec/lib/graphql_spec.rb index 725cc109a..b1e7073ea 100644 --- a/spec/lib/graphql_spec.rb +++ b/spec/lib/graphql_spec.rb @@ -207,7 +207,7 @@ describe 'ConsulSchema' do it 'only retruns tags with kind nil or category' do 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') 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 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') debate = create(:debate, tag_list: 'Parks, Health, Admin tag') @@ -453,7 +453,7 @@ describe 'ConsulSchema' do describe 'Tags' do it 'only display tags with kind nil or category' do 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') proposal = create(:proposal, tag_list: 'Parks') diff --git a/spec/models/proposal_spec.rb b/spec/models/proposal_spec.rb index f60bff18c..d8c467974 100644 --- a/spec/models/proposal_spec.rb +++ b/spec/models/proposal_spec.rb @@ -703,14 +703,14 @@ describe Proposal do context "categories" 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') expect(Proposal.for_summary.values.flatten).to include(proposal) end 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') expect(Proposal.for_summary.values.flatten).to_not include(proposal) @@ -735,19 +735,19 @@ describe Proposal do end 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') 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') + create(:tag, :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 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, 10) create(:proposal, tag_list: 'culture').update_column(:confidence_score, 5) @@ -760,9 +760,9 @@ describe Proposal do end it "should order groups alphabetically" do - create(:tag, kind: 'category', name: 'health') - create(:tag, kind: 'category', name: 'culture') - create(:tag, kind: 'category', name: 'social services') + create(:tag, :category, name: 'health') + create(:tag, :category, name: 'culture') + create(:tag, :category, name: 'social services') health_proposal = create(:proposal, tag_list: 'health') culture_proposal = create(:proposal, tag_list: 'culture') @@ -776,8 +776,8 @@ describe Proposal do end it "should return proposals grouped by tag" do - create(:tag, kind: 'category', name: 'culture') - create(:tag, kind: 'category', name: 'health') + create(:tag, :category, name: 'culture') + create(:tag, :category, name: 'health') proposal1 = create(:proposal, tag_list: 'culture') proposal2 = create(:proposal, tag_list: 'culture') diff --git a/spec/models/tag_cloud_spec.rb b/spec/models/tag_cloud_spec.rb index 5de136ae1..c99e6a919 100644 --- a/spec/models/tag_cloud_spec.rb +++ b/spec/models/tag_cloud_spec.rb @@ -41,8 +41,8 @@ describe TagCloud do end it "does not return category tags" do - create(:tag, kind: 'category', name: 'Education') - create(:tag, kind: 'category', name: 'Participation') + create(:tag, :category, name: 'Education') + create(:tag, :category, name: 'Participation') create(:proposal, tag_list: 'education, parks') create(:proposal, tag_list: 'participation, water') @@ -65,8 +65,8 @@ describe TagCloud do end it "returns tags scoped by category" do - create(:tag, kind: 'category', name: 'Education') - create(:tag, kind: 'category', name: 'Participation') + create(:tag, :category, name: 'Education') + create(:tag, :category, name: 'Participation') create(:proposal, tag_list: 'education, parks') create(:proposal, tag_list: 'participation, water')