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 @@ +
+ + + + + + + <% end %> +
+
<% if comentario.user != nil%> +
<%= comentario.user.name %>
+ <%end%> +

<%= truncate(strip_tags(comentario.coment), + :length => 240) %>
+
+
+ <% 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 %> +
+
\ No newline at end of file diff --git a/app/views/comentarios/_form.html.erb b/app/views/comentarios/_form.html.erb new file mode 100644 index 0000000..a754b52 --- /dev/null +++ b/app/views/comentarios/_form.html.erb @@ -0,0 +1,9 @@ +<%= form_for([@site, @site.comentarios.build]) do |f| %> +
+ <%= f.text_area :coment %> +
+ +
+ <%= f.submit %> +
+<% end %> \ No newline at end of file diff --git a/app/views/comentarios/edit.html.erb b/app/views/comentarios/edit.html.erb new file mode 100644 index 0000000..9ba379b --- /dev/null +++ b/app/views/comentarios/edit.html.erb @@ -0,0 +1,26 @@ +

Editing comentario

+ + +<%= form_for([@site, @comentario]) do |comentario| %> + <% if @comentario.errors.any? %> +
+

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

+ + +
+ <% end %> + +
+ <%= comentario.text_area :coment %> +
+ +
+ <%= comentario.submit %> +
+<% end %> + +<%= link_to 'Back', sites_path %> diff --git a/app/views/comentarios/index.html.erb b/app/views/comentarios/index.html.erb new file mode 100644 index 0000000..00d02d9 --- /dev/null +++ b/app/views/comentarios/index.html.erb @@ -0,0 +1,37 @@ +
+

Listing comentarios

+ + + + + + + + + + +<% @comentarios.each do |comentario| %> + + + + + + + + <% end %> + + + +<% end %> +
ComentUser
+
<%= truncate(strip_tags(comentario.coment), + :length => 240) %>
+
+ + <% if comentario.user ==current_user %> + <%= link_to 'Edit', site_comentario_path(@site) %><%= link_to 'Destroy', @site.comentario, confirm: 'Are you sure?', method: :delete %>
+
+ +
+ +<%= link_to 'Nuevo comentario', new_site_comentario_path %> diff --git a/app/views/comentarios/new.html.erb b/app/views/comentarios/new.html.erb new file mode 100644 index 0000000..5310e0c --- /dev/null +++ b/app/views/comentarios/new.html.erb @@ -0,0 +1,5 @@ +

New comentario

+ +<%= render 'form' %> + +<%= link_to 'Back', comentarios_path %> diff --git a/app/views/comentarios/show.html.erb b/app/views/comentarios/show.html.erb new file mode 100644 index 0000000..8027d06 --- /dev/null +++ b/app/views/comentarios/show.html.erb @@ -0,0 +1,23 @@ +

<%= 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)%> - + +
+
+<%= 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)%> \ No newline at end of file diff --git a/app/views/planet/author.html.erb b/app/views/planet/author.html.erb new file mode 100644 index 0000000..ac3ce2d --- /dev/null +++ b/app/views/planet/author.html.erb @@ -0,0 +1,46 @@ +

Autores

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Nombre

Fernando Serra Parri

Alfredo Schoch López

Dirección postalCarrer Pisuerga, 08028,Barcelona,Catalunya (spain)Urbanización Las Fuentes nº33, Collado Villalba, 28400 (Madrid)
Dirección electrónicanandoserra_23@hotmail.comalfredoschoch@gmail.com
Fotografía<%= image_tag('autorverdadero.png') %><%= image_tag('alfredo.png') %>
CVCurriculum

+ Estudios: Ingeniería de Telecomunicación, UPM, Especialidad: Telemática

+ Idiomas:
+

    +
  • Castellano: Medio
  • +
  • Inglés: Alto
  • +
  • Alemán: Medio
  • +
  • Català: Llengua materna
  • +
Curriculum

+ Estudios: Ingeniería de Telecomunicación, UPM, Especialidad: Telemática

+ Idiomas:
+

    +
  • Castellano: Lengua materna
  • +
  • Inglés: Alto
  • +
  • Francés: Medio
  • +
+ + diff --git a/app/views/planet/error_search.html.erb b/app/views/planet/error_search.html.erb new file mode 100644 index 0000000..af05d1f --- /dev/null +++ b/app/views/planet/error_search.html.erb @@ -0,0 +1 @@ +La búsqueda debe contener al menos 3 caracteres \ No newline at end of file diff --git a/app/views/planet/index.html.erb b/app/views/planet/index.html.erb index bbee722..875d4e1 100644 --- a/app/views/planet/index.html.erb +++ b/app/views/planet/index.html.erb @@ -1 +1 @@ -

