From 7ba6fc50bb0691179138c2ca880f44dde8e83417 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 15 Jul 2015 23:19:14 +0200 Subject: [PATCH 01/11] cherry picks capybara config [#5] --- app/controllers/welcome_controller.rb | 6 ++++++ app/views/welcome/index.html.erb | 1 + spec/features/home_spec.rb | 10 ++++++++++ 3 files changed, 17 insertions(+) create mode 100644 app/controllers/welcome_controller.rb create mode 100644 app/views/welcome/index.html.erb create mode 100644 spec/features/home_spec.rb diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb new file mode 100644 index 000000000..dd09ea984 --- /dev/null +++ b/app/controllers/welcome_controller.rb @@ -0,0 +1,6 @@ +class WelcomeController < ApplicationController + + def index + end + +end diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb new file mode 100644 index 000000000..c71238c69 --- /dev/null +++ b/app/views/welcome/index.html.erb @@ -0,0 +1 @@ +

Bienvenido al Ayuntamiento de Madrid

diff --git a/spec/features/home_spec.rb b/spec/features/home_spec.rb new file mode 100644 index 000000000..0fa8b3255 --- /dev/null +++ b/spec/features/home_spec.rb @@ -0,0 +1,10 @@ +require 'rails_helper' + +feature "Home" do + + scenario "Welcome message" do + visit '/' + expect(page).to have_content 'Bienvenido al Ayuntamiento de Madrid' + end + +end From be342cac7611ced8c9ea05a5677740ab8fd2e6c5 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 16 Jul 2015 19:22:20 +0200 Subject: [PATCH 02/11] Basic CRU operations [#5] --- app/controllers/debates_controller.rb | 38 ++++++++++++++++++++++++++ app/views/debates/_debate.html.erb | 6 ++++ app/views/debates/_form.html.erb | 32 ++++++++++++++++++++++ app/views/debates/edit.html.erb | 6 ++++ app/views/debates/index.html.erb | 8 ++++++ app/views/debates/new.html.erb | 5 ++++ app/views/debates/show.html.erb | 8 ++++++ app/views/layouts/application.html.erb | 9 ++++-- config/routes.rb | 3 +- 9 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 app/controllers/debates_controller.rb create mode 100644 app/views/debates/_debate.html.erb create mode 100644 app/views/debates/_form.html.erb create mode 100644 app/views/debates/edit.html.erb create mode 100644 app/views/debates/index.html.erb create mode 100644 app/views/debates/new.html.erb create mode 100644 app/views/debates/show.html.erb diff --git a/app/controllers/debates_controller.rb b/app/controllers/debates_controller.rb new file mode 100644 index 000000000..53545887e --- /dev/null +++ b/app/controllers/debates_controller.rb @@ -0,0 +1,38 @@ +class DebatesController < ApplicationController + before_action :set_debate, only: [:show, :edit, :update] + + def index + @debates = Debate.all + end + + def show + end + + def new + @debate = Debate.new + end + + def edit + end + + def create + @debate = Debate.create(debate_params) + respond_with @debate + end + + def update + @debate.update(debate_params) + respond_with @debate + end + + + private + def set_debate + @debate = Debate.find(params[:id]) + end + + def debate_params + params.require(:debate).permit(:title, :description, :external_link, :terms_of_service) + end + +end diff --git a/app/views/debates/_debate.html.erb b/app/views/debates/_debate.html.erb new file mode 100644 index 000000000..4f99c9df9 --- /dev/null +++ b/app/views/debates/_debate.html.erb @@ -0,0 +1,6 @@ +
+

<%= link_to debate.title, debate %>

+

<%= debate.description %>

+

Creado el: <%= l debate.created_at.to_date %>

+
+

\ No newline at end of file diff --git a/app/views/debates/_form.html.erb b/app/views/debates/_form.html.erb new file mode 100644 index 000000000..98de3c538 --- /dev/null +++ b/app/views/debates/_form.html.erb @@ -0,0 +1,32 @@ +<%= form_for(@debate) do |f| %> + <% if @debate.errors.any? %> +
+

<%= pluralize(@debate.errors.count, "error") %> prohibited this debate from being saved:

+ +
    + <% @debate.errors.full_messages.each do |message| %> +
  • <%= message %>
  • + <% end %> +
+
+ <% end %> + +

Título del debate

+

Sé claro y conciso a la hora de poner un título, pero recuerda que debe explicar bien tu idea, ¡es tu carta de entrada!

+ <%= f.text_field :title %> + +
+

Describe tu opinión

+

Explica con todo el detalle que puedas y de una manera sencilla la idea y que crees que conseguiríamos con ella

+ <%= f.text_area :description %> + + <% if action_name == 'new' %> + <%= f.check_box :terms_of_service %> + Acepto la política de privacidad y el aviso legal + <% end %> + +
+ <%= f.submit %> +
+
+<% end %> \ No newline at end of file diff --git a/app/views/debates/edit.html.erb b/app/views/debates/edit.html.erb new file mode 100644 index 000000000..da5449f23 --- /dev/null +++ b/app/views/debates/edit.html.erb @@ -0,0 +1,6 @@ +

Editing Debate

+ +<%= render 'form' %> + +<%= link_to 'Show', @debate %> | +<%= link_to 'Back', debates_path %> diff --git a/app/views/debates/index.html.erb b/app/views/debates/index.html.erb new file mode 100644 index 000000000..ffd5803ee --- /dev/null +++ b/app/views/debates/index.html.erb @@ -0,0 +1,8 @@ +

Debates sobre Madrid

+ +
+ <%= render @debates %> +
+ +
+<%= link_to 'New Debate', new_debate_path %> diff --git a/app/views/debates/new.html.erb b/app/views/debates/new.html.erb new file mode 100644 index 000000000..c56fdb48f --- /dev/null +++ b/app/views/debates/new.html.erb @@ -0,0 +1,5 @@ +

Publicar un debate nuevo

+ +<%= render 'form' %> + +<%= link_to 'Back', debates_path %> diff --git a/app/views/debates/show.html.erb b/app/views/debates/show.html.erb new file mode 100644 index 000000000..777b22d1b --- /dev/null +++ b/app/views/debates/show.html.erb @@ -0,0 +1,8 @@ +
+

<%= @debate.title %>

+

<%= @debate.description %>

+

Creado el: <%= l @debate.created_at.to_date %>

+
+ +<%= link_to 'Edit', edit_debate_path(@debate) %> | +<%= link_to 'Back', debates_path %> \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 419f31452..3e1fe0213 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -6,9 +6,12 @@ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> <%= csrf_meta_tags %> - - -<%= yield %> + +

<%= notice %>

+
+ <%= yield %> +
+ diff --git a/config/routes.rb b/config/routes.rb index 3f66539d5..e72630d25 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,7 +3,8 @@ Rails.application.routes.draw do # See how all your routes lay out with "rake routes". # You can have the root of your site routed with "root" - # root 'welcome#index' + root 'welcome#index' + resources :debates # Example of regular route: # get 'products/:id' => 'catalog#view' From c2d5b36fb5af4d3b7d9b67dcd15d28ed869322cb Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 16 Jul 2015 19:22:58 +0200 Subject: [PATCH 03/11] makes default language spanish [#5] --- config/application.rb | 2 +- config/locales/es.yml | 198 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 199 insertions(+), 1 deletion(-) create mode 100644 config/locales/es.yml diff --git a/config/application.rb b/config/application.rb index b2304b6ea..b8b69cec4 100644 --- a/config/application.rb +++ b/config/application.rb @@ -18,7 +18,7 @@ module Participacion # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] - # config.i18n.default_locale = :de + config.i18n.default_locale = :es # Do not swallow errors in after_commit/after_rollback callbacks. config.active_record.raise_in_transactional_callbacks = true diff --git a/config/locales/es.yml b/config/locales/es.yml new file mode 100644 index 000000000..68f7b4a06 --- /dev/null +++ b/config/locales/es.yml @@ -0,0 +1,198 @@ +--- +es: + date: + abbr_day_names: + - dom + - lun + - mar + - mié + - jue + - vie + - sáb + abbr_month_names: + - + - ene + - feb + - mar + - abr + - may + - jun + - jul + - ago + - sep + - oct + - nov + - dic + day_names: + - domingo + - lunes + - martes + - miércoles + - jueves + - viernes + - sábado + formats: + default: "%d/%m/%Y" + long: "%d de %B de %Y" + short: "%d de %b" + month_names: + - + - enero + - febrero + - marzo + - abril + - mayo + - junio + - julio + - agosto + - septiembre + - octubre + - noviembre + - diciembre + order: + - :day + - :month + - :year + datetime: + distance_in_words: + about_x_hours: + one: alrededor de 1 hora + other: alrededor de %{count} horas + about_x_months: + one: alrededor de 1 mes + other: alrededor de %{count} meses + about_x_years: + one: alrededor de 1 año + other: alrededor de %{count} años + almost_x_years: + one: casi 1 año + other: casi %{count} años + half_a_minute: medio minuto + less_than_x_minutes: + one: menos de 1 minuto + other: menos de %{count} minutos + less_than_x_seconds: + one: menos de 1 segundo + other: menos de %{count} segundos + over_x_years: + one: más de 1 año + other: más de %{count} años + x_days: + one: 1 día + other: "%{count} días" + x_minutes: + one: 1 minuto + other: "%{count} minutos" + x_months: + one: 1 mes + other: "%{count} meses" + x_seconds: + one: 1 segundo + other: "%{count} segundos" + prompts: + day: Día + hour: Hora + minute: Minutos + month: Mes + second: Segundos + year: Año + errors: + format: "%{attribute} %{message}" + messages: + accepted: debe ser aceptado + blank: no puede estar en blanco + present: debe estar en blanco + confirmation: no coincide + empty: no puede estar vacío + equal_to: debe ser igual a %{count} + even: debe ser par + exclusion: está reservado + greater_than: debe ser mayor que %{count} + greater_than_or_equal_to: debe ser mayor que o igual a %{count} + inclusion: no está incluido en la lista + invalid: no es válido + less_than: debe ser menor que %{count} + less_than_or_equal_to: debe ser menor que o igual a %{count} + not_a_number: no es un número + not_an_integer: debe ser un entero + odd: debe ser impar + record_invalid: 'La validación falló: %{errors}' + restrict_dependent_destroy: + one: No se puede eliminar el registro porque existe un %{record} dependiente + many: No se puede eliminar el registro porque existen %{record} dependientes + taken: ya está en uso + too_long: es demasiado largo (%{count} caracteres máximo) + too_short: es demasiado corto (%{count} caracteres mínimo) + wrong_length: no tiene la longitud correcta (%{count} caracteres exactos) + other_than: debe ser distinto de %{count} + template: + body: 'Se encontraron problemas con los siguientes campos:' + header: + one: No se pudo guardar este/a %{model} porque se encontró 1 error + other: No se pudo guardar este/a %{model} porque se encontraron %{count} errores + helpers: + select: + prompt: Por favor seleccione + submit: + create: Crear %{model} + submit: Guardar %{model} + update: Actualizar %{model} + number: + currency: + format: + delimiter: "." + format: "%n %u" + precision: 2 + separator: "," + significant: false + strip_insignificant_zeros: false + unit: "€" + format: + delimiter: "." + precision: 3 + separator: "," + significant: false + strip_insignificant_zeros: false + human: + decimal_units: + format: "%n %u" + units: + billion: mil millones + million: millón + quadrillion: mil billones + thousand: mil + trillion: billón + unit: '' + format: + delimiter: '' + precision: 1 + significant: true + strip_insignificant_zeros: true + storage_units: + format: "%n %u" + units: + byte: + one: Byte + other: Bytes + gb: GB + kb: KB + mb: MB + tb: TB + percentage: + format: + delimiter: '' + precision: + format: + delimiter: '' + support: + array: + last_word_connector: " y " + two_words_connector: " y " + words_connector: ", " + time: + am: am + formats: + default: "%A, %d de %B de %Y %H:%M:%S %z" + long: "%d de %B de %Y %H:%M" + short: "%d de %b %H:%M" + pm: pm \ No newline at end of file From b1f19f124d2448d26d895bd58a758bdb81444711 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 16 Jul 2015 19:24:27 +0200 Subject: [PATCH 04/11] removes unused column [#5] --- .../20150716154501_remove_external_link_from_debates.rb | 5 +++++ db/schema.rb | 7 +++---- 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20150716154501_remove_external_link_from_debates.rb diff --git a/db/migrate/20150716154501_remove_external_link_from_debates.rb b/db/migrate/20150716154501_remove_external_link_from_debates.rb new file mode 100644 index 000000000..5991b363d --- /dev/null +++ b/db/migrate/20150716154501_remove_external_link_from_debates.rb @@ -0,0 +1,5 @@ +class RemoveExternalLinkFromDebates < ActiveRecord::Migration + def change + remove_column :debates, :external_link + end +end diff --git a/db/schema.rb b/db/schema.rb index c3f3ec2dd..0d8cba5b5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,15 +11,14 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150715190041) do +ActiveRecord::Schema.define(version: 20150716154501) do create_table "debates", force: :cascade do |t| t.string "title" t.text "description" - t.string "external_link" t.integer "author_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end end From 8a3ca2a77f76e4e659f1cdaf48d4cde7a4ac3240 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 16 Jul 2015 19:24:54 +0200 Subject: [PATCH 05/11] configures factory_girl [#5] --- Gemfile | 2 ++ spec/factories.rb | 7 +++++++ spec/spec_helper.rb | 2 ++ 3 files changed, 11 insertions(+) create mode 100644 spec/factories.rb diff --git a/Gemfile b/Gemfile index 84005e07a..476024b38 100644 --- a/Gemfile +++ b/Gemfile @@ -42,5 +42,7 @@ group :development, :test do # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'rspec-rails', '~> 3.0' + gem 'capybara' + gem 'factory_girl_rails' end diff --git a/spec/factories.rb b/spec/factories.rb new file mode 100644 index 000000000..58f320ea7 --- /dev/null +++ b/spec/factories.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + factory :debate do + title 'Debate title' + description 'Debate description' + terms_of_service '1' + end +end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d0b233102..7ad54cc81 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,8 @@ +require 'factory_girl_rails' RSpec.configure do |config| config.filter_run :focus config.run_all_when_everything_filtered = true + config.include FactoryGirl::Syntax::Methods # Allows RSpec to persist some state between runs in order to support # the `--only-failures` and `--next-failure` CLI options. From 89b9c6672a9a7778689ef93d21e39c7f46ddb703 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 16 Jul 2015 19:25:15 +0200 Subject: [PATCH 06/11] updates rails helper [#5] --- spec/rails_helper.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 972bb3bba..5c5fedee7 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -4,6 +4,8 @@ abort("The Rails environment is running in production mode!") if Rails.env.produ require 'spec_helper' require 'rspec/rails' +require 'capybara/rails' +require 'capybara/rspec' ActiveRecord::Migration.maintain_test_schema! RSpec.configure do |config| From 9b3d41552d4b3e28630470ab88fc4d28ae42b364 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 16 Jul 2015 19:25:47 +0200 Subject: [PATCH 07/11] configures responders gem [#5] --- Gemfile | 2 ++ Gemfile.lock | 18 ++++++++++++++++++ app/controllers/application_controller.rb | 5 +++++ config/locales/responders.en.yml | 12 ++++++++++++ config/locales/responders.es.yml | 10 ++++++++++ lib/application_responder.rb | 8 ++++++++ 6 files changed, 55 insertions(+) create mode 100644 config/locales/responders.en.yml create mode 100644 config/locales/responders.es.yml create mode 100644 lib/application_responder.rb diff --git a/Gemfile b/Gemfile index 476024b38..b7badcff5 100644 --- a/Gemfile +++ b/Gemfile @@ -32,6 +32,8 @@ gem 'sdoc', '~> 0.4.0', group: :doc # Use Capistrano for deployment # gem 'capistrano-rails', group: :development +gem "responders" + group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug' diff --git a/Gemfile.lock b/Gemfile.lock index 441af5fa2..db96916c6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -42,6 +42,12 @@ GEM builder (3.2.2) byebug (5.0.0) columnize (= 0.9.0) + capybara (2.4.4) + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + xpath (~> 2.0) coffee-rails (4.1.0) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.0) @@ -54,6 +60,11 @@ GEM diff-lcs (1.2.5) erubis (2.7.0) execjs (2.5.2) + factory_girl (4.5.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.5.0) + factory_girl (~> 4.5.0) + railties (>= 3.0.0) globalid (0.3.5) activesupport (>= 4.1.0) i18n (0.7.0) @@ -104,6 +115,8 @@ GEM thor (>= 0.18.1, < 2.0) rake (10.4.2) rdoc (4.2.0) + responders (2.1.0) + railties (>= 4.2.0, < 5) rspec-core (3.3.1) rspec-support (~> 3.3.0) rspec-expectations (3.3.0) @@ -154,16 +167,21 @@ GEM binding_of_caller (>= 0.7.2) railties (>= 4.0) sprockets-rails (>= 2.0, < 4.0) + xpath (2.0.0) + nokogiri (~> 1.3) PLATFORMS ruby DEPENDENCIES byebug + capybara coffee-rails (~> 4.1.0) + factory_girl_rails jbuilder (~> 2.0) jquery-rails rails (= 4.2.3) + responders rspec-rails (~> 3.0) sass-rails (~> 5.0) sdoc (~> 0.4.0) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d83690e1b..b64f11bb4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,4 +1,9 @@ +require "application_responder" + class ApplicationController < ActionController::Base + self.responder = ApplicationResponder + respond_to :html + # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception diff --git a/config/locales/responders.en.yml b/config/locales/responders.en.yml new file mode 100644 index 000000000..c3e147abf --- /dev/null +++ b/config/locales/responders.en.yml @@ -0,0 +1,12 @@ +en: + flash: + actions: + create: + notice: '%{resource_name} was successfully created.' + # alert: '%{resource_name} could not be created.' + update: + notice: '%{resource_name} was successfully updated.' + # alert: '%{resource_name} could not be updated.' + destroy: + notice: '%{resource_name} was successfully destroyed.' + alert: '%{resource_name} could not be destroyed.' diff --git a/config/locales/responders.es.yml b/config/locales/responders.es.yml new file mode 100644 index 000000000..aa3a47f0d --- /dev/null +++ b/config/locales/responders.es.yml @@ -0,0 +1,10 @@ +es: + flash: + actions: + create: + notice: "%{resource_name} creado correctamente." + update: + notice: "%{resource_name} actualizado correctamente." + destroy: + notice: "%{resource_name} borrado correctamente." + alert: "%{resource_name} no ha podido ser borrado." \ No newline at end of file diff --git a/lib/application_responder.rb b/lib/application_responder.rb new file mode 100644 index 000000000..cc3e58885 --- /dev/null +++ b/lib/application_responder.rb @@ -0,0 +1,8 @@ +class ApplicationResponder < ActionController::Responder + include Responders::FlashResponder + include Responders::HttpCacheResponder + + # Redirects resources to the collection path (index action) instead + # of the resource path (show action) for POST/PUT/DELETE requests. + # include Responders::CollectionResponder +end From 8df23ed498d4becc73b1807f9eb1f63fb1ec006f Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 16 Jul 2015 19:26:01 +0200 Subject: [PATCH 08/11] adds debate validations [#5] --- app/models/debate.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/debate.rb b/app/models/debate.rb index 4e0f1012e..c66913c59 100644 --- a/app/models/debate.rb +++ b/app/models/debate.rb @@ -1,2 +1,6 @@ class Debate < ActiveRecord::Base + validates :title, presence: true + validates :description, presence: true + + validates :terms_of_service, acceptance: { allow_nil: false }, on: :create end From 62349acc544ea51db089b103fbfada0ebcbfe3a8 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 16 Jul 2015 19:26:17 +0200 Subject: [PATCH 09/11] adds debate model specs [#5] --- spec/models/debate_spec.rb | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/spec/models/debate_spec.rb b/spec/models/debate_spec.rb index 768e6feec..490eea985 100644 --- a/spec/models/debate_spec.rb +++ b/spec/models/debate_spec.rb @@ -1,5 +1,28 @@ require 'rails_helper' -RSpec.describe Debate, type: :model do - pending "add some examples to (or delete) #{__FILE__}" +describe Debate do + + before(:each) do + @debate = build(:debate) + end + + it "should be valid" do + expect(@debate).to be_valid + end + + it "should not be valid without a title" do + @debate.title = nil + expect(@debate).to_not be_valid + end + + it "should not be valid without a description" do + @debate.description = nil + expect(@debate).to_not be_valid + end + + it "should not be valid without accepting terms of service" do + @debate.terms_of_service = nil + expect(@debate).to_not be_valid + end + end From a63b272f8b197bc443ab28e6b07851401d7a4211 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 16 Jul 2015 19:26:34 +0200 Subject: [PATCH 10/11] adds debate feature specs [#5] --- spec/features/debates_spec.rb | 55 +++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 spec/features/debates_spec.rb diff --git a/spec/features/debates_spec.rb b/spec/features/debates_spec.rb new file mode 100644 index 000000000..48f7d3b62 --- /dev/null +++ b/spec/features/debates_spec.rb @@ -0,0 +1,55 @@ +require 'rails_helper' + +feature 'Debates' do + + scenario 'Index' do + 3.times { create(:debate) } + + visit debates_path + + expect(page).to have_selector('.debate', count: 3) + within first('.debate') 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}" + end + end + + scenario 'Show' do + debate = create(:debate) + + visit debate_path(debate) + + 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}" + end + + scenario 'Create' do + 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...' + check 'debate_terms_of_service' + + click_button 'Crear Debate' + + 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...' + end + + scenario 'Update' do + debate = create(:debate) + + visit edit_debate_path(debate) + fill_in 'debate_title', with: 'Dimisión Rajoy' + fill_in 'debate_description', with: 'Podríamos...' + + click_button 'Actualizar Debate' + + expect(page).to have_content 'Debate actualizado correctamente' + expect(page).to have_content 'Dimisión Rajoy' + expect(page).to have_content 'Podríamos...' + end + +end From a4ee10fd3fcebe3183c334201183a8e6b3035d67 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 16 Jul 2015 20:27:09 +0200 Subject: [PATCH 11/11] fixing specs [#5] --- app/views/layouts/application.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index d24d7ca73..de07f1b75 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -13,6 +13,7 @@ +

<%= notice %>

<%= yield %>