fixes spacing
This commit is contained in:
@@ -16,6 +16,7 @@ class AccountController < ApplicationController
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_account
|
||||
@account = current_user
|
||||
end
|
||||
|
||||
@@ -26,12 +26,12 @@ class Admin::TagsController < Admin::BaseController
|
||||
|
||||
private
|
||||
|
||||
def tag_params
|
||||
params.require(:tag).permit(:featured, :name)
|
||||
end
|
||||
def tag_params
|
||||
params.require(:tag).permit(:featured, :name)
|
||||
end
|
||||
|
||||
def find_tag
|
||||
@tag = ActsAsTaggableOn::Tag.find(params[:id])
|
||||
end
|
||||
def find_tag
|
||||
@tag = ActsAsTaggableOn::Tag.find(params[:id])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -19,25 +19,25 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
private
|
||||
|
||||
def set_locale
|
||||
if params[:locale] && I18n.available_locales.include?(params[:locale].to_sym)
|
||||
session[:locale] = params[:locale]
|
||||
def set_locale
|
||||
if params[:locale] && I18n.available_locales.include?(params[:locale].to_sym)
|
||||
session[:locale] = params[:locale]
|
||||
end
|
||||
|
||||
session[:locale] ||= I18n.default_locale
|
||||
|
||||
I18n.locale = session[:locale]
|
||||
end
|
||||
|
||||
session[:locale] ||= I18n.default_locale
|
||||
|
||||
I18n.locale = session[:locale]
|
||||
end
|
||||
|
||||
def set_layout
|
||||
if devise_controller?
|
||||
"devise"
|
||||
else
|
||||
"application"
|
||||
def set_layout
|
||||
if devise_controller?
|
||||
"devise"
|
||||
else
|
||||
"application"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def set_debate_votes(debates)
|
||||
@voted_values = current_user ? current_user.debate_votes(debates) : {}
|
||||
end
|
||||
def set_debate_votes(debates)
|
||||
@voted_values = current_user ? current_user.debate_votes(debates) : {}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -22,6 +22,7 @@ class CommentsController < ApplicationController
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def comment_params
|
||||
params.require(:comments).permit(:commentable_type, :commentable_id, :body)
|
||||
end
|
||||
|
||||
@@ -48,6 +48,7 @@ class DebatesController < ApplicationController
|
||||
|
||||
|
||||
private
|
||||
|
||||
def debate_params
|
||||
params.require(:debate).permit(:title, :description, :tag_list, :terms_of_service, :captcha, :captcha_key)
|
||||
end
|
||||
|
||||
@@ -12,8 +12,8 @@ class RegistrationsController < Devise::RegistrationsController
|
||||
|
||||
private
|
||||
|
||||
def sign_up_params
|
||||
params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation, :use_nickname, :nickname, :captcha, :captcha_key)
|
||||
end
|
||||
def sign_up_params
|
||||
params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation, :use_nickname, :nickname, :captcha, :captcha_key)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ class Debate < ActiveRecord::Base
|
||||
default_scope { order('created_at DESC') }
|
||||
|
||||
apply_simple_captcha
|
||||
TITLE_LENGTH = Debate.columns.find{|c| c.name == 'title'}.limit
|
||||
TITLE_LENGTH = Debate.columns.find { |c| c.name == 'title' }.limit
|
||||
|
||||
acts_as_votable
|
||||
acts_as_commentable
|
||||
@@ -70,7 +70,7 @@ class Debate < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def sanitize_tag_list
|
||||
self.tag_list = TagSanitizer.new.sanitize_tag_list(self.tag_list)
|
||||
self.tag_list = TagSanitizer.new.sanitize_tag_list(self.tag_list)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ class User < ActiveRecord::Base
|
||||
|
||||
def debate_votes(debates)
|
||||
voted = votes.for_debates.in(debates)
|
||||
voted.each_with_object({}) { |v,_| _[v.votable_id] = v.value }
|
||||
voted.each_with_object({}) { |v, _| _[v.votable_id] = v.value }
|
||||
end
|
||||
|
||||
def administrator?
|
||||
|
||||
@@ -9,15 +9,15 @@ FactoryGirl.define do
|
||||
end
|
||||
|
||||
factory :debate do
|
||||
sequence(:title) {|n| "Debate #{n} title"}
|
||||
description 'Debate description'
|
||||
terms_of_service '1'
|
||||
sequence(:title) { |n| "Debate #{n} title" }
|
||||
description 'Debate description'
|
||||
terms_of_service '1'
|
||||
association :author, factory: :user
|
||||
end
|
||||
|
||||
factory :vote do
|
||||
association :votable, factory: :debate
|
||||
association :voter, factory: :user
|
||||
association :voter, factory: :user
|
||||
vote_flag true
|
||||
end
|
||||
|
||||
@@ -36,7 +36,7 @@ FactoryGirl.define do
|
||||
end
|
||||
|
||||
factory :tag, class: 'ActsAsTaggableOn::Tag' do
|
||||
sequence(:name) {|n| "Tag #{n} name"}
|
||||
sequence(:name) { |n| "Tag #{n} name" }
|
||||
|
||||
trait :featured do
|
||||
featured true
|
||||
|
||||
@@ -3,7 +3,7 @@ require 'rails_helper'
|
||||
feature 'Account' do
|
||||
|
||||
background do
|
||||
@user = create(:user, first_name: "Manuela", last_name:"Colau")
|
||||
@user = create(:user, first_name: "Manuela", last_name: "Colau")
|
||||
login_as(@user)
|
||||
end
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ feature 'Comments' do
|
||||
visit debate_path(debate)
|
||||
|
||||
expect(page).to have_content 'Log in to participate'
|
||||
within ('#comments') do
|
||||
within('#comments') do
|
||||
expect(page).to_not have_content 'Write a comment'
|
||||
expect(page).to_not have_content 'Reply'
|
||||
expect(page).to_not have_css('form')
|
||||
@@ -77,7 +77,7 @@ feature 'Comments' do
|
||||
click_button 'Publish reply'
|
||||
end
|
||||
|
||||
within "#comment-#{comment.id}" do
|
||||
within("#comment-#{comment.id}") do
|
||||
expect(page).to have_content 'It will be done next week.'
|
||||
end
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ feature 'Debates' do
|
||||
|
||||
visit new_debate_path
|
||||
click_button 'Create Debate'
|
||||
expect(page).to have_content /error/
|
||||
expect(page).to have_content error_message
|
||||
end
|
||||
|
||||
scenario 'JS injection is prevented but safe html is respected' do
|
||||
@@ -183,7 +183,7 @@ feature 'Debates' do
|
||||
|
||||
scenario 'Update should not be posible if debate is not editable' do
|
||||
debate = create(:debate)
|
||||
vote = create(:vote, votable: debate)
|
||||
create(:vote, votable: debate)
|
||||
expect(debate).to_not be_editable
|
||||
login_as(debate.author)
|
||||
|
||||
@@ -223,7 +223,7 @@ feature 'Debates' do
|
||||
end
|
||||
|
||||
scenario 'Captcha is required to update a debate' do
|
||||
debate = create(:debate)
|
||||
debate = create(:debate)
|
||||
login_as(debate.author)
|
||||
|
||||
visit edit_debate_path(debate)
|
||||
@@ -264,12 +264,9 @@ feature 'Debates' do
|
||||
end
|
||||
|
||||
describe 'Limiting tags shown' do
|
||||
let(:all_tags) {
|
||||
["Hacienda", "Economía", "Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa", "Huelgas"]
|
||||
}
|
||||
let(:debate) {
|
||||
create :debate, tag_list: all_tags
|
||||
}
|
||||
tags = ["Hacienda", "Economía", "Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa", "Huelgas"]
|
||||
let(:all_tags) { tags }
|
||||
let(:debate) { create :debate, tag_list: all_tags }
|
||||
|
||||
scenario 'Index page shows up to 5 tags per debate' do
|
||||
debate
|
||||
@@ -287,7 +284,7 @@ feature 'Debates' do
|
||||
|
||||
scenario 'Index page shows 3 tags with no plus link' do
|
||||
tag_list = ["Medio Ambiente", "Corrupción", "Fiestas populares"]
|
||||
debate = create :debate, tag_list: tag_list
|
||||
create :debate, tag_list: tag_list
|
||||
|
||||
visit debates_path
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ feature 'Users' do
|
||||
end
|
||||
|
||||
scenario 'Sign in' do
|
||||
user = create(:user, email: 'manuela@madrid.es', password: 'judgementday')
|
||||
create(:user, email: 'manuela@madrid.es', password: 'judgementday')
|
||||
|
||||
visit '/'
|
||||
click_link 'Log in'
|
||||
|
||||
@@ -17,8 +17,8 @@ feature 'Votes' do
|
||||
debate1 = create(:debate)
|
||||
debate2 = create(:debate)
|
||||
debate3 = create(:debate)
|
||||
vote = create(:vote, voter: @manuela, votable: debate1, vote_flag: true)
|
||||
vote = create(:vote, voter: @manuela, votable: debate3, vote_flag: false)
|
||||
create(:vote, voter: @manuela, votable: debate1, vote_flag: true)
|
||||
create(:vote, voter: @manuela, votable: debate3, vote_flag: false)
|
||||
|
||||
visit root_path
|
||||
|
||||
@@ -65,8 +65,8 @@ feature 'Votes' do
|
||||
debate1 = create(:debate)
|
||||
debate2 = create(:debate)
|
||||
debate3 = create(:debate)
|
||||
vote = create(:vote, voter: @manuela, votable: debate1, vote_flag: true)
|
||||
vote = create(:vote, voter: @manuela, votable: debate3, vote_flag: false)
|
||||
create(:vote, voter: @manuela, votable: debate1, vote_flag: true)
|
||||
create(:vote, voter: @manuela, votable: debate3, vote_flag: false)
|
||||
|
||||
visit debates_path
|
||||
|
||||
@@ -120,7 +120,7 @@ feature 'Votes' do
|
||||
expect(page).to_not have_css("a.no-voted")
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within('.against') do
|
||||
expect(page).to have_content "0%"
|
||||
expect(page).to_not have_css("a.voted")
|
||||
expect(page).to_not have_css("a.no-voted")
|
||||
@@ -128,8 +128,8 @@ feature 'Votes' do
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
vote = create(:vote, voter: @manuela, votable: @debate, vote_flag: true)
|
||||
vote = create(:vote, voter: @pablo, votable: @debate, vote_flag: false)
|
||||
create(:vote, voter: @manuela, votable: @debate, vote_flag: true)
|
||||
create(:vote, voter: @pablo, votable: @debate, vote_flag: false)
|
||||
|
||||
visit debate_path(@debate)
|
||||
|
||||
@@ -140,7 +140,7 @@ feature 'Votes' do
|
||||
expect(page).to have_css("a.voted")
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within('.against') do
|
||||
expect(page).to have_content "50%"
|
||||
expect(page).to have_css("a.no-voted")
|
||||
end
|
||||
@@ -154,7 +154,7 @@ feature 'Votes' do
|
||||
expect(page).to have_css("a.voted")
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within('.against') do
|
||||
expect(page).to have_content "0%"
|
||||
expect(page).to have_css("a.no-voted")
|
||||
end
|
||||
@@ -173,7 +173,7 @@ feature 'Votes' do
|
||||
expect(page).to have_css("a.voted")
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within('.against') do
|
||||
expect(page).to have_content "0%"
|
||||
expect(page).to have_css("a.no-voted")
|
||||
end
|
||||
@@ -195,7 +195,7 @@ feature 'Votes' do
|
||||
expect(page).to have_css("a.voted")
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within('.against') do
|
||||
expect(page).to have_content "0%"
|
||||
expect(page).to have_css("a.no-voted")
|
||||
end
|
||||
@@ -214,7 +214,7 @@ feature 'Votes' do
|
||||
expect(page).to have_css("a.no-voted")
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within('.against') do
|
||||
expect(page).to have_content "100%"
|
||||
expect(page).to have_css("a.voted")
|
||||
end
|
||||
@@ -230,7 +230,7 @@ feature 'Votes' do
|
||||
expect(page).to have_content "100%"
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within('.against') do
|
||||
expect(page).to have_content "0%"
|
||||
end
|
||||
|
||||
@@ -250,17 +250,17 @@ feature 'Votes' do
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
vote = create(:vote, voter: @manuela, votable: @comment, vote_flag: true)
|
||||
vote = create(:vote, voter: @pablo, votable: @comment, vote_flag: false)
|
||||
create(:vote, voter: @manuela, votable: @comment, vote_flag: true)
|
||||
create(:vote, voter: @pablo, votable: @comment, vote_flag: false)
|
||||
|
||||
visit debate_path(@debate)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within(".in_favor") do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
within(".against") do
|
||||
within(".against") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
@@ -276,7 +276,7 @@ feature 'Votes' do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
within(".against") do
|
||||
within(".against") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
@@ -293,7 +293,7 @@ feature 'Votes' do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within('.against') do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
@@ -310,7 +310,7 @@ feature 'Votes' do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within('.against') do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ describe Debate do
|
||||
|
||||
describe '#default_order' do
|
||||
let!(:economy) { create(:debate) }
|
||||
let!(:health) { create(:debate) }
|
||||
let!(:health) { create(:debate) }
|
||||
|
||||
it "returns debates ordered by last one first" do
|
||||
expect(Debate.all).to eq([health, economy])
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'factory_girl_rails'
|
||||
require 'database_cleaner'
|
||||
require "email_spec"
|
||||
Dir["./spec/support/**/*.rb"].sort.each { |f| require f}
|
||||
Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.use_transactional_fixtures = false
|
||||
@@ -17,7 +17,7 @@ RSpec.configure do |config|
|
||||
end
|
||||
|
||||
config.before(:each) do |example|
|
||||
DatabaseCleaner.strategy= example.metadata[:js] ? :truncation : :transaction
|
||||
DatabaseCleaner.strategy = example.metadata[:js] ? :truncation : :transaction
|
||||
DatabaseCleaner.start
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user