Wecome to the Planet Travel Site

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 +

Benvinguts a Planet Travel Site

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 @@ +
+

Sites

+ + + <% @sites.each do |site| %> + + + + + + + + + <% end %> +
+ <%= link_to image_tag(site.image_url, :class => 'list_image'), site %> + +
+
<%= link_to site.name, site %>
+
<%= truncate(strip_tags(site.description), + :length => 80) %>
+
+
+ <%= link_to 'Show', site %>
+
+
+ +
+ +
+

Trips

+ + + <% @trips.each do |trip| %> + + + + + + + <% end %> +
+
+
<%= link_to trip.name, trip_path(trip) %>
+
<%= truncate(strip_tags(trip.description), + :length => 80) + ', ' + trip.date.to_s %>
+
+
+ <%= link_to 'Show', trip %>
+
+

\ No newline at end of file diff --git a/app/views/sites/_form.html.erb b/app/views/sites/_form.html.erb index f1fd754..14a6aa2 100644 --- a/app/views/sites/_form.html.erb +++ b/app/views/sites/_form.html.erb @@ -1,3 +1,89 @@ + + + + + + + + + + <%= form_for(@site) do |f| %> <% if @site.errors.any? %>
@@ -11,7 +97,7 @@
<% end %> -
+
<%= f.label :name %>
<%= f.text_field :name %>
@@ -19,15 +105,39 @@ <%= f.label :description %>
<%= f.text_area :description , :rows => 4 %>
+
+ <%= f.label :longitud %>
+ <%= f.text_field :longitud %> +
+
+ <%= f.label :latitud %>
+ <%= f.text_field :latitud %> +
+
+ <%= f.label :zoom %>
+ <%= f.text_field :zoom %> +
+ +
+ + + +
+
+
<%= f.label :type_id %>
<%= f.collection_select(:type_id, Type.find(:all, :order => :name), :id, :name) %>
- <%= f.label :image %>
- <%= f.file_field :image %> + + <%= f.label :image_url %>
+ <%= f.text_field :image_url %> +
<%= f.submit %>
-<% end %> +<%end%> + + diff --git a/app/views/sites/_geoloc.html.erb b/app/views/sites/_geoloc.html.erb new file mode 100644 index 0000000..d52fb1f --- /dev/null +++ b/app/views/sites/_geoloc.html.erb @@ -0,0 +1,45 @@ + +
+ + + + + + + + +
+ +
+ diff --git a/app/views/sites/index.html.erb b/app/views/sites/index.html.erb index b8e4cae..a9f5f6a 100644 --- a/app/views/sites/index.html.erb +++ b/app/views/sites/index.html.erb @@ -14,16 +14,22 @@
<%= link_to site.name, site %>
<%= truncate(strip_tags(site.description), :length => 80) %>
+ <% if site.comentarios !=[] %> +
<%= (link_to 'comentarios',site)%>
+ <%end%> + Viajes:<%=site.visits.length%> <%= link_to 'Show', site %>
- <% if site.user == current_user %> <%= link_to 'Edit', edit_site_path(site) %>
+ <% if site.user == current_user %> + <%= link_to 'Edit', edit_site_path(site) %>
<%= link_to 'Destroy', site, :confirm => 'Are you sure?', :method => :delete %> - <% end %> + <% end %> + <% end %> diff --git a/app/views/sites/show.html.erb b/app/views/sites/show.html.erb index 01a5417..005cd54 100644 --- a/app/views/sites/show.html.erb +++ b/app/views/sites/show.html.erb @@ -1,19 +1,73 @@ + + + + +
- -

<%= @site.type.name if @site.type %>

- <%= image_tag(@site.image.url, :class => 'site_image') %> +

<%= @site.type.name if @site.type %>

+<%= image_tag(@site.image.url, :class => 'site_image') %> +

<%= @site.name %>

+ +

<%=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 %>

-

<%= @site.name %>

+<% end %> -

<%=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 %>

+
+<% if @site.longitud != nil %> +
+<%end%>
- Visitas: <%= @site.visitas %> + Visitas: <%= @site.visitas %> +

Viajes: <%= @site.visits.length %> +

