Activates & updates deactivated specs

This commit is contained in:
kikito
2016-02-04 20:06:49 +01:00
parent d452dcda5b
commit bc5ed945b4
2 changed files with 48 additions and 62 deletions

View File

@@ -778,32 +778,32 @@ feature 'Debates' do
end end
end end
xscenario "Order by relevance by default", :js do scenario "Order by relevance by default", :js do
debate1 = create(:debate, title: "Show you got", cached_votes_up: 10) debate1 = create(:debate, title: "Show you got", cached_votes_up: 10)
debate2 = create(:debate, title: "Show what you got", cached_votes_up: 1) debate2 = create(:debate, title: "Show what you got", cached_votes_up: 1)
debate3 = create(:debate, title: "Show you got", cached_votes_up: 100) debate3 = create(:debate, title: "Show you got", cached_votes_up: 100)
visit debates_path visit debates_path
fill_in "search", with: "Show what you got" fill_in "search", with: "Show you got"
click_button "Search" click_button "Search"
expect(page).to have_selector("a.active", text: "relevance") expect(page).to have_selector("a.active", text: "relevance")
within("#debates") do within("#debates") do
expect(all(".debate")[0].text).to match "Show what you got" expect(all(".debate")[0].text).to match "Show you got"
expect(all(".debate")[1].text).to match "Show you got" expect(all(".debate")[1].text).to match "Show you got"
expect(all(".debate")[2].text).to match "Show you got" expect(all(".debate")[2].text).to match "Show what you got"
end end
end end
xscenario "Reorder results maintaing search", :js do scenario "Reorder results maintaing search", :js do
debate1 = create(:debate, title: "Show you got", cached_votes_up: 10, created_at: 1.week.ago) debate1 = create(:debate, title: "Show you got", cached_votes_up: 10, created_at: 1.week.ago)
debate2 = create(:debate, title: "Show what you got", cached_votes_up: 1, created_at: 1.month.ago) debate2 = create(:debate, title: "Show what you got", cached_votes_up: 1, created_at: 1.month.ago)
debate3 = create(:debate, title: "Show you got", cached_votes_up: 100, created_at: Time.now) debate3 = create(:debate, title: "Show you got", cached_votes_up: 100, created_at: Time.now)
debate4 = create(:debate, title: "Do not display", cached_votes_up: 1, created_at: 1.week.ago) debate4 = create(:debate, title: "Do not display", cached_votes_up: 1, created_at: 1.week.ago)
visit debates_path visit debates_path
fill_in "search", with: "Show what you got" fill_in "search", with: "Show you got"
click_button "Search" click_button "Search"
click_link 'newest' click_link 'newest'
expect(page).to have_selector("a.active", text: "newest") expect(page).to have_selector("a.active", text: "newest")
@@ -960,12 +960,12 @@ feature 'Debates' do
debate5 = create(:debate, title: "Fifth debate has 5 votes", cached_votes_up: 5) debate5 = create(:debate, title: "Fifth debate has 5 votes", cached_votes_up: 5)
debate6 = create(:debate, title: "Sixth debate has 6 votes", description: 'This is the sixth debate', cached_votes_up: 6) debate6 = create(:debate, title: "Sixth debate has 6 votes", description: 'This is the sixth debate', cached_votes_up: 6)
debate7 = create(:debate, title: "This has seven votes, and is not suggest", description: 'This is the seven', cached_votes_up: 7) debate7 = create(:debate, title: "This has seven votes, and is not suggest", description: 'This is the seven', cached_votes_up: 7)
visit new_debate_path visit new_debate_path
fill_in 'debate_title', with: 'debate' fill_in 'debate_title', with: 'debate'
check "debate_terms_of_service" check "debate_terms_of_service"
within('div#js-suggest') do within('div#js-suggest') do
expect(page).to have_content ("You are seeing 5 of 6 debates containing the term 'debate'") expect(page).to have_content ("You are seeing 5 of 6 debates containing the term 'debate'")
end end
end end
@@ -976,14 +976,14 @@ feature 'Debates' do
debate1 = create(:debate, title: "First debate has 10 vote", cached_votes_up: 10) debate1 = create(:debate, title: "First debate has 10 vote", cached_votes_up: 10)
debate2 = create(:debate, title: "Second debate has 2 votes", cached_votes_up: 2) debate2 = create(:debate, title: "Second debate has 2 votes", cached_votes_up: 2)
visit new_debate_path visit new_debate_path
fill_in 'debate_title', with: 'proposal' fill_in 'debate_title', with: 'proposal'
check "debate_terms_of_service" check "debate_terms_of_service"
within('div#js-suggest') do within('div#js-suggest') do
expect(page).to_not have_content ('You are seeing') expect(page).to_not have_content ('You are seeing')
end end
end end
end end
end end

View File

