<%= notice %>
<%= alert %>
+<%= notice %>
<%= alert %>
<%= yield %>diff --git a/.gitignore b/.gitignore index 4a4d70e..db32bfb 100644 --- a/.gitignore +++ b/.gitignore @@ -14,8 +14,7 @@ /log/*.log /tmp -# ignore al .DS_store files of MAC OSX -.DS_Store + # ignore paperclip installation files public/system diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..cc599cc --- /dev/null +++ b/.travis.yml @@ -0,0 +1,2 @@ +rvm: + - 1.9.2 diff --git a/Gemfile b/Gemfile index b0be4dd..14a4bf8 100644 --- a/Gemfile +++ b/Gemfile @@ -8,12 +8,6 @@ gem 'rails', '3.2.2' group :development do gem 'sqlite3' end - -group :production do - gem 'pg' -end - - gem 'devise' # Gems used only for assets and not required @@ -30,8 +24,11 @@ end gem 'jquery-rails' gem 'cleditor_rails' + gem 'paperclip' +gem 'pg' + # To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' @@ -45,4 +42,4 @@ gem 'paperclip' # gem 'capistrano' # To use debugger -# gem 'ruby-debug19', :require => 'ruby-debug' +# gem 'ruby-debug19', :require => 'ruby-debug' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 3b96e7c..4345ae9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -29,7 +29,7 @@ GEM i18n (~> 0.6) multi_json (~> 1.0) arel (3.0.2) - bcrypt-ruby (3.0.1) + bcrypt-ruby (3.0.1-x86-mingw32) builder (3.0.0) cleditor_rails (0.0.3) cocaine (0.2.1) @@ -39,7 +39,7 @@ GEM coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.2.0) + coffee-script-source (1.3.1) devise (2.0.4) bcrypt-ruby (~> 3.0) orm_adapter (~> 0.0.3) @@ -51,23 +51,24 @@ GEM hike (1.2.1) i18n (0.6.0) journey (1.0.3) - jquery-rails (2.0.1) + jquery-rails (2.0.2) railties (>= 3.2.0, < 5.0) thor (~> 0.14) - json (1.6.5) + json (1.6.6) mail (2.4.4) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) - mime-types (1.17.2) - multi_json (1.1.0) + mime-types (1.18) + multi_json (1.3.2) orm_adapter (0.0.7) - paperclip (2.4.5) - activerecord (>= 2.3.0) - activesupport (>= 2.3.2) + paperclip (3.0.2) + activemodel (>= 3.0.0) + activerecord (>= 3.0.0) + activesupport (>= 3.0.0) cocaine (>= 0.0.2) mime-types - pg (0.13.2) + pg (0.13.2-x86-mingw32) polyglot (0.3.3) rack (1.4.1) rack-cache (1.2) @@ -94,8 +95,8 @@ GEM rake (0.9.2.2) rdoc (3.12) json (~> 1.4) - sass (3.1.15) - sass-rails (3.2.4) + sass (3.1.16) + sass-rails (3.2.5) railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) @@ -103,21 +104,21 @@ GEM hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.5) + sqlite3 (1.3.6-x86-mingw32) thor (0.14.6) tilt (1.3.3) treetop (1.4.10) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.32) - uglifier (1.2.3) + tzinfo (0.3.33) + uglifier (1.2.4) execjs (>= 0.3.0) multi_json (>= 1.0.2) warden (1.1.1) rack (>= 1.0) PLATFORMS - ruby + x86-mingw32 DEPENDENCIES cleditor_rails diff --git a/app/assets/images/alfredo.png b/app/assets/images/alfredo.png new file mode 100644 index 0000000..9dafc9d Binary files /dev/null and b/app/assets/images/alfredo.png differ diff --git a/app/assets/images/autorverdadero.png b/app/assets/images/autorverdadero.png new file mode 100644 index 0000000..3ef7487 Binary files /dev/null and b/app/assets/images/autorverdadero.png differ diff --git a/app/assets/images/montserrat.JPG b/app/assets/images/montserrat.JPG new file mode 100644 index 0000000..c62538d Binary files /dev/null and b/app/assets/images/montserrat.JPG differ diff --git a/app/assets/images/prueba.jpg b/app/assets/images/prueba.jpg new file mode 100644 index 0000000..b3b9dc1 Binary files /dev/null and b/app/assets/images/prueba.jpg differ diff --git a/app/assets/images/pruebaII.png b/app/assets/images/pruebaII.png new file mode 100644 index 0000000..3174462 Binary files /dev/null and b/app/assets/images/pruebaII.png differ diff --git a/app/assets/javascripts/comentarios.js.coffee b/app/assets/javascripts/comentarios.js.coffee new file mode 100644 index 0000000..7615679 --- /dev/null +++ b/app/assets/javascripts/comentarios.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/comentarios.css.scss b/app/assets/stylesheets/comentarios.css.scss new file mode 100644 index 0000000..df69af7 --- /dev/null +++ b/app/assets/stylesheets/comentarios.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Comentarios controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/comentarios_controller.rb b/app/controllers/comentarios_controller.rb new file mode 100644 index 0000000..345a1c6 --- /dev/null +++ b/app/controllers/comentarios_controller.rb @@ -0,0 +1,94 @@ +class ComentariosController < ApplicationController + # authenticate_user! ejecuta acción solo si sesión existe + before_filter :authenticate_user!, :except => [ :index, :show ] + + # GET /comentarios + # GET /comentarios.json + def index + if params[:site_id].nil? or params[:site_id].empty? + @comentarios = Comentario.all # path: /sites + else + @comentarios = Site.find(params[:site_id]).comentarios # path: /sites/id/comentarios + end + respond_to do |format| + format.html # index.html.erb + format.json { render json: @comentarios } + end + end + + # GET /comentarios/1 + # GET /comentarios/1.json + def show + @comentario = Comentario.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @comentario } + end + end + + # GET /comentarios/new + # GET /comentarios/new.json + def new + @comentario = Comentario.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @comentario } + end + end + + # GET /comentarios/1/edit + def edit + @site = Site.find(params[:site_id]) + @comentario = @site.comentarios.find(params[:id]) + end + + # POST /comentarios + # POST /comentarios.json + def create + @site = Site.find(params[:site_id]) + @comentario = @site.comentarios.create(params[:comentario]) + @comentario.user_id= current_user.id + + respond_to do |format| + if @comentario.save + format.html { redirect_to @site, notice: 'Comentario was successfully created.' } + else + format.html { render action: "edit" } + format.json { render json: @comentario.errors, status: :unprocessable_entity } + end + end + end + + # PUT /comentarios/1 + # PUT /comentarios/1.json + def update + @site = Site.find(params[:site_id]) + @comentario = @site.comentarios.create(params[:comentario]) + @comentario.user_id= current_user.id + + respond_to do |format| + if @comentario.update_attributes(params[:comentario]) + format.html { redirect_to @site, notice: 'Comentario was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @comentario.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /comentarios/1 + # DELETE /comentarios/1.json + def destroy + @site = Site.find(params[:site_id]) + @comentario = @site.comentarios.find(params[:id]) + @comentario.destroy + + respond_to do |format| + format.html { redirect_to site_path(@site) } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/planet_controller.rb b/app/controllers/planet_controller.rb index be7ac0a..462d97e 100644 --- a/app/controllers/planet_controller.rb +++ b/app/controllers/planet_controller.rb @@ -1,11 +1,24 @@ class PlanetController < ApplicationController + #GET/planet/index def index end - +#GET/planet/contact def contact end - +#GET/planet/ejemplo def ejemplo end - -end +#GET/planet/author + def author + end + + def search + if params[:search].length >= 3 + @sites = Site.where("name like ? OR description like ?", "%#{params[:search]}%", "%#{params[:search]}%") + @trips = Trip.where("name like ? OR description like ?", "%#{params[:search]}%", "%#{params[:search]}%") + else + render action: "errorSearch" + end + end + +end \ No newline at end of file diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb index 57e0611..1f2dd8e 100644 --- a/app/controllers/sites_controller.rb +++ b/app/controllers/sites_controller.rb @@ -1,11 +1,12 @@ class SitesController < ApplicationController - - # authenticate_user! ejecuta acción solo si sesión existe + # authenticate_user! ejecuta acción solo si sesión existe before_filter :authenticate_user!, :except => [ :index, :show ] after_filter :count_visita, :only => :show + # para que solo se ejecute count_visita al realizar la accion show # GET /sites # GET /sites.json + # Obtiene todos los sitios y los renderiza en la misma vista def index if params[:type_id].nil? or params[:type_id].empty? @sites = Site.all # path: /types @@ -20,6 +21,7 @@ def index # GET /sites/1 # GET /sites/1.json + # Muestra el siio cuyo id se pasa como parámetro. def show @site = Site.find(params[:id]) @@ -31,9 +33,10 @@ def show # GET /sites/new # GET /sites/new.json + # Muestra un formulario para añadir un nuevo sitio a la web. def new @site = current_user.sites.build # crea sitio vacio asociado a current_user - + respond_to do |format| format.html # new.html.erb format.json { render json: @site } @@ -41,12 +44,14 @@ def new end # GET /sites/1/edit + # Muestra una vista para editar el sitio cuyo id se pasa como parámetro. def edit @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user end # POST /sites # POST /sites.json + # Muestra una vista con un mensaje de confirmación y el sitio creado. def create @site = current_user.sites.build(params[:site]) # Asigna solo si sitio asociado a current_user @@ -63,6 +68,7 @@ def create # PUT /sites/1 # PUT /sites/1.json + # Muestra una vista para editar los parámetros del sitio. def update @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user @@ -79,6 +85,7 @@ def update # DELETE /sites/1 # DELETE /sites/1.json + # Elimina el sitio que se pasa como parámetro. def destroy @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user @site.destroy @@ -88,9 +95,11 @@ def destroy format.json { head :no_content } end end - + + # Aumenta las visitas de un sitio. private def count_visita @site.increment!(:visitas) end -end + +end \ No newline at end of file diff --git a/app/controllers/types_controller.rb b/app/controllers/types_controller.rb index da826f4..ff384f3 100644 --- a/app/controllers/types_controller.rb +++ b/app/controllers/types_controller.rb @@ -10,6 +10,18 @@ def index end end + # GET /types/ordered_types + # GET /types/ordered_types.json + def ordered_index + @types = Type.find(:all, :order => :name) + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @types } + end + end + + # GET /types/1 # GET /types/1.json def show diff --git a/app/helpers/comentarios_helper.rb b/app/helpers/comentarios_helper.rb new file mode 100644 index 0000000..a8f928b --- /dev/null +++ b/app/helpers/comentarios_helper.rb @@ -0,0 +1,2 @@ +module ComentariosHelper +end diff --git a/app/models/comentario.rb b/app/models/comentario.rb new file mode 100644 index 0000000..4387db4 --- /dev/null +++ b/app/models/comentario.rb @@ -0,0 +1,7 @@ +class Comentario < ActiveRecord::Base + belongs_to :site + belongs_to :user + + attr_protected :user_id + validates :coment, :presence => true # campo obligatorio +end diff --git a/app/models/site.rb b/app/models/site.rb index 2b2f99a..912b64a 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -1,6 +1,7 @@ class Site < ActiveRecord::Base belongs_to :type belongs_to :user + has_many :comentarios has_many :visits has_many :trips, :through => :visits has_attached_file :image diff --git a/app/models/user.rb b/app/models/user.rb index 35b8159..63a0ec8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,6 +2,7 @@ class User < ActiveRecord::Base has_many :sites has_many :trips + has_many :comentarios # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable diff --git a/app/views/comentarios/_comentario.html.erb b/app/views/comentarios/_comentario.html.erb new file mode 100644 index 0000000..03726a9 --- /dev/null +++ b/app/views/comentarios/_comentario.html.erb @@ -0,0 +1,23 @@ +
+
|
+
+
+ <% if comentario.user == current_user %>
+ <%= link_to 'Edit', edit_site_comentario_path(comentario.site, comentario) %> + <%= link_to 'Destroy', [comentario.site, comentario], + :confirm => 'Are you sure?', + :method => :delete %> + |
+
+ <% end %>
+
| Coment | +User | ++ | + | + |
|---|---|---|---|---|
|
+ |
+ + + <% if comentario.user ==current_user %> + | <%= link_to 'Edit', site_comentario_path(@site) %> | +<%= link_to 'Destroy', @site.comentario, confirm: 'Are you sure?', method: :delete %> | + <% end %> + + +
<%= notice %>
+ ++ Coment: + <%= @comentario.coment %> +
+ ++ Autor: + <%= @comentario.user.name if @comentario.user %> +
+ ++ Site: + <%= @comentario.site.name if @comentario.site_id %> +
+ + +<%= link_to 'Edit', edit_comentario_path(@comentario) %> | +<%= link_to 'Back', comentarios_path %> +<%= link_to 'Destroy', @comentario, + :confirm => 'Are you sure?', + :method => :delete %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 82edd70..62b34ab 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -6,15 +6,32 @@ <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> - + +<%= link_to('Index', planet_index_path)+ ' || '+ link_to('Author', planet_author_path) + ' || ' + link_to('Contact', planet_contact_path) + ' || '+ link_to('Ejemplo', planet_ejemplo_path) + ' || '+link_to('Ordered types', ordered_index_types_path) + ' || '+ link_to("Types", types_path)%> - + +| Nombre | +Fernando Serra Parri |
+ Alfredo Schoch López |
+
| Dirección postal | +Carrer Pisuerga, 08028,Barcelona,Catalunya (spain) | +Urbanización Las Fuentes nº33, Collado Villalba, 28400 (Madrid) | +
| Dirección electrónica | +nandoserra_23@hotmail.com | +alfredoschoch@gmail.com | +
| Fotografía | +<%= image_tag('autorverdadero.png') %> | +<%= image_tag('alfredo.png') %> | +
| CV | +Curriculum + Estudios: Ingeniería de Telecomunicación, UPM, Especialidad: Telemática
+ Idiomas:
|
+ Curriculum + Estudios: Ingeniería de Telecomunicación, UPM, Especialidad: Telemática
+ Idiomas:
|
+
This site gathers information of touristic sites from all over the world and should help you to organize your trips and your holidays.
<%= image_tag('pedriza2-m.png') %>Feel free to use it for your convenience and pleasure.
\ No newline at end of file +This site gathers information of touristic sites from all over the world and should help you to organize your trips and your holidays.
<%= image_tag('pruebaII.png') %>Feel free to use it for your convenience and pleasure.
\ No newline at end of file diff --git a/app/views/planet/search.html.erb b/app/views/planet/search.html.erb new file mode 100644 index 0000000..81957c3 --- /dev/null +++ b/app/views/planet/search.html.erb @@ -0,0 +1,51 @@ +| + <%= link_to image_tag(site.image_url, :class => 'list_image'), site %> + | + +
+
|
+
+
+ <%= link_to 'Show', site %> + |
+
+
|
+
+
+ <%= link_to 'Show', trip %> + |
+
<%=sanitize @site.description %>
+<% if @site.longitud != nil%> +Coordenadas: + Longitud <%= @site.longitud %> + Latitud: <%= @site.latitud %> + Zoom: <%= @site.zoom %> + <%end%> + <% if @site.comentarios!=[] %> +Comentarios: +<%= render @site.comentarios %>
-<%=sanitize @site.description %>
+Añada su comentario: +<% if current_user %> + <%= render "comentarios/form" %>
+<% end %> -Autor: <%= @site.user.name if @site.user %>
-Autor: + <%= @site.user.name if @site.user %>
+Viajes: <%= @site.visits.length %> +
Name: <%= @trip.name %>
Date: <%= @trip.date %>
- Autor: <%= @trip.user.name if @trip.user %> -
-Description: <%= simple_format @trip.description %>
+ + + + + + ++ Name: + <%= @trip.name %> +
+ ++ Date: + <%= @trip.date %> +
+ ++ Autor: + <%= @trip.user.name if @trip.user %> +
+ ++ Description: + <%= simple_format @trip.description %> +
+| Name | +Description | +Last change | ++ | + | + |
|---|---|---|---|---|---|
| <%= type.name %> | +<%= type.description %> | +<%= type.updated_at %> | +<%= link_to 'Show', type %> | +<%= link_to 'Edit', edit_type_path(type) %> | +<%= link_to 'Destroy', type, confirm: 'Are you sure?', method: :delete %> | +
+ fecha última modificación + <%=@type.updated_at %> +
+ <%= link_to 'Edit', edit_type_path(@type) %> | diff --git a/config/routes.rb b/config/routes.rb index 29d3c86..a88f208 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,16 +1,25 @@ Planet::Application.routes.draw do + resources :comentarios + resources :visits resources :trips devise_for :users - resources :sites + resources :sites do + resources :comentarios + end resources :types do # Rutas anidadas /types/id/sites..., + get "ordered_index", :on => :collection resources :sites, :only => [ :index ] # Restringe a acción “index” end + + resources :users do + resources :comments + end get "planet/index" @@ -18,6 +27,11 @@ get "planet/ejemplo" + get "planet/author" + + get "planet/search" + + # The priority is based upon order of creation: # first created -> highest priority. diff --git a/db/migrate/20120320100145_create_sites.rb b/db/migrate/20120320100145_create_sites.rb index 823209a..16462f2 100644 --- a/db/migrate/20120320100145_create_sites.rb +++ b/db/migrate/20120320100145_create_sites.rb @@ -4,8 +4,7 @@ def change t.string :name t.text :description t.integer :type_id - t.string :image_url - + t.string :image_url t.timestamps end end diff --git a/db/migrate/20120415163612_create_comentarios.rb b/db/migrate/20120415163612_create_comentarios.rb new file mode 100644 index 0000000..1f46d24 --- /dev/null +++ b/db/migrate/20120415163612_create_comentarios.rb @@ -0,0 +1,11 @@ +class CreateComentarios < ActiveRecord::Migration + def change + create_table :comentarios do |t| + t.string :coment + t.integer :user_id + t.integer :site_id + + t.timestamps + end + end +end diff --git a/db/migrate/20120426154857_sites_geopos.rb b/db/migrate/20120426154857_sites_geopos.rb new file mode 100644 index 0000000..c1337b9 --- /dev/null +++ b/db/migrate/20120426154857_sites_geopos.rb @@ -0,0 +1,12 @@ +class SitesGeopos < ActiveRecord::Migration + def up + change_table :sites do |t| + t.column :latitud, :float + t.column :longitud, :float + t.column :zoom, :integer + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index e6aa66f..1981a98 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,15 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120411160519) do +ActiveRecord::Schema.define(:version => 20120426154857) do + + create_table "comentarios", :force => true do |t| + t.string "coment" + t.integer "user_id" + t.integer "site_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end create_table "sites", :force => true do |t| t.string "name" @@ -26,6 +34,9 @@ t.string "image_file_size" t.datetime "image_updated_at" t.integer "visitas", :default => 0 + t.float "latitud" + t.float "longitud" + t.integer "zoom" end create_table "trips", :force => true do |t| diff --git a/db/seeds.rb b/db/seeds.rb index 2aadd13..2bda1ab 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -9,56 +9,109 @@ Type.delete_all -tm = Type.create( +type1 = Type.create!( name: 'Monumento', description: 'Edificio de interes turistico o artistico') -tn = Type.create( +type2 = Type.create!( name: 'Naturaleza', description: 'Lugar al aire libre de interes natural o de recreo') -tr = Type.create( +type3 = Type.create!( name: 'Ruina', description: 'Lugar o resto de interes arquelogico') -Site.delete_all +User.delete_all + +user1 = User.create!( + name: 'Jose Perez', + email: 'jose.perez@gmail.com', + password: 'perez22', + password_confirmation: 'perez22') +user2 = User.create!( + name: 'Javier Sedano', + email: 'javier.sedano@me.com', + password: 'sedano22', + password_confirmation: 'sedano22') -Site.create( + +Site.delete_all + +site1= Site.create!( name: 'Pedriza', description: 'Magnifico valle al norte de Madrid en el Macizo Central', - type_id: tn.id, - image_url: 'pedriza.png') + type_id: type2.id, + image_url: 'pedriza.png', + image: File.open(File.join(Rails.root, 'app', 'assets','images', 'pedriza.png'), "r")) +site1.user_id = user1.id ; site1.save -Site.create( +site2 = Site.create!( name: 'Catedral de Florencia', description: 'Catedral de la ciudad de Florencia con la que se inicia el Renacimiento', - type_id: tm.id, - image_url: 'florencia.png') + type_id: type1.id, + image_url: 'florencia.png', + image: File.open(File.join(Rails.root, 'app', 'assets','images', 'florencia.png'), "r")) +site2.user_id = user1.id ; site2.save -Site.create( +site3 = Site.create!( name: 'Jardin de Lineo', - description: 'Jardin de la ciudad sueca de Uppsala donde el famoso naturalista enia su coleccion de plantas', - type_id: tn.id, - image_url: 'arbol1.png') + description: 'Jardin de la ciudad sueca de Uppsala donde el famoso naturalista tenia su coleccion de plantas', + type_id: type1.id, + image_url: 'arbol1.png', + image: File.open(File.join(Rails.root, 'app', 'assets','images', 'arbol1.png'), "r")) +site3.user_id = user2.id ; site3.save -Site.create( +site4 = Site.create!( name: 'Reichstag', description: 'Parlamento aleman en la ciudad de Berlin', - type_id: tm.id, - image_url: 'reichstag.png') + type_id: type2.id, + image_url: 'reichstag.png', + image: File.open(File.join(Rails.root, 'app', 'assets','images', 'reichstag.png'), "r")) +site4.user_id = user2.id ; site4.save -Site.create( +site5 = Site.create!( name: 'Pergamo', description: 'Puerta del mercado de la antigua ciudad griega de Pergamo del museo arquelogico de Berlin', - type_id: tr.id, - image_url: 'pergamo.png') + type_id: type3.id, + image_url: 'pergamo.png', + image: File.open(File.join(Rails.root, 'app', 'assets','images', 'pergamo.png'), "r")) +site5.user_id = user1.id ; site5.save + + + +Trip.delete_all + +trip1 = Trip.create!( + name: 'Viaje por Europa', + description: 'Viaje por capitales europeas', + date: '2012-04-12') +trip1.user_id = user1.id ; trip1.save + +trip2 = Trip.create!( + name: 'Sierra de Madrid', + description: 'Sua al Yelmo en la Pedriza', + date: '2012-05-18') +trip2.user_id = user2.id ; trip2.save + + +Visit.delete_all + +visit1 = Visit.create!( + hour: '10') +visit1.trip_id = trip2.id +visit1.site_id = site1.id ; visit1.save -# user_id esta protegido con "attr_protected" y debe inicializarse asi, -# Site.create(....) levantaria una excepcipón al intentar inicializarlo -Site.all.each { |obj| obj.user_id = 1 ; obj.save } +visit2 = Visit.create!( + hour: '9') +visit2.trip_id = trip1.id +visit2.site_id = site5.id ; visit2.save +visit3 = Visit.create!( + hour: '16') +visit3.trip_id = trip1.id +visit3.site_id = site4.id ; visit3.save diff --git a/doc/app/ApplicationController.html b/doc/app/ApplicationController.html new file mode 100644 index 0000000..04bd7c9 --- /dev/null +++ b/doc/app/ApplicationController.html @@ -0,0 +1,163 @@ + + + + + + +ActiveRecord::Base + +
POST /comentarios POST /comentarios.json
+ + + +# File app/controllers/comentarios_controller.rb, line 49 +def create + @site = Site.find(params[:site_id]) + @comentario = @site.comentarios.create(params[:comentario]) + @comentario.user_id= current_user.id + + respond_to do |format| + if @comentario.save + format.html { redirect_to @site, notice: 'Comentario was successfully created.' } + else + format.html { render action: "edit" } + format.json { render json: @comentario.errors, status: :unprocessable_entity } + end + end +end+
DELETE /comentarios/1 DELETE /comentarios/1.json
+ + + +# File app/controllers/comentarios_controller.rb, line 84 +def destroy + @site = Site.find(params[:site_id]) + @comentario = @site.comentarios.find(params[:id]) + @comentario.destroy + + respond_to do |format| + format.html { redirect_to site_path(@site) } + format.json { head :no_content } + end +end+
GET /comentarios/1/edit
+ + + +# File app/controllers/comentarios_controller.rb, line 42 +def edit + @site = Site.find(params[:site_id]) + @comentario = @site.comentarios.find(params[:id]) +end+
GET /comentarios GET /comentarios.json
+ + + +# File app/controllers/comentarios_controller.rb, line 7 +def index + if params[:site_id].nil? or params[:site_id].empty? + @comentarios = Comentario.all # path: /sites + else + @comentarios = Site.find(params[:site_id]).comentarios # path: /sites/id/comentarios + end + respond_to do |format| + format.html # index.html.erb + format.json { render json: @comentarios } + end +end+
GET /comentarios/new GET /comentarios/new.json
+ + + +# File app/controllers/comentarios_controller.rb, line 32 +def new + @comentario = Comentario.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @comentario } + end +end+
GET /comentarios/1 GET /comentarios/1.json
+ + + +# File app/controllers/comentarios_controller.rb, line 21 +def show + @comentario = Comentario.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @comentario } + end +end+
PUT /comentarios/1 PUT /comentarios/1.json
+ + + +# File app/controllers/comentarios_controller.rb, line 66 +def update + @site = Site.find(params[:site_id]) + @comentario = @site.comentarios.create(params[:comentario]) + @comentario.user_id= current_user.id + + respond_to do |format| + if @comentario.update_attributes(params[:comentario]) + format.html { redirect_to @site, notice: 'Comentario was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @comentario.errors, status: :unprocessable_entity } + end + end +end+
GET/planet/contact
+ + + +# File app/controllers/planet_controller.rb, line 6 +def contact +end+
GET/planet/ejemplo
+ + + +# File app/controllers/planet_controller.rb, line 9 +def ejemplo +end+
GET/planet/index
+ + + +# File app/controllers/planet_controller.rb, line 3 +def index +end+
# File app/controllers/planet_controller.rb, line 15 +def search + if params[:search].length >= 3 + @sites = Site.where("name like ? OR description like ?", "%#{params[:search]}%", "%#{params[:search]}%") + @trips = Trip.where("name like ? OR description like ?", "%#{params[:search]}%", "%#{params[:search]}%") + else + render action: "errorSearch" + end +end+
ActiveRecord::Base + +
POST /sites POST /sites.json Muestra una vista con un mensaje de +confirmación y el sitio creado.
+ + + +# File app/controllers/sites_controller.rb, line 55 +def create + @site = current_user.sites.build(params[:site]) # Asigna solo si sitio asociado a current_user + + respond_to do |format| + if @site.save + format.html { redirect_to @site, notice: 'Site was successfully created.' } + format.json { render json: @site, status: :created, location: @site } + else + format.html { render action: "new" } + format.json { render json: @site.errors, status: :unprocessable_entity } + end + end +end+
DELETE /sites/1 DELETE /sites/1.json Elimina el sitio que se pasa como +parámetro.
+ + + +# File app/controllers/sites_controller.rb, line 89 +def destroy + @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user + @site.destroy + + respond_to do |format| + format.html { redirect_to sites_url } + format.json { head :no_content } + end +end+
GET /sites/1/edit Muestra una vista para editar el sitio cuyo id se pasa +como parámetro.
+ + + +# File app/controllers/sites_controller.rb, line 48 +def edit + @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user +end+
GET /sites GET /sites.json Obtiene todos los sitios y los renderiza en la +misma vista
+ + + +# File app/controllers/sites_controller.rb, line 10 +def index + if params[:type_id].nil? or params[:type_id].empty? + @sites = Site.all # path: /types + else + @sites = Type.find(params[:type_id]).sites # path: /types/id/sites + end + respond_to do |format| + format.html # index.html.erb + format.json { render json: @sites } + end +end+
GET /sites/new GET /sites/new.json Muestra un formulario para añadir un +nuevo sitio a la web.
+ + + +# File app/controllers/sites_controller.rb, line 37 +def new + @site = current_user.sites.build # crea sitio vacio asociado a current_user + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @site } + end +end+
GET /sites/1 GET /sites/1.json Muestra el siio cuyo id se pasa como +parámetro.
+ + + +# File app/controllers/sites_controller.rb, line 25 +def show + @site = Site.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @site } + end +end+
PUT /sites/1 PUT /sites/1.json Muestra una vista para editar los parámetros +del sitio.
+ + + +# File app/controllers/sites_controller.rb, line 72 +def update + @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user + + respond_to do |format| + if @site.update_attributes(params[:site]) + format.html { redirect_to @site, notice: 'Site was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @site.errors, status: :unprocessable_entity } + end + end +end+
ActiveRecord::Base + +
POST /trips POST /trips.json
+ + + +# File app/controllers/trips_controller.rb, line 47 +def create + @trip = current_user.trips.build(params[:trip]) + + respond_to do |format| + if @trip.save + format.html { redirect_to @trip, notice: 'Trip was successfully created.' } + format.json { render json: @trip, status: :created, location: @trip } + else + format.html { render action: "new" } + format.json { render json: @trip.errors, status: :unprocessable_entity } + end + end +end+
DELETE /trips/1 DELETE /trips/1.json
+ + + +# File app/controllers/trips_controller.rb, line 79 +def destroy + @trip = current_user.trips.find(params[:id]) + @trip.destroy + + respond_to do |format| + format.html { redirect_to trips_url } + format.json { head :no_content } + end +end+
GET /trips/1/edit
+ + + +# File app/controllers/trips_controller.rb, line 41 +def edit + @trip = current_user.trips.find(params[:id]) +end+
GET /trips GET /trips.json
+ + + +# File app/controllers/trips_controller.rb, line 8 +def index + @trips = Trip.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @trips } + end +end+
GET /trips/new GET /trips/new.json
+ + + +# File app/controllers/trips_controller.rb, line 31 +def new + @trip = current_user.trips.build + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @trip } + end +end+
GET /trips/1 GET /trips/1.json
+ + + +# File app/controllers/trips_controller.rb, line 19 +def show + @trip = Trip.find(params[:id]) + @visit = @trip.visits.build + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @trip } + end +end+
PUT /trips/1 PUT /trips/1.json
+ + + +# File app/controllers/trips_controller.rb, line 63 +def update + @trip = current_user.trips.find(params[:id]) + + respond_to do |format| + if @trip.update_attributes(params[:trip]) + format.html { redirect_to @trip, notice: 'Trip was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @trip.errors, status: :unprocessable_entity } + end + end +end+
ActiveRecord::Base + +
POST /types POST /types.json
+ + + +# File app/controllers/types_controller.rb, line 54 +def create + @type = Type.new(params[:type]) + + respond_to do |format| + if @type.save + format.html { redirect_to @type, notice: 'Type was successfully created.' } + format.json { render json: @type, status: :created, location: @type } + else + format.html { render action: "new" } + format.json { render json: @type.errors, status: :unprocessable_entity } + end + end +end+
DELETE /types/1 DELETE /types/1.json
+ + + +# File app/controllers/types_controller.rb, line 86 +def destroy + @type = Type.find(params[:id]) + @type.destroy + + respond_to do |format| + format.html { redirect_to types_url } + format.json { head :no_content } + end +end+
GET /types/1/edit
+ + + +# File app/controllers/types_controller.rb, line 48 +def edit + @type = Type.find(params[:id]) +end+
GET /types GET /types.json
+ + + +# File app/controllers/types_controller.rb, line 4 +def index + @types = Type.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @types } + end +end+
GET /types/new GET /types/new.json
+ + + +# File app/controllers/types_controller.rb, line 38 +def new + @type = Type.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @type } + end +end+
GET /types/ordered_types GET /types/ordered_types.json
+ + + +# File app/controllers/types_controller.rb, line 15 +def ordered_index + @types = Type.find(:all, :order => :name) + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @types } + end +end+
GET /types/1 GET /types/1.json
+ + + +# File app/controllers/types_controller.rb, line 27 +def show + @type = Type.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @type } + end +end+
PUT /types/1 PUT /types/1.json
+ + + +# File app/controllers/types_controller.rb, line 70 +def update + @type = Type.find(params[:id]) + + respond_to do |format| + if @type.update_attributes(params[:type]) + format.html { redirect_to @type, notice: 'Type was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @type.errors, status: :unprocessable_entity } + end + end +end+
ActiveRecord::Base + +
ActiveRecord::Base + +
POST /visits POST /visits.json
+ + + +# File app/controllers/visits_controller.rb, line 42 +def create + @visit = Visit.new(params[:visit]) + + respond_to do |format| + if @visit.save + format.html { redirect_to @visit.trip, notice: 'Visit was successfully created.' } + format.js + format.json { render json: @visit, status: :created, location: @visit } + else + format.html { render action: "new" } + format.json { render json: @visit.errors, status: :unprocessable_entity } + end + end +end+
DELETE /visits/1 DELETE /visits/1.json
+ + + +# File app/controllers/visits_controller.rb, line 75 +def destroy + @visit = Visit.find(params[:id]) + @visit.destroy + + respond_to do |format| + format.html { redirect_to @visit.trip } + format.json { head :no_content } + end +end+
GET /visits/1/edit
+ + + +# File app/controllers/visits_controller.rb, line 36 +def edit + @visit = Visit.find(params[:id]) +end+
GET /visits GET /visits.json
+ + + +# File app/controllers/visits_controller.rb, line 4 +def index + @visits = Visit.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @visits } + end +end+
GET /visits/new GET /visits/new.json
+ + + +# File app/controllers/visits_controller.rb, line 26 +def new + @visit = Visit.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @visit } + end +end+
GET /visits/1 GET /visits/1.json
+ + + +# File app/controllers/visits_controller.rb, line 15 +def show + @visit = Visit.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @visit } + end +end+
PUT /visits/1 PUT /visits/1.json
+ + + +# File app/controllers/visits_controller.rb, line 59 +def update + @visit = Visit.find(params[:id]) + + respond_to do |format| + if @visit.update_attributes(params[:visit]) + format.html { redirect_to @visit.trip, notice: 'Visit was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @visit.errors, status: :unprocessable_entity } + end + end +end+
Use this README file to introduce your application and point to useful +places in the API for learning more. Run “rake doc:app” to generate API +documentation for your models, controllers, helpers, and libraries.
+ +This is the API documentation for Rails Application Documentation.
+
+
+
+
diff --git a/doc/app/js/darkfish.js b/doc/app/js/darkfish.js
new file mode 100644
index 0000000..4be722f
--- /dev/null
+++ b/doc/app/js/darkfish.js
@@ -0,0 +1,153 @@
+/**
+ *
+ * Darkfish Page Functions
+ * $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $
+ *
+ * Author: Michael Granger Table of Contents - Rails Application Documentation
+
+Pages
+
+
+
+Classes/Modules
+
+
+
+Methods
+
+
+
+
+
+
+
diff --git a/test/fixtures/comentarios.yml b/test/fixtures/comentarios.yml
new file mode 100644
index 0000000..3f018b8
--- /dev/null
+++ b/test/fixtures/comentarios.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ coment: MyString
+ user_id: 1
+ site_id: 1
+
+two:
+ coment: YourString
+ user_id: 2
+ site_id: 2
diff --git a/test/fixtures/sites.yml b/test/fixtures/sites.yml
index 0b20b0a..cb34338 100644
--- a/test/fixtures/sites.yml
+++ b/test/fixtures/sites.yml
@@ -3,11 +3,14 @@
one:
name: MyString
description: MyText
- type_id: 1
+ type: one
image_url: MyString
+ user: one
two:
- name: MyString
- description: MyText
- type_id: 1
- image_url: MyString
+ name: YourString
+ description: YourText
+ type: two
+ image_url: YourString
+ user: two
+
diff --git a/test/fixtures/trips.yml b/test/fixtures/trips.yml
index f71f334..e093bcf 100644
--- a/test/fixtures/trips.yml
+++ b/test/fixtures/trips.yml
@@ -4,10 +4,10 @@ one:
name: MyString
description: MyText
date: 2012-04-09
- user_id: 1
+ user: one
two:
- name: MyString
- description: MyText
+ name: YourString
+ description: YourText
date: 2012-04-09
- user_id: 1
+ user: two
diff --git a/test/fixtures/types.yml b/test/fixtures/types.yml
index 8683ea9..49a7b4e 100644
--- a/test/fixtures/types.yml
+++ b/test/fixtures/types.yml
@@ -5,8 +5,8 @@ one:
description: MyText
two:
- name: MyString
- description: MyText
+ name: YourString
+ description: YourText
# Podriamos añadir nuevos datos de inicialización, que se referencian como
# -> types(:monumento) types(:naturaleza)
monumento:
name: Monumento
description: “Edificio o construcción de valor historico”
naturaleza:
name: Naturaleza
description: “Lugar al aire libre de interés natural”
\ No newline at end of file
diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml
index c63aac0..2e8c5e4 100644
--- a/test/fixtures/users.yml
+++ b/test/fixtures/users.yml
@@ -4,8 +4,14 @@
# model remove the '{}' from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
-one: {}
+one:
+ name: Jose Perez
+ email: jose.perez@gmail.com
+ encrypted_password: perez22222
# column: value
#
-two: {}
+two:
+ name: Jose Perez
+ email: jose.perez@me.com
+ encrypted_password: perez33333
# column: value
diff --git a/test/fixtures/visits.yml b/test/fixtures/visits.yml
index 6a15000..22d3657 100644
--- a/test/fixtures/visits.yml
+++ b/test/fixtures/visits.yml
@@ -1,11 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
- trip_id: 1
- site_id: 1
- hour: 1
+ trip: one
+ site: one
+ hour: 9
two:
- trip_id: 1
- site_id: 1
- hour: 1
+ trip: two
+ site: two
+ hour: 9
diff --git a/test/functional/comentarios_controller_test.rb b/test/functional/comentarios_controller_test.rb
new file mode 100644
index 0000000..2c09333
--- /dev/null
+++ b/test/functional/comentarios_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class ComentariosControllerTest < ActionController::TestCase
+ setup do
+ @comentario = comentarios(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:comentarios)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create comentario" do
+ assert_difference('Comentario.count') do
+ post :create, comentario: @comentario.attributes
+ end
+
+ assert_redirected_to comentario_path(assigns(:comentario))
+ end
+
+ test "should show comentario" do
+ get :show, id: @comentario
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @comentario
+ assert_response :success
+ end
+
+ test "should update comentario" do
+ put :update, id: @comentario, comentario: @comentario.attributes
+ assert_redirected_to comentario_path(assigns(:comentario))
+ end
+
+ test "should destroy comentario" do
+ assert_difference('Comentario.count', -1) do
+ delete :destroy, id: @comentario
+ end
+
+ assert_redirected_to comentarios_path
+ end
+end
diff --git a/test/functional/planet_controller_test.rb b/test/functional/planet_controller_test.rb
index 88229e0..e13f8f9 100644
--- a/test/functional/planet_controller_test.rb
+++ b/test/functional/planet_controller_test.rb
@@ -1,6 +1,9 @@
require 'test_helper'
class PlanetControllerTest < ActionController::TestCase
+setup do
+ @busqueda = "MyString"
+end
test "should get index" do
get :index
assert_response :success
@@ -11,4 +14,18 @@ class PlanetControllerTest < ActionController::TestCase
assert_response :success
end
-end
+ test "should get ejemplo" do
+ get :ejemplo
+ assert_response :success
+ end
+
+ test "should get author" do
+ get :author
+ assert_response :success
+ end
+
+ test "should get search" do
+ get :search, busqueda: @busqueda
+ assert_response :success
+ end
+end
\ No newline at end of file
diff --git a/test/functional/sites_controller_test.rb b/test/functional/sites_controller_test.rb
index beac6d1..05d1ae7 100644
--- a/test/functional/sites_controller_test.rb
+++ b/test/functional/sites_controller_test.rb
@@ -3,6 +3,13 @@
class SitesControllerTest < ActionController::TestCase
setup do
@site = sites(:one)
+ @update = { # @update: parametros diferentes
+ :name => 'AnotherType',
+ :description => 'AnotherText',
+ :type_id => types(:one).id
+ }
+ @user = @site.user
+ sign_in @user
end
test "should get index" do
@@ -18,7 +25,7 @@ class SitesControllerTest < ActionController::TestCase
test "should create site" do
assert_difference('Site.count') do
- post :create, site: @site.attributes
+ post :create, site: @update
end
assert_redirected_to site_path(assigns(:site))
@@ -35,7 +42,7 @@ class SitesControllerTest < ActionController::TestCase
end
test "should update site" do
- put :update, id: @site, site: @site.attributes
+ put :update, id: @site, site: @update
assert_redirected_to site_path(assigns(:site))
end
diff --git a/test/functional/trips_controller_test.rb b/test/functional/trips_controller_test.rb
index b09dce2..cf88341 100644
--- a/test/functional/trips_controller_test.rb
+++ b/test/functional/trips_controller_test.rb
@@ -3,6 +3,13 @@
class TripsControllerTest < ActionController::TestCase
setup do
@trip = trips(:one)
+ @update = { # @update: parametros diferentes
+ :name => 'AnotherType',
+ :description => 'AnotherText',
+ :date => '2012-04-09'
+ }
+ @user = @trip.user
+ sign_in @user
end
test "should get index" do
@@ -18,7 +25,7 @@ class TripsControllerTest < ActionController::TestCase
test "should create trip" do
assert_difference('Trip.count') do
- post :create, trip: @trip.attributes
+ post :create, trip: @update
end
assert_redirected_to trip_path(assigns(:trip))
@@ -35,7 +42,7 @@ class TripsControllerTest < ActionController::TestCase
end
test "should update trip" do
- put :update, id: @trip, trip: @trip.attributes
+ put :update, id: @trip, trip: @update
assert_redirected_to trip_path(assigns(:trip))
end
diff --git a/test/functional/types_controller_test.rb b/test/functional/types_controller_test.rb
index d8b0dc1..5df8926 100644
--- a/test/functional/types_controller_test.rb
+++ b/test/functional/types_controller_test.rb
@@ -7,6 +7,8 @@ class TypesControllerTest < ActionController::TestCase
:name => 'AnotherType',
:description => 'AnotherText',
}
+ @user = users(:one)
+ sign_in @user
end
test "should get index" do
diff --git a/test/functional/visits_controller_test.rb b/test/functional/visits_controller_test.rb
index 45397e3..f3d098a 100644
--- a/test/functional/visits_controller_test.rb
+++ b/test/functional/visits_controller_test.rb
@@ -3,6 +3,7 @@
class VisitsControllerTest < ActionController::TestCase
setup do
@visit = visits(:one)
+ @trip = @visit.trip
end
test "should get index" do
@@ -21,7 +22,7 @@ class VisitsControllerTest < ActionController::TestCase
post :create, visit: @visit.attributes
end
- assert_redirected_to visit_path(assigns(:visit))
+ assert_redirected_to @trip
end
test "should show visit" do
@@ -36,7 +37,7 @@ class VisitsControllerTest < ActionController::TestCase
test "should update visit" do
put :update, id: @visit, visit: @visit.attributes
- assert_redirected_to visit_path(assigns(:visit))
+ assert_redirected_to @trip
end
test "should destroy visit" do
@@ -44,6 +45,6 @@ class VisitsControllerTest < ActionController::TestCase
delete :destroy, id: @visit
end
- assert_redirected_to visits_path
+ assert_redirected_to @trip
end
end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 8bf1192..fcb3995 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -10,4 +10,7 @@ class ActiveSupport::TestCase
fixtures :all
# Add more helper methods to be used by all tests here...
+ ActionController::TestCase.class_eval do
+ include Devise::TestHelpers
+end
end
diff --git a/test/unit/comentario_test.rb b/test/unit/comentario_test.rb
new file mode 100644
index 0000000..02f982d
--- /dev/null
+++ b/test/unit/comentario_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class ComentarioTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/unit/helpers/comentarios_helper_test.rb b/test/unit/helpers/comentarios_helper_test.rb
new file mode 100644
index 0000000..d553eef
--- /dev/null
+++ b/test/unit/helpers/comentarios_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class ComentariosHelperTest < ActionView::TestCase
+end
diff --git a/test/unit/helpers/planet_controller_test.rb b/test/unit/helpers/planet_controller_test.rb
new file mode 100644
index 0000000..62b893b
--- /dev/null
+++ b/test/unit/helpers/planet_controller_test.rb
@@ -0,0 +1,24 @@
+require 'test_helper'
+
+class PlanetControllerTest < ActionController::TestCase
+ test "should get index" do
+ get :index
+ assert_response :success
+ end
+
+ test "should get contact" do
+ get :contact
+ assert_response :success
+ end
+
+ test "should get author" do
+ get :author
+ assert_response :success
+ end
+
+ test "should get ejemplo" do
+ get :ejemplo
+ assert_response :success
+ end
+
+end
diff --git a/test/unit/helpers/sites_controller_test.rb b/test/unit/helpers/sites_controller_test.rb
new file mode 100644
index 0000000..37bf8d5
--- /dev/null
+++ b/test/unit/helpers/sites_controller_test.rb
@@ -0,0 +1,46 @@
+# one:
+# name: MyString
+# description: MyText
+# type_id: 1
+# image_url: MyString
+class SitesControllerTest < ActionController::TestCase
+ setup do
+ @site = sites(:one)
+ end
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:sites) # @sites inicializada?
+ end
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create site" do
+ # Comprueba que tabla crece (+1)
+ assert_difference('Site.count') do
+ # “name: MyString” ya existe en la tabla
+ post :create, :site => @site.attributes
+ end
+ assert_redirected_to site_path(assigns(:site))
+ end
+ test "should show site" do
+ get :show, :id => @site.to_param
+ assert_response :success
+ end
+ test "should get edit" do
+ get :edit, :id => @site.to_param
+ assert_response :success
+ end
+ test "should update site" do
+ put :update, :id => @site, :site => @site.attributes
+ assert_redirected_to site_path(assigns(:site))
+ end
+ test "should destroy site" do
+ assert_difference('Site.count', -1) do
+ delete :destroy, :id => @site.to_param
+ end
+ assert_redirected_to sites_path
+ end
+end
\ No newline at end of file
diff --git a/test/unit/helpers/types_controller_test.rb b/test/unit/helpers/types_controller_test.rb
new file mode 100644
index 0000000..ddd2e36
--- /dev/null
+++ b/test/unit/helpers/types_controller_test.rb
@@ -0,0 +1,54 @@
+require 'test_helper'
+# one:
+# name: MyString
+# description: MyText
+# type_id: 1
+# image_url: MyString
+
+class TypesControllerTest < ActionController::TestCase
+ setup do
+ @type = types (:one)
+ @update = {
+ :name => 'AnotherType',
+ :description => 'AnotherText'
+ }
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns (:types)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create type" do
+ assert_difference ("Type.count") do
+ post :create, :type => @update
+ end
+ assert_redirected_to type_path(assigns (:type))
+ end
+
+ test "should show type" do
+ get :show, :id => @type.to_param
+ assert_response :success
+ end
+ test "should get edit" do
+ get :edit, :id => @type.to_param
+ assert_response :success
+ end
+ test "should update type" do
+ put :update, :id => @type, :type => @update
+ assert_redirected_to type_path(assigns(:type))
+ end
+ test "should destroy type" do
+ assert_difference('Type.count', -1) do
+ delete :destroy, :id => @type.to_param
+ end
+ assert_redirected_to types_path
+ end
+end
+
diff --git a/test/unit/site_test.rb b/test/unit/site_test.rb
index 34931c1..1f4a391 100644
--- a/test/unit/site_test.rb
+++ b/test/unit/site_test.rb
@@ -12,6 +12,6 @@ class SiteTest < ActiveSupport::TestCase
assert site.errors[:name].any?
assert not(site.errors[:description].any?)
assert site.errors[:type_id].any?
- assert site.errors[:image_url].any?
+ # assert site.errors[:image_url].any? not used with paperclip
end
end