-<% if @site.user == current_user %> <%= link_to 'Edit', edit_site_path(@site) %> | <% end %> <%= link_to 'Back', sites_path %> +<% if @site.user == current_user %> + <%= link_to 'Edit', edit_site_path(@site) %> | +<% end %> +<%= link_to 'Back', sites_path %> + + diff --git a/app/views/trips/show.html.erb b/app/views/trips/show.html.erb index 8bced6a..bed1dac 100644 --- a/app/views/trips/show.html.erb +++ b/app/views/trips/show.html.erb @@ -1,14 +1,82 @@ -

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 %> +

+

Sitios a visitar

<%= render(@trip) %> - <% if @trip.user == current_user %> + <% if @trip.user == current_user %> <%= form_for(@visit, :remote => true) do |f| %> <%= f.number_field :trip_id, :value => @trip.id, :hidden => true %> @@ -21,8 +89,13 @@ <% end %> <% end %>
-
+<% if @trip.sites != [] %> +
+<% end %> - <% if @trip.user == current_user %> <%= link_to 'Edit', edit_trip_path(@trip) %> | <% end %> <%= link_to 'Back', trips_path %> - \ No newline at end of file +<% if @trip.user == current_user %> + <%= link_to 'Edit', edit_trip_path(@trip) %> | +<% end %> +<%= link_to 'Back', trips_path %> + \ No newline at end of file diff --git a/app/views/types/ordered_index.html.erb b/app/views/types/ordered_index.html.erb new file mode 100644 index 0000000..5016ce9 --- /dev/null +++ b/app/views/types/ordered_index.html.erb @@ -0,0 +1,28 @@ +

Listing types

+ + + + + + + + + + + + +<% @types.each do |type| %> + + + + + + + + +<% end %> +
NameDescriptionLast 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 %>
+ +
+ +<%= link_to 'New Type', new_type_path %> diff --git a/app/views/types/show.html.erb b/app/views/types/show.html.erb index 98b32e7..807668c 100644 --- a/app/views/types/show.html.erb +++ b/app/views/types/show.html.erb @@ -9,6 +9,11 @@ Description: <%= @type.description %>

+

+ 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 @@ + + + + + + +class ApplicationController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class ApplicationController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/ApplicationHelper.html b/doc/app/ApplicationHelper.html new file mode 100644 index 0000000..256ce6c --- /dev/null +++ b/doc/app/ApplicationHelper.html @@ -0,0 +1,157 @@ + + + + + + +module ApplicationHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module ApplicationHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Comentario.html b/doc/app/Comentario.html new file mode 100644 index 0000000..cd5851e --- /dev/null +++ b/doc/app/Comentario.html @@ -0,0 +1,163 @@ + + + + + + +class Comentario - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Comentario

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/ComentariosController.html b/doc/app/ComentariosController.html new file mode 100644 index 0000000..5795f10 --- /dev/null +++ b/doc/app/ComentariosController.html @@ -0,0 +1,450 @@ + + + + + + +class ComentariosController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class ComentariosController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/ComentariosHelper.html b/doc/app/ComentariosHelper.html new file mode 100644 index 0000000..b24bfea --- /dev/null +++ b/doc/app/ComentariosHelper.html @@ -0,0 +1,157 @@ + + + + + + +module ComentariosHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module ComentariosHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/PlanetController.html b/doc/app/PlanetController.html new file mode 100644 index 0000000..02c6eff --- /dev/null +++ b/doc/app/PlanetController.html @@ -0,0 +1,338 @@ + + + + + + +class PlanetController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class PlanetController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ author() + click to toggle source +
+ + +
+ +

GET/planet/author

+ + + +
+
# File app/controllers/planet_controller.rb, line 12
+def author
+end
+
+ +
+ + + + +
+ + +
+ +
+ contact() + click to toggle source +
+ + +
+ +

GET/planet/contact

+ + + +
+
# File app/controllers/planet_controller.rb, line 6
+def contact
+end
+
+ +
+ + + + +
+ + +
+ +
+ ejemplo() + click to toggle source +
+ + +
+ +

GET/planet/ejemplo

+ + + +
+
# File app/controllers/planet_controller.rb, line 9
+def ejemplo
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

GET/planet/index

