fixing conflicts [#9]
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -31,7 +31,7 @@ gem 'devise'
|
||||
|
||||
# Use Capistrano for deployment
|
||||
# gem 'capistrano-rails', group: :development
|
||||
|
||||
gem 'acts-as-taggable-on'
|
||||
gem "responders"
|
||||
gem 'foundation-rails'
|
||||
gem 'acts_as_votable'
|
||||
|
||||
@@ -36,6 +36,8 @@ GEM
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.3, >= 0.3.4)
|
||||
tzinfo (~> 1.1)
|
||||
acts-as-taggable-on (3.5.0)
|
||||
activerecord (>= 3.2, < 5)
|
||||
acts_as_votable (0.10.0)
|
||||
arel (6.0.2)
|
||||
bcrypt (3.1.10)
|
||||
@@ -189,6 +191,7 @@ PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
acts-as-taggable-on
|
||||
acts_as_votable
|
||||
byebug
|
||||
capybara
|
||||
|
||||
7
app/assets/stylesheets/debates.scss
Normal file
7
app/assets/stylesheets/debates.scss
Normal file
@@ -0,0 +1,7 @@
|
||||
#tag_cloud {
|
||||
width: 400px;
|
||||
line-height: 1.6em;
|
||||
.s { font-size: 0.8em; }
|
||||
.m { font-size: 1.2em; }
|
||||
.l { font-size: 1.8em; }
|
||||
}
|
||||
@@ -1,8 +1,13 @@
|
||||
class DebatesController < ApplicationController
|
||||
before_action :set_debate, only: [:show, :edit, :update]
|
||||
|
||||
before_action :authenticate_user!, only: [:new, :create]
|
||||
|
||||
def index
|
||||
@debates = Debate.all
|
||||
if params[:tag]
|
||||
@debates = Debate.tagged_with(params[:tag])
|
||||
else
|
||||
@debates = Debate.all
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@@ -16,7 +21,9 @@ class DebatesController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
@debate = Debate.create(debate_params)
|
||||
@debate = Debate.new(debate_params)
|
||||
@debate.author = current_user
|
||||
@debate.save
|
||||
respond_with @debate
|
||||
end
|
||||
|
||||
@@ -32,7 +39,7 @@ class DebatesController < ApplicationController
|
||||
end
|
||||
|
||||
def debate_params
|
||||
params.require(:debate).permit(:title, :description, :external_link, :terms_of_service)
|
||||
params.require(:debate).permit(:title, :description, :tag_list, :terms_of_service)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
9
app/controllers/registrations_controller.rb
Normal file
9
app/controllers/registrations_controller.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class RegistrationsController < Devise::RegistrationsController
|
||||
|
||||
private
|
||||
|
||||
def sign_up_params
|
||||
params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,2 +1,7 @@
|
||||
module ApplicationHelper
|
||||
|
||||
def tags(debate)
|
||||
debate.tag_list.map { |tag| link_to sanitize(tag), debates_path(tag: tag) }.join(', ').html_safe
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
require 'numeric'
|
||||
class Debate < ActiveRecord::Base
|
||||
acts_as_votable
|
||||
acts_as_taggable
|
||||
|
||||
belongs_to :author, class_name: 'User', foreign_key: 'author_id'
|
||||
|
||||
validates :title, presence: true
|
||||
validates :description, presence: true
|
||||
validates :author, presence: true
|
||||
|
||||
validates :terms_of_service, acceptance: { allow_nil: false }, on: :create
|
||||
|
||||
@@ -24,4 +28,5 @@ class Debate < ActiveRecord::Base
|
||||
def total_votes
|
||||
votes_for.size
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,6 +1,8 @@
|
||||
class User < ActiveRecord::Base
|
||||
# Include default devise modules. Others available are:
|
||||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||
devise :database_authenticatable, :registerable,
|
||||
:recoverable, :rememberable, :trackable, :validatable
|
||||
|
||||
def name
|
||||
"#{first_name} #{last_name}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
<div class='debate'>
|
||||
<div id="debate-<%= debate.id %>" class='debate'>
|
||||
<p><%= link_to debate.title, debate %></p>
|
||||
<p><%= debate.description %></p>
|
||||
<p>Creado el: <%= l debate.created_at.to_date %></p>
|
||||
|
||||
<p>
|
||||
Creado el: <%= l debate.created_at.to_date %>
|
||||
por: <%= debate.author.name %>
|
||||
</p>
|
||||
|
||||
<p><%= render 'shared/tags', debate: debate %></p>
|
||||
</div>
|
||||
<br/><br/>
|
||||
<br/><br/><br/><br/>
|
||||
@@ -20,7 +20,12 @@
|
||||
<p>Explica con todo el detalle que puedas y de una manera sencilla la idea y que crees que conseguiríamos con ella</p>
|
||||
<%= f.text_area :description %>
|
||||
|
||||
<% if action_name == 'new' %>
|
||||
<div>
|
||||
<%= f.label :tag_list, "Temas (separados por comas)" %><br />
|
||||
<%= f.text_field :tag_list, value: @debate.tag_list.to_s %>
|
||||
</div>
|
||||
|
||||
<% if @debate.new_record? %>
|
||||
<%= f.check_box :terms_of_service %>
|
||||
Acepto la política de privacidad y el aviso legal
|
||||
<% end %>
|
||||
|
||||
@@ -4,5 +4,7 @@
|
||||
<%= render @debates %>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<%= render 'shared/tag_cloud' %>
|
||||
|
||||
<br/><br/>
|
||||
<%= link_to 'New Debate', new_debate_path %>
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
<div id="debate-<%= @debate.id %>">
|
||||
<p><%= @debate.title %></p>
|
||||
<p><%= @debate.description %></p>
|
||||
<p>Creado el: <%= l @debate.created_at.to_date %></p>
|
||||
<p>
|
||||
Creado el: <%= l @debate.created_at.to_date %>
|
||||
por: <%= @debate.author.name %>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
@@ -18,6 +21,9 @@
|
||||
Votos <%= @debate.total_votes %>
|
||||
</div>
|
||||
|
||||
<br/><br/>
|
||||
<%= render 'shared/tags', debate: @debate %>
|
||||
|
||||
<br/><br/>
|
||||
<div>
|
||||
<%= link_to 'Edit', edit_debate_path(@debate) %> |
|
||||
|
||||
9
app/views/devise/menu/_login_items.html.erb
Normal file
9
app/views/devise/menu/_login_items.html.erb
Normal file
@@ -0,0 +1,9 @@
|
||||
<% if user_signed_in? %>
|
||||
<li>
|
||||
<%= link_to('Logout', destroy_user_session_path, :method => :delete) %>
|
||||
</li>
|
||||
<% else %>
|
||||
<li>
|
||||
<%= link_to('Login', new_user_session_path) %>
|
||||
</li>
|
||||
<% end %>
|
||||
@@ -3,9 +3,20 @@
|
||||
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :first_name %><br />
|
||||
<%= f.text_field :first_name, autofocus: true %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :last_name %><br />
|
||||
<%= f.text_field :last_name %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
<%= f.email_field :email, autofocus: true %>
|
||||
<%= f.email_field :email %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
<body style="margin-left:50px">
|
||||
<p class="alert"><%= notice %></p>
|
||||
<p class="alert"><%= alert %></p>
|
||||
|
||||
<%= render 'devise/menu/login_items' %>
|
||||
|
||||
<%= yield %>
|
||||
</body>
|
||||
</html>
|
||||
5
app/views/shared/_tag_cloud.html.erb
Normal file
5
app/views/shared/_tag_cloud.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<div id="tag-cloud">
|
||||
<% tag_cloud Debate.tag_counts, %w[s m l] do |tag, css_class| %>
|
||||
<%= link_to sanitize("#{tag.name}(#{tag.taggings_count})"), debates_path(tag: tag.name), class: css_class %>
|
||||
<% end %>
|
||||
</div>
|
||||
3
app/views/shared/_tags.html.erb
Normal file
3
app/views/shared/_tags.html.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<% if debate.tags.any? %>
|
||||
Temas: <%= tags(debate) %>
|
||||
<% end %>
|
||||
1
config/initializers/acts_as_taggable_on.rb
Normal file
1
config/initializers/acts_as_taggable_on.rb
Normal file
@@ -0,0 +1 @@
|
||||
ActsAsTaggableOn.delimiter = ','
|
||||
58
config/locales/devise.es.yml
Normal file
58
config/locales/devise.es.yml
Normal file
@@ -0,0 +1,58 @@
|
||||
es:
|
||||
devise:
|
||||
confirmations:
|
||||
confirmed: "Tu cuenta ha sido confirmada."
|
||||
send_instructions: "Recibirás un correo electrónico en unos minutos con instrucciones sobre cómo restablecer tu contraseña."
|
||||
send_paranoid_instructions: "Si tu correo electrónico existe en nuestra base de datos recibirás un correo electrónico en unos minutos con instrucciones sobre cómo restablecer tu contraseña."
|
||||
failure:
|
||||
already_authenticated: "Ya has iniciado sesión."
|
||||
inactive: "Tu cuenta aún no ha sido activada."
|
||||
invalid: "%{authentication_keys} o contraseña inválidos."
|
||||
locked: "Tu cuenta ha sido bloqueada."
|
||||
last_attempt: "Tienes un último intento antes de que tu cuenta sea bloqueada."
|
||||
not_found_in_database: "%{authentication_keys} o contraseña inválidos."
|
||||
timeout: "Tu sesión ha expirado, por favor inicia sesión nuevamente para continuar."
|
||||
unauthenticated: "Necesitas iniciar sesión o registrarte para continuar."
|
||||
unconfirmed: "Debes confirmar tu cuenta para continuar."
|
||||
mailer:
|
||||
confirmation_instructions:
|
||||
subject: "Instrucciones de confirmación"
|
||||
reset_password_instructions:
|
||||
subject: "Instrucciones para restablecer tu contraseña"
|
||||
unlock_instructions:
|
||||
subject: "Instrucciones de desbloqueo"
|
||||
omniauth_callbacks:
|
||||
failure: "No se te ha podido autorizar de %{kind} debido a \"%{reason}\"."
|
||||
success: "Identificado correctamente de %{kind}."
|
||||
passwords:
|
||||
no_token: "No puedes acceder a esta página si no es a través de un enlace para restablecer la contraseña. Si has accedido desde el enlace para restablecer la contraseña, asegúrate de que la URL esté completa."
|
||||
send_instructions: "Recibirás un correo electrónico con instrucciones sobre cómo restablecer tu contraseña en unos minutos."
|
||||
send_paranoid_instructions: "Si tu correo electrónico existe en nuestra base de datos, recibirás un enlace para restablecer la contraseña en unos minutos."
|
||||
updated: "Tu contraseña ha cambiado correctamente. Has sido identificado correctamente."
|
||||
updated_not_active: "Tu contraseña se ha cambiado correctamente."
|
||||
registrations:
|
||||
destroyed: "¡Adiós! Tu cuenta ha sido cancelada. Esperamos volver a verte pronto."
|
||||
signed_up: "¡Bienvenido! Has sido identificado."
|
||||
signed_up_but_inactive: "Te has registrado correctamente, pero no has podido iniciar sesión porque tu cuenta no ha sido activada."
|
||||
signed_up_but_locked: "Te has registrado correctamente, pero no has podido iniciar sesión porque tu cuenta está bloqueada."
|
||||
signed_up_but_unconfirmed: "Se te ha enviado un mensaje con un enlace de confirmación. Por favor visita el enlace para activar tu cuenta."
|
||||
update_needs_confirmation: "Has actualizado tu cuenta correctamente, sin embargo necesitamos verificar tu nueva cuenta de correo. Por favor revisa tu correo electrónico y visita el enlace para finalizar la confirmación de tu nueva dirección de correo electrónico."
|
||||
updated: "Has actualizado tu cuenta correctamente."
|
||||
sessions:
|
||||
signed_in: "Has iniciado sesión correctamente."
|
||||
signed_out: "Has cerrado la sesión correctamente."
|
||||
already_signed_out: "Has cerrado la sesión correctamente."
|
||||
unlocks:
|
||||
send_instructions: "Recibirás un correo electrónico en unos minutos con instrucciones sobre cómo desbloquear tu cuenta."
|
||||
send_paranoid_instructions: "Si tu cuenta existe, recibirás un correo electrónico en unos minutos con instrucciones sobre cómo desbloquear tu cuenta."
|
||||
unlocked: "Tu cuenta ha sido desbloqueada. Por favor inicia sesión para continuar."
|
||||
errors:
|
||||
messages:
|
||||
already_confirmed: "ya has sido confirmado, por favor intenta iniciar sesión."
|
||||
confirmation_period_expired: "necesitas ser confirmado en %{period}, por favor vuelve a solicitarla."
|
||||
expired: "ha expirado, por favor vuelve a solicitarla."
|
||||
not_found: "no se ha encontrado."
|
||||
not_locked: "no estaba bloqueado."
|
||||
not_saved:
|
||||
one: "1 error impidió que este %{resource} fuera guardado:"
|
||||
other: "%{count} errores impidieron que este %{resource} fuera guardado:"
|
||||
@@ -1,5 +1,6 @@
|
||||
Rails.application.routes.draw do
|
||||
devise_for :users
|
||||
devise_for :users, :controllers => { registrations: 'registrations' }
|
||||
|
||||
# The priority is based upon order of creation: first created -> highest priority.
|
||||
# See how all your routes lay out with "rake routes".
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class AddFirstNameAndLastNameToUsers < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :users, :first_name, :string
|
||||
add_column :users, :last_name, :string
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,25 @@
|
||||
# This migration comes from acts_as_taggable_on_engine (originally 1)
|
||||
class ActsAsTaggableOnMigration < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :tags do |t|
|
||||
t.string :name
|
||||
end
|
||||
|
||||
create_table :taggings do |t|
|
||||
t.references :tag
|
||||
t.references :taggable, polymorphic: true
|
||||
t.references :tagger, polymorphic: true
|
||||
t.string :context, limit: 128
|
||||
t.datetime :created_at
|
||||
end
|
||||
|
||||
add_index :tags, :name, unique: true
|
||||
add_index :taggings, :tag_id
|
||||
add_index :taggings, [:taggable_id, :taggable_type, :context]
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :taggings
|
||||
drop_table :tags
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,10 @@
|
||||
# This migration comes from acts_as_taggable_on_engine (originally 3)
|
||||
class AddTaggingsCounterCacheToTags < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column :tags, :taggings_count, :integer, default: 0
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :tags, :taggings_count
|
||||
end
|
||||
end
|
||||
24
db/schema.rb
24
db/schema.rb
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150717180105) do
|
||||
ActiveRecord::Schema.define(version: 20150718075337) do
|
||||
|
||||
create_table "debates", force: :cascade do |t|
|
||||
t.string "title"
|
||||
@@ -21,6 +21,26 @@ ActiveRecord::Schema.define(version: 20150717180105) do
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
create_table "taggings", force: :cascade do |t|
|
||||
t.integer "tag_id"
|
||||
t.integer "taggable_id"
|
||||
t.string "taggable_type"
|
||||
t.integer "tagger_id"
|
||||
t.string "tagger_type"
|
||||
t.string "context", limit: 128
|
||||
t.datetime "created_at"
|
||||
end
|
||||
|
||||
add_index "taggings", ["tag_id"], name: "index_taggings_on_tag_id"
|
||||
add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context"
|
||||
|
||||
create_table "tags", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.integer "taggings_count", default: 0
|
||||
end
|
||||
|
||||
add_index "tags", ["name"], name: "index_tags_on_name", unique: true
|
||||
|
||||
create_table "users", force: :cascade do |t|
|
||||
t.string "email", default: "", null: false
|
||||
t.string "encrypted_password", default: "", null: false
|
||||
@@ -34,6 +54,8 @@ ActiveRecord::Schema.define(version: 20150717180105) do
|
||||
t.string "last_sign_in_ip"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "first_name"
|
||||
t.string "last_name"
|
||||
end
|
||||
|
||||
add_index "users", ["email"], name: "index_users_on_email", unique: true
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
FactoryGirl.define do
|
||||
|
||||
factory :user do
|
||||
first_name 'Manuela'
|
||||
last_name 'Carmena'
|
||||
sequence(:email) { |n| "manuela#{n}@madrid.es" }
|
||||
password 'judgmentday'
|
||||
end
|
||||
|
||||
factory :debate do
|
||||
title 'Debate title'
|
||||
description 'Debate description'
|
||||
terms_of_service '1'
|
||||
association :author, factory: :user
|
||||
end
|
||||
|
||||
factory :vote do
|
||||
|
||||
@@ -12,6 +12,7 @@ feature 'Debates' do
|
||||
expect(page).to have_content "Debate title"
|
||||
expect(page).to have_content "Debate description"
|
||||
expect(page).to have_content "Creado el: #{I18n.l Date.today}"
|
||||
expect(page).to have_content "por: #{Debate.first.author.name}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -23,9 +24,13 @@ feature 'Debates' do
|
||||
expect(page).to have_content "Debate title"
|
||||
expect(page).to have_content "Debate description"
|
||||
expect(page).to have_content "Creado el: #{I18n.l Date.today}"
|
||||
expect(page).to have_content "por: #{debate.author.name}"
|
||||
end
|
||||
|
||||
scenario 'Create' do
|
||||
author = create(:user)
|
||||
login_as(author)
|
||||
|
||||
visit new_debate_path
|
||||
fill_in 'debate_title', with: 'Acabar con los desahucios'
|
||||
fill_in 'debate_description', with: 'Esto es un tema muy importante porque...'
|
||||
@@ -36,6 +41,8 @@ feature 'Debates' do
|
||||
expect(page).to have_content 'Debate creado correctamente'
|
||||
expect(page).to have_content 'Acabar con los desahucios'
|
||||
expect(page).to have_content 'Esto es un tema muy importante porque...'
|
||||
expect(page).to have_content "Creado el: #{I18n.l Date.today}"
|
||||
expect(page).to have_content "por: #{author.name}"
|
||||
end
|
||||
|
||||
scenario 'Update' do
|
||||
|
||||
99
spec/features/tags_spec.rb
Normal file
99
spec/features/tags_spec.rb
Normal file
@@ -0,0 +1,99 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature 'Tags' do
|
||||
|
||||
scenario 'Index' do
|
||||
earth = create(:debate, tag_list: 'Medio Ambiente')
|
||||
money = create(:debate, tag_list: 'Economía')
|
||||
|
||||
visit debates_path
|
||||
|
||||
within "#debate-#{earth.id}" do
|
||||
expect(page).to have_content "Temas: Medio Ambiente"
|
||||
end
|
||||
|
||||
within "#debate-#{money.id}" do
|
||||
expect(page).to have_content "Temas: Economía"
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Filtered' do
|
||||
2.times { create(:debate, tag_list: 'Salud') }
|
||||
2.times { create(:debate, tag_list: 'Hacienda') }
|
||||
|
||||
visit debates_path
|
||||
first(:link, "Salud").click
|
||||
|
||||
expect(page).to have_css('.debate', count: 2)
|
||||
expect(page).to have_content('Temas: Salud')
|
||||
expect(page).to_not have_content('Temas: Hacienda')
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
debate = create(:debate, tag_list: 'Hacienda, Economía')
|
||||
|
||||
visit debate_path(debate)
|
||||
|
||||
expect(page).to have_content "Temas: Hacienda, Economía"
|
||||
end
|
||||
|
||||
scenario 'Tag Cloud' do
|
||||
1.times { create(:debate, tag_list: 'Medio Ambiente') }
|
||||
5.times { create(:debate, tag_list: 'Corrupción') }
|
||||
10.times { create(:debate, tag_list: 'Economía') }
|
||||
|
||||
visit debates_path
|
||||
|
||||
within "#tag-cloud" do
|
||||
expect(page).to have_css(".s", text: "Medio Ambiente(1)")
|
||||
expect(page).to have_css(".m", text: "Corrupción(5)")
|
||||
expect(page).to have_css(".l", text: "Economía(10)")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Create' do
|
||||
user = create(:user)
|
||||
login_as(user)
|
||||
|
||||
visit new_debate_path
|
||||
fill_in 'debate_title', with: 'Title'
|
||||
fill_in 'debate_description', with: 'Description'
|
||||
check 'debate_terms_of_service'
|
||||
|
||||
fill_in 'debate_tag_list', with: "Impuestos, Economía, Hacienda"
|
||||
|
||||
click_button 'Crear Debate'
|
||||
|
||||
expect(page).to have_content 'Debate creado correctamente'
|
||||
expect(page).to have_content 'Temas: Impuestos, Economía, Hacienda'
|
||||
end
|
||||
|
||||
scenario 'Update' do
|
||||
debate = create(:debate, tag_list: 'Economía')
|
||||
|
||||
login_as(debate.author)
|
||||
visit edit_debate_path(debate)
|
||||
|
||||
expect(page).to have_selector("input[value='Economía']")
|
||||
|
||||
fill_in 'debate_tag_list', with: "Economía, Hacienda"
|
||||
click_button 'Actualizar Debate'
|
||||
|
||||
expect(page).to have_content 'Debate actualizado correctamente'
|
||||
expect(page).to have_content 'Temas: Economía, Hacienda'
|
||||
end
|
||||
|
||||
scenario 'Delete' do
|
||||
debate = create(:debate, tag_list: 'Economía')
|
||||
|
||||
login_as(debate.author)
|
||||
visit edit_debate_path(debate)
|
||||
|
||||
fill_in 'debate_tag_list', with: ""
|
||||
click_button 'Actualizar Debate'
|
||||
|
||||
expect(page).to have_content 'Debate actualizado correctamente'
|
||||
expect(page).to_not have_content 'Temas:'
|
||||
end
|
||||
|
||||
end
|
||||
43
spec/features/users_spec.rb
Normal file
43
spec/features/users_spec.rb
Normal file
@@ -0,0 +1,43 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature 'Users' do
|
||||
|
||||
scenario 'Sign up' do
|
||||
visit '/'
|
||||
click_link 'Login'
|
||||
click_link 'Sign up'
|
||||
|
||||
fill_in 'user_first_name', with: 'Manuela'
|
||||
fill_in 'user_last_name', with: 'Carmena'
|
||||
fill_in 'user_email', with: 'manuela@madrid.es'
|
||||
fill_in 'user_password', with: 'judgementday'
|
||||
fill_in 'user_password_confirmation', with: 'judgementday'
|
||||
|
||||
click_button 'Sign up'
|
||||
|
||||
expect(page).to have_content '¡Bienvenido! Has sido identificado.'
|
||||
end
|
||||
|
||||
scenario 'Sign in' do
|
||||
user = create(:user, email: 'manuela@madrid.es', password: 'judgementday')
|
||||
|
||||
visit '/'
|
||||
click_link 'Login'
|
||||
fill_in 'user_email', with: 'manuela@madrid.es'
|
||||
fill_in 'user_password', with: 'judgementday'
|
||||
click_button 'Log in'
|
||||
|
||||
expect(page).to have_content 'Has iniciado sesión correctamente.'
|
||||
end
|
||||
|
||||
scenario 'Sign out' do
|
||||
user = create(:user)
|
||||
login_as(user)
|
||||
|
||||
visit "/"
|
||||
click_link 'Logout'
|
||||
|
||||
expect(page).to have_content 'Has cerrado la sesión correctamente.'
|
||||
end
|
||||
|
||||
end
|
||||
@@ -10,6 +10,11 @@ describe Debate do
|
||||
expect(@debate).to be_valid
|
||||
end
|
||||
|
||||
it "should not be valid without an author" do
|
||||
@debate.author = nil
|
||||
expect(@debate).to_not be_valid
|
||||
end
|
||||
|
||||
it "should not be valid without a title" do
|
||||
@debate.title = nil
|
||||
expect(@debate).to_not be_valid
|
||||
|
||||
@@ -6,6 +6,10 @@ require 'spec_helper'
|
||||
require 'rspec/rails'
|
||||
require 'capybara/rails'
|
||||
require 'capybara/rspec'
|
||||
|
||||
include Warden::Test::Helpers
|
||||
Warden.test_mode!
|
||||
|
||||
ActiveRecord::Migration.maintain_test_schema!
|
||||
|
||||
RSpec.configure do |config|
|
||||
|
||||
Reference in New Issue
Block a user