@@ -436,26 +436,26 @@ describe Debate do
context "attributes" do context "attributes" do
xit "searches by title" do it "searches by title" do
debate = create(:debate, title: 'save the world') debate = create(:debate, title: 'save the world')
results = Debate.search('save the world') results = Debate.search('save the world')
expect(results).to eq([debate]) expect(results).to eq([debate])
end end
xit "searches by description" do it "searches by description" do
debate = create(:debate, description: 'in order to save the world one must think about...') debate = create(:debate, description: 'in order to save the world one must think about...')
results = Debate.search('one must think') results = Debate.search('one must think')
expect(results).to eq([debate]) expect(results).to eq([debate])
end end
xit "searches by author name" do it "searches by author name" do
author = create(:user, username: 'Danny Trejo') author = create(:user, username: 'Danny Trejo')
debate = create(:debate, author: author) debate = create(:debate, author: author)
results = Debate.search('Danny') results = Debate.search('Danny')
expect(results).to eq([debate]) expect(results).to eq([debate])
end end
xit "searches by geozone" do it "searches by geozone" do
geozone = create(:geozone, name: 'California') geozone = create(:geozone, name: 'California')
debate = create(:debate, geozone: geozone) debate = create(:debate, geozone: geozone)
results = Debate.search('California') results = Debate.search('California')
@@ -466,7 +466,7 @@ describe Debate do
context "stemming" do context "stemming" do
xit "searches word stems" do it "searches word stems" do
debate = create(:debate, title: 'limpiar') debate = create(:debate, title: 'limpiar')
results = Debate.search('limpiará') results = Debate.search('limpiará')
@@ -483,7 +483,7 @@ describe Debate do
context "accents" do context "accents" do
xit "searches with accents" do it "searches with accents" do
debate = create(:debate, title: 'difusión') debate = create(:debate, title: 'difusión')
results = Debate.search('difusion') results = Debate.search('difusion')
@@ -492,13 +492,16 @@ describe Debate do
debate2 = create(:debate, title: 'estadisticas') debate2 = create(:debate, title: 'estadisticas')
results = Debate.search('estadísticas') results = Debate.search('estadísticas')
expect(results).to eq([debate2]) expect(results).to eq([debate2])
debate3 = create(:debate, title: 'público')
results = Debate.search('publico')
expect(results).to eq([debate3])
end end
end end
context "case" do context "case" do
it "searches case insensite" do
xit "searches case insensite" do
debate = create(:debate, title: 'SHOUT') debate = create(:debate, title: 'SHOUT')
results = Debate.search('shout') results = Debate.search('shout')
@@ -508,27 +511,23 @@ describe Debate do
results = Debate.search("SCREAM") results = Debate.search("SCREAM")
expect(results).to eq([debate2]) expect(results).to eq([debate2])
end end
end end
context "typos" do context "tags" do
it "searches by tags" do
debate = create(:debate, tag_list: 'Latina')
xit "searches with typos" do results = Debate.search('Latina')
debate = create(:debate, title: 'difusión') expect(results.first).to eq(debate)
results = Debate.search('difuon') results = Debate.search('Latin')
expect(results).to eq([debate]) expect(results.first).to eq(debate)
debate2 = create(:debate, title: 'desarrollo')
results = Debate.search('desarolo')
expect(results).to eq([debate2])
end end
end end
context "order" do context "order" do
xit "orders by weight" do it "orders by weight" do
debate_description = create(:debate, description: 'stop corruption') debate_description = create(:debate, description: 'stop corruption')
debate_title = create(:debate, title: 'stop corruption') debate_title = create(:debate, title: 'stop corruption')
@@ -538,7 +537,7 @@ describe Debate do
expect(results.second).to eq(debate_description) expect(results.second).to eq(debate_description)
end end
xit "orders by weight and then votes" do it "orders by weight and then votes" do
title_some_votes = create(:debate, title: 'stop corruption', cached_votes_up: 5) title_some_votes = create(:debate, title: 'stop corruption', cached_votes_up: 5)
title_least_voted = create(:debate, title: 'stop corruption', cached_votes_up: 2) title_least_voted = create(:debate, title: 'stop corruption', cached_votes_up: 2)
title_most_voted = create(:debate, title: 'stop corruption', cached_votes_up: 10) title_most_voted = create(:debate, title: 'stop corruption', cached_votes_up: 10)
@@ -547,28 +546,26 @@ describe Debate do
results = Debate.search('stop corruption') results = Debate.search('stop corruption')
expect(results.first).to eq(title_most_voted) expect(results.first).to eq(title_most_voted)
expect(results.second).to eq(description_most_voted) expect(results.second).to eq(title_some_votes)
expect(results.third).to eq(title_some_votes) expect(results.third).to eq(title_least_voted)
expect(results.fourth).to eq(title_least_voted) expect(results.fourth).to eq(description_most_voted)
end end
xit "orders by weight and then votes and then created_at" do it "gives much more weight to word matches than votes" do
newest = create(:debate, title: 'stop corruption', cached_votes_up: 5, created_at: Time.now) exact_title_few_votes = create(:debate, title: 'stop corruption', cached_votes_up: 5)
oldest = create(:debate, title: 'stop corruption', cached_votes_up: 5, created_at: 1.month.ago) similar_title_many_votes = create(:debate, title: 'stop some of the corruption', cached_votes_up: 500)
old = create(:debate, title: 'stop corruption', cached_votes_up: 5, created_at: 1.week.ago)
results = Debate.search('stop corruption') results = Debate.search('stop corruption')
expect(results.first).to eq(newest) expect(results.first).to eq(exact_title_few_votes)
expect(results.second).to eq(old) expect(results.second).to eq(similar_title_many_votes)
expect(results.third).to eq(oldest)
end end
end end
context "reorder" do context "reorder" do
xit "should be able to reorder by hot_score after searching" do it "should be able to reorder by hot_score after searching" do
lowest_score = create(:debate, title: 'stop corruption', cached_votes_up: 1) lowest_score = create(:debate, title: 'stop corruption', cached_votes_up: 1)
highest_score = create(:debate, title: 'stop corruption', cached_votes_up: 2) highest_score = create(:debate, title: 'stop corruption', cached_votes_up: 2)
average_score = create(:debate, title: 'stop corruption', cached_votes_up: 3) average_score = create(:debate, title: 'stop corruption', cached_votes_up: 3)
@@ -590,7 +587,7 @@ describe Debate do
expect(results.third).to eq(lowest_score) expect(results.third).to eq(lowest_score)
end end
xit "should be able to reorder by confidence_score after searching" do it "should be able to reorder by confidence_score after searching" do
lowest_score = create(:debate, title: 'stop corruption', cached_votes_up: 1) lowest_score = create(:debate, title: 'stop corruption', cached_votes_up: 1)
highest_score = create(:debate, title: 'stop corruption', cached_votes_up: 2) highest_score = create(:debate, title: 'stop corruption', cached_votes_up: 2)
average_score = create(:debate, title: 'stop corruption', cached_votes_up: 3) average_score = create(:debate, title: 'stop corruption', cached_votes_up: 3)
@@ -612,7 +609,7 @@ describe Debate do
expect(results.third).to eq(lowest_score) expect(results.third).to eq(lowest_score)
end end
xit "should be able to reorder by created_at after searching" do it "should be able to reorder by created_at after searching" do
recent = create(:debate, title: 'stop corruption', cached_votes_up: 1, created_at: 1.week.ago) recent = create(:debate, title: 'stop corruption', cached_votes_up: 1, created_at: 1.week.ago)
newest = create(:debate, title: 'stop corruption', cached_votes_up: 2, created_at: Time.now) newest = create(:debate, title: 'stop corruption', cached_votes_up: 2, created_at: Time.now)
oldest = create(:debate, title: 'stop corruption', cached_votes_up: 3, created_at: 1.month.ago) oldest = create(:debate, title: 'stop corruption', cached_votes_up: 3, created_at: 1.month.ago)
@@ -630,7 +627,7 @@ describe Debate do
expect(results.third).to eq(oldest) expect(results.third).to eq(oldest)
end end
xit "should be able to reorder by most commented after searching" do it "should be able to reorder by most commented after searching" do
least_commented = create(:debate, title: 'stop corruption', cached_votes_up: 1, comments_count: 1) least_commented = create(:debate, title: 'stop corruption', cached_votes_up: 1, comments_count: 1)
most_commented = create(:debate, title: 'stop corruption', cached_votes_up: 2, comments_count: 100) most_commented = create(:debate, title: 'stop corruption', cached_votes_up: 2, comments_count: 100)
some_comments = create(:debate, title: 'stop corruption', cached_votes_up: 3, comments_count: 10) some_comments = create(:debate, title: 'stop corruption', cached_votes_up: 3, comments_count: 10)
@@ -650,41 +647,30 @@ describe Debate do
end end
context "tags" do
xit "searches by tags" do
debate = create(:debate, tag_list: 'Latina')
results = Debate.search('Latina')
expect(results.first).to eq(debate)
end
end
context "no results" do context "no results" do
xit "no words match" do it "no words match" do
debate = create(:debate, title: 'save world') debate = create(:debate, title: 'save world')
results = Debate.search('destroy planet') results = Debate.search('destroy planet')
expect(results).to eq([]) expect(results).to eq([])
end end
xit "too many typos" do it "too many typos" do
debate = create(:debate, title: 'fantastic') debate = create(:debate, title: 'fantastic')
results = Debate.search('frantac') results = Debate.search('frantac')
expect(results).to eq([]) expect(results).to eq([])
end end
xit "too much stemming" do it "too much stemming" do
debate = create(:debate, title: 'reloj') debate = create(:debate, title: 'reloj')
results = Debate.search('superrelojimetro') results = Debate.search('superrelojimetro')
expect(results).to eq([]) expect(results).to eq([])
end end
xit "empty" do it "empty" do
debate = create(:debate, title: 'great') debate = create(:debate, title: 'great')
results = Debate.search('') results = Debate.search('')