+ + + +
+
# File app/controllers/planet_controller.rb, line 3
+def index
+end
+
+ +
+ + + + +
+ + + + + +
+ +
+ +
+ + + + diff --git a/doc/app/PlanetHelper.html b/doc/app/PlanetHelper.html new file mode 100644 index 0000000..2dee8a8 --- /dev/null +++ b/doc/app/PlanetHelper.html @@ -0,0 +1,157 @@ + + + + + + +module PlanetHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module PlanetHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Site.html b/doc/app/Site.html new file mode 100644 index 0000000..cde7c35 --- /dev/null +++ b/doc/app/Site.html @@ -0,0 +1,163 @@ + + + + + + +class Site - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Site

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/SitesController.html b/doc/app/SitesController.html new file mode 100644 index 0000000..19fba45 --- /dev/null +++ b/doc/app/SitesController.html @@ -0,0 +1,452 @@ + + + + + + +class SitesController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class SitesController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/SitesHelper.html b/doc/app/SitesHelper.html new file mode 100644 index 0000000..146bf3e --- /dev/null +++ b/doc/app/SitesHelper.html @@ -0,0 +1,157 @@ + + + + + + +module SitesHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module SitesHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Trip.html b/doc/app/Trip.html new file mode 100644 index 0000000..6d52587 --- /dev/null +++ b/doc/app/Trip.html @@ -0,0 +1,163 @@ + + + + + + +class Trip - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Trip

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/TripsController.html b/doc/app/TripsController.html new file mode 100644 index 0000000..7ac1c22 --- /dev/null +++ b/doc/app/TripsController.html @@ -0,0 +1,443 @@ + + + + + + +class TripsController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class TripsController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

GET /trips/1/edit

+ + + +
+
# File app/controllers/trips_controller.rb, line 41
+def edit
+  @trip = current_user.trips.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/TripsHelper.html b/doc/app/TripsHelper.html new file mode 100644 index 0000000..b79e648 --- /dev/null +++ b/doc/app/TripsHelper.html @@ -0,0 +1,157 @@ + + + + + + +module TripsHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module TripsHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Type.html b/doc/app/Type.html new file mode 100644 index 0000000..42b6837 --- /dev/null +++ b/doc/app/Type.html @@ -0,0 +1,163 @@ + + + + + + +class Type - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Type

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/TypesController.html b/doc/app/TypesController.html new file mode 100644 index 0000000..e8e520f --- /dev/null +++ b/doc/app/TypesController.html @@ -0,0 +1,479 @@ + + + + + + +class TypesController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class TypesController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

GET /types/1/edit

+ + + +
+
# File app/controllers/types_controller.rb, line 48
+def edit
+  @type = Type.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ ordered_index() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/TypesHelper.html b/doc/app/TypesHelper.html new file mode 100644 index 0000000..7fa0b66 --- /dev/null +++ b/doc/app/TypesHelper.html @@ -0,0 +1,157 @@ + + + + + + +module TypesHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module TypesHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/User.html b/doc/app/User.html new file mode 100644 index 0000000..756c7f0 --- /dev/null +++ b/doc/app/User.html @@ -0,0 +1,163 @@ + + + + + + +class User - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class User

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Visit.html b/doc/app/Visit.html new file mode 100644 index 0000000..53837a6 --- /dev/null +++ b/doc/app/Visit.html @@ -0,0 +1,163 @@ + + + + + + +class Visit - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Visit

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/VisitsController.html b/doc/app/VisitsController.html new file mode 100644 index 0000000..1d535cb --- /dev/null +++ b/doc/app/VisitsController.html @@ -0,0 +1,443 @@ + + + + + + +class VisitsController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class VisitsController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

GET /visits/1/edit

