merges master and fixes conflicts

This commit is contained in:
kikito
2015-09-10 17:47:40 +02:00
34 changed files with 262 additions and 58 deletions

View File

@@ -0,0 +1,84 @@
require 'rails_helper'
feature 'Admin tags' do
background do
@tag1 = create(:tag)
login_as(create(:administrator).user)
end
scenario 'Index' do
create(:debate, tag_list: 'supertag')
visit admin_tags_path
expect(page).to have_content @tag1.name
expect(page).to have_content 'supertag'
end
scenario 'Create' do
visit admin_tags_path
expect(page).to_not have_content 'important issues'
within("form.new_tag") do
fill_in "tag_name", with: 'important issues'
click_button 'Create Topic'
end
visit admin_tags_path
expect(page).to have_content 'important issues'
end
scenario 'Update' do
visit admin_tags_path
featured_checkbox = find("#tag_featured_#{@tag1.id}")
expect(featured_checkbox.checked?).to be_nil
within("#edit_tag_#{@tag1.id}") do
check "tag_featured_#{@tag1.id}"
click_button 'Update Topic'
end
visit admin_tags_path
featured_checkbox = find("#tag_featured_#{@tag1.id}")
expect(featured_checkbox.checked?).to eq('checked')
end
scenario 'Delete' do
tag2 = create(:tag, name: 'bad tag')
create(:debate, tag_list: tag2.name)
visit admin_tags_path
expect(page).to have_content @tag1.name
expect(page).to have_content tag2.name
within("#edit_tag_#{tag2.id}") do
click_link 'Delete Topic'
end
visit admin_tags_path
expect(page).to have_content @tag1.name
expect(page).to_not have_content tag2.name
end
scenario 'Delete tag with hidden taggables' do
tag2 = create(:tag, name: 'bad tag')
debate = create(:debate, tag_list: tag2.name)
debate.hide
visit admin_tags_path
expect(page).to have_content @tag1.name
expect(page).to have_content tag2.name
within("#edit_tag_#{tag2.id}") do
click_link 'Delete Topic'
end
visit admin_tags_path
expect(page).to have_content @tag1.name
expect(page).to_not have_content tag2.name
end
end

View File

@@ -360,59 +360,59 @@ feature 'Debates' do
feature 'Debate index order filters' do
scenario 'Default order is confidence_score', :js do
create(:debate, title: 'best').update_column(:confidence_score, 10)
create(:debate, title: 'worst').update_column(:confidence_score, 2)
create(:debate, title: 'medium').update_column(:confidence_score, 5)
create(:debate, title: 'Best').update_column(:confidence_score, 10)
create(:debate, title: 'Worst').update_column(:confidence_score, 2)
create(:debate, title: 'Medium').update_column(:confidence_score, 5)
visit debates_path
expect('best').to appear_before('medium')
expect('medium').to appear_before('worst')
expect('Best').to appear_before('Medium')
expect('Medium').to appear_before('Worst')
end
scenario 'Debates are ordered by hot_score', :js do
create(:debate, title: 'best').update_column(:hot_score, 10)
create(:debate, title: 'worst').update_column(:hot_score, 2)
create(:debate, title: 'medium').update_column(:hot_score, 5)
create(:debate, title: 'Best').update_column(:hot_score, 10)
create(:debate, title: 'Worst').update_column(:hot_score, 2)
create(:debate, title: 'Medium').update_column(:hot_score, 5)
visit debates_path
select 'most active', from: 'order-selector'
within '#debates.js-order-hot-score' do
expect('best').to appear_before('medium')
expect('medium').to appear_before('worst')
expect('Best').to appear_before('Medium')
expect('Medium').to appear_before('Worst')
end
expect(current_url).to include('order=hot_score')
end
scenario 'Debates are ordered by most commented', :js do
create(:debate, title: 'best', comments_count: 10)
create(:debate, title: 'medium', comments_count: 5)
create(:debate, title: 'worst', comments_count: 2)
create(:debate, title: 'Best', comments_count: 10)
create(:debate, title: 'Medium', comments_count: 5)
create(:debate, title: 'Worst', comments_count: 2)
visit debates_path
select 'most commented', from: 'order-selector'
within '#debates.js-order-most-commented' do
expect('best').to appear_before('medium')
expect('medium').to appear_before('worst')
expect('Best').to appear_before('Medium')
expect('Medium').to appear_before('Worst')
end
expect(current_url).to include('order=most_commented')
end
scenario 'Debates are ordered by newest', :js do
create(:debate, title: 'best', created_at: Time.now)
create(:debate, title: 'medium', created_at: Time.now - 1.hour)
create(:debate, title: 'worst', created_at: Time.now - 1.day)
create(:debate, title: 'Best', created_at: Time.now)
create(:debate, title: 'Medium', created_at: Time.now - 1.hour)
create(:debate, title: 'Worst', created_at: Time.now - 1.day)
visit debates_path
select 'newest', from: 'order-selector'
within '#debates.js-order-created-at' do
expect('best').to appear_before('medium')
expect('medium').to appear_before('worst')
expect('Best').to appear_before('Medium')
expect('Medium').to appear_before('Worst')
end
expect(current_url).to include('order=created_at')

View File

@@ -0,0 +1,21 @@
require 'rails_helper'
feature 'Stats' do
scenario 'Level 2 user' do
admin = create(:administrator)
user = create(:user)
login_as(user)
visit account_path
click_link 'Verify my account'
verify_residence
confirm_phone
login_as(admin.user)
visit stats_path
expect(page).to have_content "Level 2 User (1)"
end
end

View File

@@ -76,4 +76,24 @@ feature 'Verify Letter' do
expect(URI.parse(current_url).path).to eq(new_sms_path)
end
scenario '3 tries allowed' do
user = create(:user, residence_verified_at: Time.now, confirmed_phone: "611111111")
login_as(user)
visit new_letter_path
click_button 'Send me a letter with the code'
3.times do
fill_in 'letter_verification_code', with: "999999"
click_button 'Send'
end
expect(page).to have_content 'You have reached the maximum number of letter verification tries'
expect(URI.parse(current_url).path).to eq(account_path)
visit new_letter_path
expect(page).to have_content 'You have reached the maximum number of letter verification tries'
expect(URI.parse(current_url).path).to eq(account_path)
end
end

View File

@@ -110,4 +110,17 @@ module CommonActions
click_button 'Verify residence'
expect(page).to have_content 'Residence verified'
end
def confirm_phone
fill_in 'sms_phone', with: "611111111"
click_button 'Send'
expect(page).to have_content 'Security code confirmation'
user = User.last.reload
fill_in 'sms_confirmation_code', with: user.sms_confirmation_code
click_button 'Send'
expect(page).to have_content 'Correct code'
end
end