+ + + +
+
# File app/controllers/visits_controller.rb, line 36
+def edit
+  @visit = Visit.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

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
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/VisitsHelper.html b/doc/app/VisitsHelper.html new file mode 100644 index 0000000..0cd627c --- /dev/null +++ b/doc/app/VisitsHelper.html @@ -0,0 +1,157 @@ + + + + + + +module VisitsHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module VisitsHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/created.rid b/doc/app/created.rid new file mode 100644 index 0000000..3b69dd7 --- /dev/null +++ b/doc/app/created.rid @@ -0,0 +1,22 @@ +Fri, 27 Apr 2012 00:09:50 +0200 +doc/README_FOR_APP Thu, 26 Apr 2012 12:50:22 +0200 +app/controllers/application_controller.rb Thu, 26 Apr 2012 12:50:21 +0200 +app/controllers/comentarios_controller.rb Thu, 26 Apr 2012 16:52:41 +0200 +app/controllers/planet_controller.rb Thu, 26 Apr 2012 23:31:32 +0200 +app/controllers/sites_controller.rb Thu, 26 Apr 2012 22:24:57 +0200 +app/controllers/trips_controller.rb Thu, 26 Apr 2012 12:50:21 +0200 +app/controllers/types_controller.rb Thu, 26 Apr 2012 12:50:21 +0200 +app/controllers/visits_controller.rb Thu, 26 Apr 2012 12:50:21 +0200 +app/helpers/application_helper.rb Thu, 26 Apr 2012 12:50:21 +0200 +app/helpers/comentarios_helper.rb Thu, 26 Apr 2012 12:50:21 +0200 +app/helpers/planet_helper.rb Thu, 26 Apr 2012 12:50:21 +0200 +app/helpers/sites_helper.rb Thu, 26 Apr 2012 12:50:21 +0200 +app/helpers/trips_helper.rb Thu, 26 Apr 2012 12:50:21 +0200 +app/helpers/types_helper.rb Thu, 26 Apr 2012 12:50:21 +0200 +app/helpers/visits_helper.rb Thu, 26 Apr 2012 12:50:21 +0200 +app/models/comentario.rb Thu, 26 Apr 2012 22:48:07 +0200 +app/models/site.rb Thu, 26 Apr 2012 12:50:21 +0200 +app/models/trip.rb Thu, 26 Apr 2012 12:50:21 +0200 +app/models/type.rb Thu, 26 Apr 2012 12:50:21 +0200 +app/models/user.rb Thu, 26 Apr 2012 12:50:21 +0200 +app/models/visit.rb Thu, 26 Apr 2012 12:50:21 +0200 diff --git a/doc/app/doc/README_FOR_APP.html b/doc/app/doc/README_FOR_APP.html new file mode 100644 index 0000000..577df8f --- /dev/null +++ b/doc/app/doc/README_FOR_APP.html @@ -0,0 +1,123 @@ + + + + + + +README_FOR_APP - Rails Application Documentation + + + + + + + + + + + + + + + + +
+ +

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.

+ +
+ + + + + diff --git a/doc/app/images/add.png b/doc/app/images/add.png new file mode 100644 index 0000000..6332fef Binary files /dev/null and b/doc/app/images/add.png differ diff --git a/doc/app/images/brick.png b/doc/app/images/brick.png new file mode 100644 index 0000000..7851cf3 Binary files /dev/null and b/doc/app/images/brick.png differ diff --git a/doc/app/images/brick_link.png b/doc/app/images/brick_link.png new file mode 100644 index 0000000..9ebf013 Binary files /dev/null and b/doc/app/images/brick_link.png differ diff --git a/doc/app/images/bug.png b/doc/app/images/bug.png new file mode 100644 index 0000000..2d5fb90 Binary files /dev/null and b/doc/app/images/bug.png differ diff --git a/doc/app/images/bullet_black.png b/doc/app/images/bullet_black.png new file mode 100644 index 0000000..5761970 Binary files /dev/null and b/doc/app/images/bullet_black.png differ diff --git a/doc/app/images/bullet_toggle_minus.png b/doc/app/images/bullet_toggle_minus.png new file mode 100644 index 0000000..b47ce55 Binary files /dev/null and b/doc/app/images/bullet_toggle_minus.png differ diff --git a/doc/app/images/bullet_toggle_plus.png b/doc/app/images/bullet_toggle_plus.png new file mode 100644 index 0000000..9ab4a89 Binary files /dev/null and b/doc/app/images/bullet_toggle_plus.png differ diff --git a/doc/app/images/date.png b/doc/app/images/date.png new file mode 100644 index 0000000..783c833 Binary files /dev/null and b/doc/app/images/date.png differ diff --git a/doc/app/images/delete.png b/doc/app/images/delete.png new file mode 100644 index 0000000..08f2493 Binary files /dev/null and b/doc/app/images/delete.png differ diff --git a/doc/app/images/find.png b/doc/app/images/find.png new file mode 100644 index 0000000..1547479 Binary files /dev/null and b/doc/app/images/find.png differ diff --git a/doc/app/images/loadingAnimation.gif b/doc/app/images/loadingAnimation.gif new file mode 100644 index 0000000..82290f4 Binary files /dev/null and b/doc/app/images/loadingAnimation.gif differ diff --git a/doc/app/images/macFFBgHack.png b/doc/app/images/macFFBgHack.png new file mode 100644 index 0000000..c6473b3 Binary files /dev/null and b/doc/app/images/macFFBgHack.png differ diff --git a/doc/app/images/package.png b/doc/app/images/package.png new file mode 100644 index 0000000..da3c2a2 Binary files /dev/null and b/doc/app/images/package.png differ diff --git a/doc/app/images/page_green.png b/doc/app/images/page_green.png new file mode 100644 index 0000000..de8e003 Binary files /dev/null and b/doc/app/images/page_green.png differ diff --git a/doc/app/images/page_white_text.png b/doc/app/images/page_white_text.png new file mode 100644 index 0000000..813f712 Binary files /dev/null and b/doc/app/images/page_white_text.png differ diff --git a/doc/app/images/page_white_width.png b/doc/app/images/page_white_width.png new file mode 100644 index 0000000..1eb8809 Binary files /dev/null and b/doc/app/images/page_white_width.png differ diff --git a/doc/app/images/plugin.png b/doc/app/images/plugin.png new file mode 100644 index 0000000..6187b15 Binary files /dev/null and b/doc/app/images/plugin.png differ diff --git a/doc/app/images/ruby.png b/doc/app/images/ruby.png new file mode 100644 index 0000000..f763a16 Binary files /dev/null and b/doc/app/images/ruby.png differ diff --git a/doc/app/images/tag_blue.png b/doc/app/images/tag_blue.png new file mode 100644 index 0000000..3f02b5f Binary files /dev/null and b/doc/app/images/tag_blue.png differ diff --git a/doc/app/images/tag_green.png b/doc/app/images/tag_green.png new file mode 100644 index 0000000..83ec984 Binary files /dev/null and b/doc/app/images/tag_green.png differ diff --git a/doc/app/images/transparent.png b/doc/app/images/transparent.png new file mode 100644 index 0000000..d665e17 Binary files /dev/null and b/doc/app/images/transparent.png differ diff --git a/doc/app/images/wrench.png b/doc/app/images/wrench.png new file mode 100644 index 0000000..5c8213f Binary files /dev/null and b/doc/app/images/wrench.png differ diff --git a/doc/app/images/wrench_orange.png b/doc/app/images/wrench_orange.png new file mode 100644 index 0000000..565a933 Binary files /dev/null and b/doc/app/images/wrench_orange.png differ diff --git a/doc/app/images/zoom.png b/doc/app/images/zoom.png new file mode 100644 index 0000000..908612e Binary files /dev/null and b/doc/app/images/zoom.png differ diff --git a/doc/app/index.html b/doc/app/index.html new file mode 100644 index 0000000..8cddd7f --- /dev/null +++ b/doc/app/index.html @@ -0,0 +1,116 @@ + + + + + + +Rails Application Documentation + + + + + + + + + + + + + + + + +

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 + * + */ + +/* Provide console simulation for firebug-less environments */ +if (!("console" in window) || !("firebug" in console)) { + var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", + "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; + + window.console = {}; + for (var i = 0; i < names.length; ++i) + window.console[names[i]] = function() {}; +}; + + +/** + * Unwrap the first element that matches the given @expr@ from the targets and return them. + */ +$.fn.unwrap = function( expr ) { + return this.each( function() { + $(this).parents( expr ).eq( 0 ).after( this ).remove(); + }); +}; + + +function showSource( e ) { + var target = e.target; + var codeSections = $(target). + parents('.method-detail'). + find('.method-source-code'); + + $(target). + parents('.method-detail'). + find('.method-source-code'). + slideToggle(); +}; + +function hookSourceViews() { + $('.method-heading').click( showSource ); +}; + +function toggleDebuggingSection() { + $('.debugging-section').slideToggle(); +}; + +function hookDebuggingToggle() { + $('#debugging-toggle img').click( toggleDebuggingSection ); +}; + +function hookTableOfContentsToggle() { + $('.indexpage li .toc-toggle').each( function() { + $(this).click( function() { + $(this).toggleClass('open'); + }); + + var section = $(this).next(); + + $(this).click( function() { + section.slideToggle(); + }); + }); +} + +function hookSearch() { + var input = $('#search-field').eq(0); + var result = $('#search-results').eq(0); + $(result).show(); + + var search_section = $('#search-section').get(0); + $(search_section).show(); + + var search = new Search(search_data, input, result); + + search.renderItem = function(result) { + var li = document.createElement('li'); + var html = ''; + + // TODO add relative path to + + + + + + + + + + +

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