diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..30e8a10 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +.rvmrc +db/*.sqlite3 +log/*.log +tmp/ +*.swp +*.directory +cache +public/system/ +.sass-cache/ +public/uploads/ diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..4e1e0d2 --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--color diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..590395d --- /dev/null +++ b/Gemfile @@ -0,0 +1,64 @@ +source 'https://rubygems.org' + +gem 'rails', '3.2.13' + +# Bundle edge Rails instead: +# gem 'rails', :git => 'git://github.com/rails/rails.git' + +gem 'sqlite3' + + +# Gems used only for assets and not required +# in production environments by default. +group :assets do + gem 'sass-rails', '~> 3.2.3' + gem 'coffee-rails', '~> 3.2.1' + + # See https://github.com/sstephenson/execjs#readme for more supported runtimes + # gem 'therubyracer', :platforms => :ruby + + gem 'uglifier', '>= 1.0.3' + gem 'jquery-fileupload-rails' +end + +gem 'jquery-rails' +gem 'jquery_mobile_rails' + +gem 'rieles', github: 'LogicalBricks/rieles' +gem 'haml-rails' +gem 'cancan' +gem 'carrierwave' +gem 'rmagick' + +gem 'activeadmin' +gem 'roadie' + +group :development, :test do + gem 'sqlite3' + gem 'rspec-rails' + gem 'shoulda-matchers' + gem 'capybara' + gem 'poltergeist' + gem 'cucumber-rails', require: false + gem 'database_cleaner' + gem 'test_notifier' + gem 'factory_girl_rails' + gem 'email_spec' + gem 'letter_opener' + gem 'pry' +end + +# To use ActiveModel has_secure_password +# gem 'bcrypt-ruby', '~> 3.0.0' + +# To use Jbuilder templates for JSON +# gem 'jbuilder' + +# Use unicorn as the app server +# gem 'unicorn' + +# Deploy with Capistrano +# gem 'capistrano' + +# To use debugger +# gem 'debugger' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..34ed861 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,285 @@ +GIT + remote: git://github.com/LogicalBricks/rieles.git + revision: 5d42619c97aa443a8547eada2af610ae5c62bc79 + specs: + rieles (0.0.5) + +GEM + remote: https://rubygems.org/ + specs: + actionmailer (3.2.13) + actionpack (= 3.2.13) + mail (~> 2.5.3) + actionpack (3.2.13) + activemodel (= 3.2.13) + activesupport (= 3.2.13) + builder (~> 3.0.0) + erubis (~> 2.7.0) + journey (~> 1.0.4) + rack (~> 1.4.5) + rack-cache (~> 1.2) + rack-test (~> 0.6.1) + sprockets (~> 2.2.1) + activeadmin (0.6.0) + arbre (>= 1.0.1) + bourbon (>= 1.0.0) + devise (>= 1.1.2) + fastercsv + formtastic (>= 2.0.0) + inherited_resources (>= 1.3.1) + jquery-rails (>= 1.0.0) + kaminari (>= 0.13.0) + meta_search (>= 0.9.2) + rails (>= 3.0.0) + sass (>= 3.1.0) + activemodel (3.2.13) + activesupport (= 3.2.13) + builder (~> 3.0.0) + activerecord (3.2.13) + activemodel (= 3.2.13) + activesupport (= 3.2.13) + arel (~> 3.0.2) + tzinfo (~> 0.3.29) + activeresource (3.2.13) + activemodel (= 3.2.13) + activesupport (= 3.2.13) + activesupport (3.2.13) + i18n (= 0.6.1) + multi_json (~> 1.0) + addressable (2.3.3) + arbre (1.0.1) + activesupport (>= 3.0.0) + arel (3.0.2) + bcrypt-ruby (3.0.1) + bourbon (3.1.1) + sass (>= 3.2.0) + thor + builder (3.0.4) + cancan (1.6.9) + capybara (2.0.3) + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + selenium-webdriver (~> 2.0) + xpath (~> 1.0.0) + carrierwave (0.8.0) + activemodel (>= 3.2.0) + activesupport (>= 3.2.0) + childprocess (0.3.9) + ffi (~> 1.0, >= 1.0.11) + coderay (1.0.9) + coffee-rails (3.2.2) + coffee-script (>= 2.2.0) + railties (~> 3.2.0) + coffee-script (2.2.0) + coffee-script-source + execjs + coffee-script-source (1.6.2) + css_parser (1.3.4) + addressable + cucumber (1.2.5) + builder (>= 2.1.2) + diff-lcs (>= 1.1.3) + gherkin (~> 2.11.7) + multi_json (~> 1.3) + cucumber-rails (1.3.1) + capybara (>= 1.1.2) + cucumber (>= 1.2.0) + nokogiri (>= 1.5.0) + rails (~> 3.0) + database_cleaner (0.9.1) + devise (2.2.3) + bcrypt-ruby (~> 3.0) + orm_adapter (~> 0.1) + railties (~> 3.1) + warden (~> 1.2.1) + diff-lcs (1.2.2) + email_spec (1.4.0) + launchy (~> 2.1) + mail (~> 2.2) + erubis (2.7.0) + eventmachine (1.0.3) + execjs (1.4.0) + multi_json (~> 1.0) + factory_girl (4.2.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.2.1) + factory_girl (~> 4.2.0) + railties (>= 3.0.0) + fastercsv (1.5.5) + faye-websocket (0.4.7) + eventmachine (>= 0.12.0) + ffi (1.6.0) + formtastic (2.2.1) + actionpack (>= 3.0) + gherkin (2.11.7) + multi_json (~> 1.3) + haml (4.0.2) + tilt + haml-rails (0.4) + actionpack (>= 3.1, < 4.1) + activesupport (>= 3.1, < 4.1) + haml (>= 3.1, < 4.1) + railties (>= 3.1, < 4.1) + has_scope (0.5.1) + hike (1.2.1) + http_parser.rb (0.5.3) + i18n (0.6.1) + inherited_resources (1.4.0) + has_scope (~> 0.5.0) + responders (~> 0.9) + journey (1.0.4) + jquery-fileupload-rails (0.4.1) + actionpack (>= 3.1) + railties (>= 3.1) + jquery-rails (2.2.1) + railties (>= 3.0, < 5.0) + thor (>= 0.14, < 2.0) + jquery_mobile_rails (1.3.0) + railties (>= 3.1.0) + json (1.7.7) + kaminari (0.14.1) + actionpack (>= 3.0.0) + activesupport (>= 3.0.0) + launchy (2.2.0) + addressable (~> 2.3) + letter_opener (1.1.0) + launchy (~> 2.2.0) + mail (2.5.3) + i18n (>= 0.4.0) + mime-types (~> 1.16) + treetop (~> 1.4.8) + meta_search (1.1.3) + actionpack (~> 3.1) + activerecord (~> 3.1) + activesupport (~> 3.1) + polyamorous (~> 0.5.0) + method_source (0.8.1) + mime-types (1.22) + multi_json (1.7.2) + nokogiri (1.5.9) + notifier (0.4.1) + orm_adapter (0.4.0) + poltergeist (1.1.2) + capybara (~> 2.0.1) + faye-websocket (~> 0.4.4) + http_parser.rb (~> 0.5.3) + polyamorous (0.5.0) + activerecord (~> 3.0) + polyglot (0.3.3) + pry (0.9.12.2) + coderay (~> 1.0.5) + method_source (~> 0.8) + slop (~> 3.4) + rack (1.4.5) + rack-cache (1.2) + rack (>= 0.4) + rack-ssl (1.3.3) + rack + rack-test (0.6.2) + rack (>= 1.0) + rails (3.2.13) + actionmailer (= 3.2.13) + actionpack (= 3.2.13) + activerecord (= 3.2.13) + activeresource (= 3.2.13) + activesupport (= 3.2.13) + bundler (~> 1.0) + railties (= 3.2.13) + railties (3.2.13) + actionpack (= 3.2.13) + activesupport (= 3.2.13) + rack-ssl (~> 1.3.2) + rake (>= 0.8.7) + rdoc (~> 3.4) + thor (>= 0.14.6, < 2.0) + rake (10.0.4) + rdoc (3.12.2) + json (~> 1.4) + responders (0.9.3) + railties (~> 3.1) + rmagick (2.13.2) + roadie (2.4.1) + actionmailer (> 3.0.0, < 5.0.0) + css_parser (~> 1.3.4) + nokogiri (> 1.5.0, < 1.7.0) + sprockets + rspec-core (2.13.1) + rspec-expectations (2.13.0) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.13.1) + rspec-rails (2.13.0) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 2.13.0) + rspec-expectations (~> 2.13.0) + rspec-mocks (~> 2.13.0) + rubyzip (0.9.9) + sass (3.2.7) + sass-rails (3.2.6) + railties (~> 3.2.0) + sass (>= 3.1.10) + tilt (~> 1.3) + selenium-webdriver (2.31.0) + childprocess (>= 0.2.5) + multi_json (~> 1.0) + rubyzip + websocket (~> 1.0.4) + shoulda-matchers (2.0.0) + activesupport (>= 3.0.0) + slop (3.4.5) + sprockets (2.2.2) + hike (~> 1.2) + multi_json (~> 1.0) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sqlite3 (1.3.7) + test_notifier (1.0.1) + notifier + thor (0.18.1) + tilt (1.3.6) + treetop (1.4.12) + polyglot + polyglot (>= 0.3.1) + tzinfo (0.3.37) + uglifier (2.0.1) + execjs (>= 0.3.0) + multi_json (~> 1.0, >= 1.0.2) + warden (1.2.1) + rack (>= 1.0) + websocket (1.0.7) + xpath (1.0.0) + nokogiri (~> 1.3) + +PLATFORMS + ruby + +DEPENDENCIES + activeadmin + cancan + capybara + carrierwave + coffee-rails (~> 3.2.1) + cucumber-rails + database_cleaner + email_spec + factory_girl_rails + haml-rails + jquery-fileupload-rails + jquery-rails + jquery_mobile_rails + letter_opener + poltergeist + pry + rails (= 3.2.13) + rieles! + rmagick + roadie + rspec-rails + sass-rails (~> 3.2.3) + shoulda-matchers + sqlite3 + test_notifier + uglifier (>= 1.0.3) diff --git a/README.md b/README.md new file mode 100644 index 0000000..fa65e78 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +=== Sistema de Denuncia Pública para dispositivos móviles. + diff --git a/README.rdoc b/README.rdoc new file mode 100644 index 0000000..3e1c15c --- /dev/null +++ b/README.rdoc @@ -0,0 +1,261 @@ +== Welcome to Rails + +Rails is a web-application framework that includes everything needed to create +database-backed web applications according to the Model-View-Control pattern. + +This pattern splits the view (also called the presentation) into "dumb" +templates that are primarily responsible for inserting pre-built data in between +HTML tags. The model contains the "smart" domain objects (such as Account, +Product, Person, Post) that holds all the business logic and knows how to +persist themselves to a database. The controller handles the incoming requests +(such as Save New Account, Update Product, Show Post) by manipulating the model +and directing data to the view. + +In Rails, the model is handled by what's called an object-relational mapping +layer entitled Active Record. This layer allows you to present the data from +database rows as objects and embellish these data objects with business logic +methods. You can read more about Active Record in +link:files/vendor/rails/activerecord/README.html. + +The controller and view are handled by the Action Pack, which handles both +layers by its two parts: Action View and Action Controller. These two layers +are bundled in a single package due to their heavy interdependence. This is +unlike the relationship between the Active Record and Action Pack that is much +more separate. Each of these packages can be used independently outside of +Rails. You can read more about Action Pack in +link:files/vendor/rails/actionpack/README.html. + + +== Getting Started + +1. At the command prompt, create a new Rails application: + rails new myapp (where myapp is the application name) + +2. Change directory to myapp and start the web server: + cd myapp; rails server (run with --help for options) + +3. Go to http://localhost:3000/ and you'll see: + "Welcome aboard: You're riding Ruby on Rails!" + +4. Follow the guidelines to start developing your application. You can find +the following resources handy: + +* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html +* Ruby on Rails Tutorial Book: http://www.railstutorial.org/ + + +== Debugging Rails + +Sometimes your application goes wrong. Fortunately there are a lot of tools that +will help you debug it and get it back on the rails. + +First area to check is the application log files. Have "tail -f" commands +running on the server.log and development.log. Rails will automatically display +debugging and runtime information to these files. Debugging info will also be +shown in the browser on requests from 127.0.0.1. + +You can also log your own messages directly into the log file from your code +using the Ruby logger class from inside your controllers. Example: + + class WeblogController < ActionController::Base + def destroy + @weblog = Weblog.find(params[:id]) + @weblog.destroy + logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!") + end + end + +The result will be a message in your log file along the lines of: + + Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1! + +More information on how to use the logger is at http://www.ruby-doc.org/core/ + +Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are +several books available online as well: + +* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe) +* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide) + +These two books will bring you up to speed on the Ruby language and also on +programming in general. + + +== Debugger + +Debugger support is available through the debugger command when you start your +Mongrel or WEBrick server with --debugger. This means that you can break out of +execution at any point in the code, investigate and change the model, and then, +resume execution! You need to install ruby-debug to run the server in debugging +mode. With gems, use sudo gem install ruby-debug. Example: + + class WeblogController < ActionController::Base + def index + @posts = Post.all + debugger + end + end + +So the controller will accept the action, run the first line, then present you +with a IRB prompt in the server window. Here you can do things like: + + >> @posts.inspect + => "[#nil, "body"=>nil, "id"=>"1"}>, + #"Rails", "body"=>"Only ten..", "id"=>"2"}>]" + >> @posts.first.title = "hello from a debugger" + => "hello from a debugger" + +...and even better, you can examine how your runtime objects actually work: + + >> f = @posts.first + => #nil, "body"=>nil, "id"=>"1"}> + >> f. + Display all 152 possibilities? (y or n) + +Finally, when you're ready to resume execution, you can enter "cont". + + +== Console + +The console is a Ruby shell, which allows you to interact with your +application's domain model. Here you'll have all parts of the application +configured, just like it is when the application is running. You can inspect +domain models, change values, and save to the database. Starting the script +without arguments will launch it in the development environment. + +To start the console, run rails console from the application +directory. + +Options: + +* Passing the -s, --sandbox argument will rollback any modifications + made to the database. +* Passing an environment name as an argument will load the corresponding + environment. Example: rails console production. + +To reload your controllers and models after launching the console run +reload! + +More information about irb can be found at: +link:http://www.rubycentral.org/pickaxe/irb.html + + +== dbconsole + +You can go to the command line of your database directly through rails +dbconsole. You would be connected to the database with the credentials +defined in database.yml. Starting the script without arguments will connect you +to the development database. Passing an argument will connect you to a different +database, like rails dbconsole production. Currently works for MySQL, +PostgreSQL and SQLite 3. + +== Description of Contents + +The default directory structure of a generated Ruby on Rails application: + + |-- app + | |-- assets + | | |-- images + | | |-- javascripts + | | `-- stylesheets + | |-- controllers + | |-- helpers + | |-- mailers + | |-- models + | `-- views + | `-- layouts + |-- config + | |-- environments + | |-- initializers + | `-- locales + |-- db + |-- doc + |-- lib + | |-- assets + | `-- tasks + |-- log + |-- public + |-- script + |-- test + | |-- fixtures + | |-- functional + | |-- integration + | |-- performance + | `-- unit + |-- tmp + | `-- cache + | `-- assets + `-- vendor + |-- assets + | |-- javascripts + | `-- stylesheets + `-- plugins + +app + Holds all the code that's specific to this particular application. + +app/assets + Contains subdirectories for images, stylesheets, and JavaScript files. + +app/controllers + Holds controllers that should be named like weblogs_controller.rb for + automated URL mapping. All controllers should descend from + ApplicationController which itself descends from ActionController::Base. + +app/models + Holds models that should be named like post.rb. Models descend from + ActiveRecord::Base by default. + +app/views + Holds the template files for the view that should be named like + weblogs/index.html.erb for the WeblogsController#index action. All views use + eRuby syntax by default. + +app/views/layouts + Holds the template files for layouts to be used with views. This models the + common header/footer method of wrapping views. In your views, define a layout + using the layout :default and create a file named default.html.erb. + Inside default.html.erb, call <% yield %> to render the view using this + layout. + +app/helpers + Holds view helpers that should be named like weblogs_helper.rb. These are + generated for you automatically when using generators for controllers. + Helpers can be used to wrap functionality for your views into methods. + +config + Configuration files for the Rails environment, the routing map, the database, + and other dependencies. + +db + Contains the database schema in schema.rb. db/migrate contains all the + sequence of Migrations for your schema. + +doc + This directory is where your application documentation will be stored when + generated using rake doc:app + +lib + Application specific libraries. Basically, any kind of custom code that + doesn't belong under controllers, models, or helpers. This directory is in + the load path. + +public + The directory available for the web server. Also contains the dispatchers and the + default HTML files. This should be set as the DOCUMENT_ROOT of your web + server. + +script + Helper scripts for automation and generation. + +test + Unit and functional tests along with fixtures. When using the rails generate + command, template test files will be generated for you and placed in this + directory. + +vendor + External libraries that the application depends on. Also includes the plugins + subdirectory. If the app has frozen rails, those gems also go here, under + vendor/rails/. This directory is in the load path. diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..a5b7f87 --- /dev/null +++ b/Rakefile @@ -0,0 +1,7 @@ +#!/usr/bin/env rake +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require File.expand_path('../config/application', __FILE__) + +Denunciapp::Application.load_tasks diff --git a/app/admin/admin_user.rb b/app/admin/admin_user.rb new file mode 100644 index 0000000..3aac52f --- /dev/null +++ b/app/admin/admin_user.rb @@ -0,0 +1,20 @@ +ActiveAdmin.register AdminUser do + index do + column :email + column :current_sign_in_at + column :last_sign_in_at + column :sign_in_count + default_actions + end + + filter :email + + form do |f| + f.inputs "Admin Details" do + f.input :email + f.input :password + f.input :password_confirmation + end + f.actions + end +end diff --git a/app/admin/dashboard.rb b/app/admin/dashboard.rb new file mode 100644 index 0000000..6083757 --- /dev/null +++ b/app/admin/dashboard.rb @@ -0,0 +1,33 @@ +ActiveAdmin.register_page "Dashboard" do + + menu :priority => 1, :label => proc{ I18n.t("active_admin.dashboard") } + + content :title => proc{ I18n.t("active_admin.dashboard") } do + div :class => "blank_slate_container", :id => "dashboard_default_message" do + span :class => "blank_slate" do + span I18n.t("active_admin.dashboard_welcome.welcome") + small I18n.t("active_admin.dashboard_welcome.call_to_action") + end + end + + # Here is an example of a simple dashboard with columns and panels. + # + # columns do + # column do + # panel "Recent Posts" do + # ul do + # Post.recent(5).map do |post| + # li link_to(post.title, admin_post_path(post)) + # end + # end + # end + # end + + # column do + # panel "Info" do + # para "Welcome to ActiveAdmin." + # end + # end + # end + end # content +end diff --git a/app/admin/denuncias.rb b/app/admin/denuncias.rb new file mode 100644 index 0000000..398c6dc --- /dev/null +++ b/app/admin/denuncias.rb @@ -0,0 +1,54 @@ +ActiveAdmin.register Denuncia do + + scope :all, :default => true + scope :finalizadas + scope :abiertas + + controller do + def scoped_collection + resource_class.includes(:dependencia) + end + end + + index do + selectable_column + column 'Folio', :id + column :dependencia, :sortable => 'dependencias.nombre' + column 'Nombre del funcionario', :funcionario + column 'Denunciante', :email + column 'Creada en', :created_at + column 'Estado', :finalizada do |denuncia| + status_tag (denuncia.finalizada? ? 'Finalizada' : 'Abierta'), (denuncia.finalizada? ? :ok : :warning) + end + actions :defaults => false do |denuncia| + link_to 'Detalles', admin_denuncia_path(denuncia) + end + # default_actions + end + + show do |denuncia| + attributes_table do + row :id + row :funcionario + row :queja + row :email + row :dependencia + row :created_at + row :updated_at + row :finalizada do + status_tag (denuncia.finalizada? ? 'Finalizada' : 'Abierta'), (denuncia.finalizada? ? :ok : :warning) + end + row :adjuntos do + ul :class => 'adjuntos' do + denuncia.archivos.each do |archivo| + li do + link_to image_tag(archivo.adjunto.url(:thumb)), archivo.adjunto.url + end + end + end + end + end + active_admin_comments + end + +end diff --git a/app/admin/dependencias.rb b/app/admin/dependencias.rb new file mode 100644 index 0000000..58dfda1 --- /dev/null +++ b/app/admin/dependencias.rb @@ -0,0 +1,3 @@ +ActiveAdmin.register Dependencia do + +end diff --git a/app/assets/images/dependencia.png b/app/assets/images/dependencia.png new file mode 100644 index 0000000..6ba4d91 Binary files /dev/null and b/app/assets/images/dependencia.png differ diff --git a/app/assets/images/logo_top.png b/app/assets/images/logo_top.png new file mode 100644 index 0000000..ea98b8a Binary files /dev/null and b/app/assets/images/logo_top.png differ diff --git a/app/assets/images/rails.png b/app/assets/images/rails.png new file mode 100644 index 0000000..d5edc04 Binary files /dev/null and b/app/assets/images/rails.png differ diff --git a/app/assets/images/watermark.png b/app/assets/images/watermark.png new file mode 100644 index 0000000..bb63ec5 Binary files /dev/null and b/app/assets/images/watermark.png differ diff --git a/app/assets/javascripts/active_admin.js b/app/assets/javascripts/active_admin.js new file mode 100644 index 0000000..d2b66c5 --- /dev/null +++ b/app/assets/javascripts/active_admin.js @@ -0,0 +1 @@ +//= require active_admin/base diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js new file mode 100644 index 0000000..c6d8c8b --- /dev/null +++ b/app/assets/javascripts/application.js @@ -0,0 +1,17 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// the compiled file. +// +// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD +// GO AFTER THE REQUIRES BELOW. +// +//= require jquery +//= require jquery_ujs +//= require jquery-fileupload/basic +//= require_tree . +//= require jquery.mobile diff --git a/app/assets/javascripts/archivos.js.coffee b/app/assets/javascripts/archivos.js.coffee new file mode 100644 index 0000000..e80d430 --- /dev/null +++ b/app/assets/javascripts/archivos.js.coffee @@ -0,0 +1,8 @@ +# 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/ + +@cargaEliminarArchivo = () -> + $('ul#archivos a.delete-attachment').click () -> + url = $(this).data('url') + $('a#delete-attachment').attr('href', url) diff --git a/app/assets/javascripts/denuncias.js.coffee b/app/assets/javascripts/denuncias.js.coffee new file mode 100644 index 0000000..81c070c --- /dev/null +++ b/app/assets/javascripts/denuncias.js.coffee @@ -0,0 +1,19 @@ +# 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/ + +@limpiarFormulario = () -> + $('input[type=text], textarea').val('') + $('select').each -> + this.selectedIndex = 0 + $('select').selectmenu('refresh', true) + $('textarea').html('') + +@cargaLimpiarFormulario = () -> + $('#confirm-clean a#clean-form').click () => + @limpiarFormulario() + $('#confirm-clean').popup('close') + +$(document).on 'pageinit', (e) -> + $('form#new_denuncia').on 'submit', -> + $(this).append $('#archivos').hide() diff --git a/app/assets/javascripts/home.js.coffee b/app/assets/javascripts/home.js.coffee new file mode 100644 index 0000000..7615679 --- /dev/null +++ b/app/assets/javascripts/home.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/active_admin.css.scss b/app/assets/stylesheets/active_admin.css.scss new file mode 100644 index 0000000..fd13489 --- /dev/null +++ b/app/assets/stylesheets/active_admin.css.scss @@ -0,0 +1,35 @@ +// SASS variable overrides must be declared before loading up Active Admin's styles. +// +// To view the variables that Active Admin provides, take a look at +// `app/assets/stylesheets/active_admin/mixins/_variables.css.scss` in the +// Active Admin source. +// +// For example, to change the sidebar width: +// $sidebar-width: 242px; + +// Active Admin's got SASS! +@import "active_admin/mixins"; +@import "active_admin/base"; + +ul.adjuntos li{ + display: inline; + padding: 0 10px; +} + + +// Overriding any non-variable SASS must be done after the fact. +// For example, to change the default status-tag color: +// +// body.active_admin { +// .status_tag { background: #6090DB; } +// } +// +// Notice that Active Admin CSS rules are nested within a +// 'body.active_admin' selector to prevent conflicts with +// other pages in the app. It is best to wrap your changes in a +// namespace so they are properly recognized. You have options +// if you e.g. want different styles for different namespaces: +// +// .active_admin applies to any Active Admin namespace +// .admin_namespace applies to the admin namespace (eg: /admin) +// .other_namespace applies to a custom namespace named other (eg: /other) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css new file mode 100644 index 0000000..0e95eb4 --- /dev/null +++ b/app/assets/stylesheets/application.css @@ -0,0 +1,37 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the top of the + * compiled file, but it's generally better to create a new file per style scope. + * + *= require_self + *= require_tree . + *= require jquery.mobile + */ + +.parrafo{ + text-align: justify; +} + +#cabecera{ + background: url('dependencia.png') no-repeat; + height: 100px; +} + +div[data-role="content"]{ + background-image: url('watermark.png'); + background-attachment: fixed; + background-repeat: no-repeat; + background-position: center; +} + +#desarrollado{ + width: 100%; + text-align: center; + padding: 10px 0; + font-size: .7em; +} diff --git a/app/assets/stylesheets/archivos.css.scss b/app/assets/stylesheets/archivos.css.scss new file mode 100644 index 0000000..addb32b --- /dev/null +++ b/app/assets/stylesheets/archivos.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Archivos controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/denuncias.css.scss b/app/assets/stylesheets/denuncias.css.scss new file mode 100644 index 0000000..1ca83af --- /dev/null +++ b/app/assets/stylesheets/denuncias.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Denuncias controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/home.css.scss b/app/assets/stylesheets/home.css.scss new file mode 100644 index 0000000..f0ddc68 --- /dev/null +++ b/app/assets/stylesheets/home.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the home controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/mailer.css b/app/assets/stylesheets/mailer.css new file mode 100644 index 0000000..ad146f1 --- /dev/null +++ b/app/assets/stylesheets/mailer.css @@ -0,0 +1,57 @@ +body { + background-color:#FFFFFF; +} + +.Estilo1 { + color: #000000; + font-size: 14pt; +} + +.Estilo2 { + color: #000000; + font-size: 14px; +} + +td { + font-family:verdana; + color: #ffffff; + font-size:8pt; +} + +.text { + font-family:verdana; + color: #000000; + font-size:8pt; + text-transform: none; +} + +.arnegro11 +{ + COLOR: #000000; + FONT-FAMILY: Arial, Helvetica, sans-serif; + FONT-SIZE: 11px; + font-style: line-height:200%; +} + +.arnegro12b +{ + COLOR: #FFFFFF; + FONT-FAMILY: Arial, Helvetica, sans-serif; + FONT-SIZE: 12px; + FONT-WEIGHT: normal; + background-color:#164450; +} + +p { + text-align:center; +} + +.cuadro { + border: #666666; + border-style: solid; + border-top-width: 1px; + border-right-width: 1px; + border-bottom-width: 1px; + border-left-width: 1px; + background-color: #FFFFFF; +} diff --git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss new file mode 100644 index 0000000..b53c2a1 --- /dev/null +++ b/app/assets/stylesheets/scaffolds.css.scss @@ -0,0 +1,65 @@ +body { + background-color: #fff; + color: #333; + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +p, ol, ul, td { + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +pre { + background-color: #eee; + padding: 10px; + font-size: 11px; +} + +a { + color: #000; + &:visited { + color: #666; + } +} + +div { + &.field, &.actions { + margin-bottom: 10px; + } +} + +#notice { + color: green; +} + +.field_with_errors { + color: #b94a48; + display: inline; +} + + +#error_explanation { + width: 450px; + border: 2px solid red; + padding: 7px; + padding-bottom: 0; + margin-bottom: 20px; + background-color: #f0f0f0; + h2 { + text-align: left; + font-weight: bold; + padding: 5px 5px 5px 15px; + font-size: 12px; + margin: -7px; + margin-bottom: 0px; + background-color: #c00; + color: #fff; + } + ul li { + font-size: 12px; + list-style: square; + } +} diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb new file mode 100644 index 0000000..e8065d9 --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,3 @@ +class ApplicationController < ActionController::Base + protect_from_forgery +end diff --git a/app/controllers/denuncias_controller.rb b/app/controllers/denuncias_controller.rb new file mode 100644 index 0000000..260add7 --- /dev/null +++ b/app/controllers/denuncias_controller.rb @@ -0,0 +1,53 @@ +class DenunciasController < ApplicationController + before_filter :load_file_params, only: :create + + # GET /denuncias/1 + # GET /denuncias/1.json + def show + @denuncia = Denuncia.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @denuncia } + end + end + + # GET /denuncias/new + # GET /denuncias/new.json + def new + @denuncia = Denuncia.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @denuncia } + end + end + + # POST /denuncias + # POST /denuncias.json + def create + @denuncia = Denuncia.new + + respond_to do |format| + if @denuncia.finalize(params[:denuncia]) + format.html { redirect_to @denuncia, notice: 'Su denuncia ha sido creada exitosamente.' } + format.json { render json: @denuncia, status: :created, location: @denuncia } + else + format.html { render action: "new" } + format.json { render json: @denuncia.errors, status: :unprocessable_entity } + end + end + end + + private + + def load_file_params + return if params[:archivos].nil? || params[:archivos].empty? + archivo_attributes = [] + params[:archivos].each do |archivo| + archivo_attributes << { adjunto: archivo } + end + params[:denuncia][:archivos_attributes] = archivo_attributes + end + +end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb new file mode 100644 index 0000000..b178708 --- /dev/null +++ b/app/controllers/home_controller.rb @@ -0,0 +1,7 @@ +class HomeController < ApplicationController + def index + end + + def about + end +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb new file mode 100644 index 0000000..1d4097e --- /dev/null +++ b/app/helpers/application_helper.rb @@ -0,0 +1,22 @@ +module ApplicationHelper + + # Carga los elementos que se hayan definido en el tema actual + def theme key_sym + return if not key_sym + if development? + development_theme key_sym + else + THEME[key_sym.to_s] + end + end + + private + + def development? + Rails.env.development? + end + + def development_theme key + YAML.load_file( File.join( Rails.root, "config/theme/theme.yml" ) )[key.to_s] + end +end diff --git a/app/helpers/denuncias_helper.rb b/app/helpers/denuncias_helper.rb new file mode 100644 index 0000000..1e1e6f8 --- /dev/null +++ b/app/helpers/denuncias_helper.rb @@ -0,0 +1,2 @@ +module DenunciasHelper +end diff --git a/app/helpers/home_helper.rb b/app/helpers/home_helper.rb new file mode 100644 index 0000000..23de56a --- /dev/null +++ b/app/helpers/home_helper.rb @@ -0,0 +1,2 @@ +module HomeHelper +end diff --git a/app/mailers/denuncia_mailer.rb b/app/mailers/denuncia_mailer.rb new file mode 100644 index 0000000..85dc03f --- /dev/null +++ b/app/mailers/denuncia_mailer.rb @@ -0,0 +1,14 @@ +class DenunciaMailer < ActionMailer::Base + default from: "from@example.com", subject: 'Denuncia generada desde Denuncia Ciudadana', css: :mailer + + # Subject can be set in your I18n file at config/locales/en.yml + # with the following lookup: + # + # en.denuncia_mailer.confirmar_denuncia.subject + # + def confirmar_denuncia(denuncia) + @denuncia = denuncia + + mail to: @denuncia.email + end +end diff --git a/app/models/admin_user.rb b/app/models/admin_user.rb new file mode 100644 index 0000000..4a1624f --- /dev/null +++ b/app/models/admin_user.rb @@ -0,0 +1,11 @@ +class AdminUser < ActiveRecord::Base + # Include default devise modules. Others available are: + # :token_authenticatable, :confirmable, + # :lockable, :timeoutable and :omniauthable + devise :database_authenticatable, + :recoverable, :rememberable, :trackable, :validatable + + # Setup accessible (or protected) attributes for your model + attr_accessible :email, :password, :password_confirmation, :remember_me + # attr_accessible :title, :body +end diff --git a/app/models/archivo.rb b/app/models/archivo.rb new file mode 100644 index 0000000..aaa935f --- /dev/null +++ b/app/models/archivo.rb @@ -0,0 +1,18 @@ +class Archivo < ActiveRecord::Base + belongs_to :denuncia + attr_accessible :adjunto + + validates :url_id, uniqueness: true, presence: true + + before_validation :generate_url_id + + mount_uploader :adjunto, AdjuntoUploader + + def nombre + File.basename self.adjunto.url + end + + def generate_url_id + self.url_id ||= Digest::SHA1.hexdigest([Time.now, rand].join) + end +end diff --git a/app/models/denuncia.rb b/app/models/denuncia.rb new file mode 100644 index 0000000..5d9b714 --- /dev/null +++ b/app/models/denuncia.rb @@ -0,0 +1,27 @@ +class Denuncia < ActiveRecord::Base + # relations + belongs_to :dependencia + has_many :archivos + + # scopes + scope :finalizadas, where(:finalizada => true) + scope :abiertas, where("finalizada IS NULL") + + # accessors + attr_accessible :email, :funcionario, :queja, :dependencia_id, :archivos_attributes + + # nested attributes + accepts_nested_attributes_for :archivos, allow_destroy: true + + # validations + validates :funcionario, :queja, :dependencia, :email, :finalizada, presence: true + validates :email, format: { with: /\A[^@]+@([^@\.]+\.)+[^@\.]+\z/ } + + def finalize(attributes) + self.assign_attributes attributes + self.finalizada = true + result = self.save + DenunciaMailer.confirmar_denuncia(self).deliver if result + result + end +end diff --git a/app/models/dependencia.rb b/app/models/dependencia.rb new file mode 100644 index 0000000..2dbc48b --- /dev/null +++ b/app/models/dependencia.rb @@ -0,0 +1,15 @@ +class Dependencia < ActiveRecord::Base + # accessors + attr_accessible :nombre + + # relations + has_many :denuncias + + # validations + validates :nombre, presence: true + + # methods + def to_s + self.nombre + end +end diff --git a/app/uploaders/adjunto_uploader.rb b/app/uploaders/adjunto_uploader.rb new file mode 100644 index 0000000..fabe421 --- /dev/null +++ b/app/uploaders/adjunto_uploader.rb @@ -0,0 +1,59 @@ +# encoding: utf-8 + +class AdjuntoUploader < CarrierWave::Uploader::Base + + # Include RMagick or MiniMagick support: + include CarrierWave::RMagick + # include CarrierWave::MiniMagick + + # Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility: + # include Sprockets::Helpers::RailsHelper + # include Sprockets::Helpers::IsolatedHelper + + # Choose what kind of storage to use for this uploader: + storage :file + # storage :fog + + # Override the directory where uploaded files will be stored. + # This is a sensible default for uploaders that are meant to be mounted: + def store_dir + "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" + end + + # Provide a default URL as a default if there hasn't been a file uploaded: + # def default_url + # # For Rails 3.1+ asset pipeline compatibility: + # # asset_path("fallback/" + [version_name, "default.png"].compact.join('_')) + # + # "/images/fallback/" + [version_name, "default.png"].compact.join('_') + # end + + # Process files as they are uploaded: + # process :scale => [200, 300] + # + # def scale(width, height) + # # do something + # end + + # Create different versions of your uploaded files: + # version :thumb do + # process :scale => [50, 50] + # end + + version :thumb do + process :resize_to_limit => [250, nil] + end + + # Add a white list of extensions which are allowed to be uploaded. + # For images you might use something like this: + def extension_white_list + %w(jpg jpeg gif png) + end + + # Override the filename of the uploaded files: + # Avoid using model.id or version_name here, see uploader/store.rb for details. + # def filename + # "something.jpg" if original_filename + # end + +end diff --git a/app/views/denuncia_mailer/confirmar_denuncia.html.haml b/app/views/denuncia_mailer/confirmar_denuncia.html.haml new file mode 100644 index 0000000..007fa74 --- /dev/null +++ b/app/views/denuncia_mailer/confirmar_denuncia.html.haml @@ -0,0 +1,49 @@ +%table.cuadro{:align => "center", :width => "600"} + %tr + %td + %table{:align => "center", :border => "0", :width => "600"} + %tr + %td{:height => "143"} + %table{:border => "0", :width => "90%"} + %tr + %td{:rowspan => "3", :width => "33%"} + %p + = image_tag "logo_top.png", :height => "104", :width => "63" + %td{:width => "67%"} + \  + %tr + %td + %p.Estilo1 + DEPEDENCIA + %tr + %td + %p + %span.Estilo2 + SECRETARIA + %br + %br + %table{:align => "center", :border => "0", :width => "550"} + %tr + %td.arnegro11 + %div{:align => "right"} + Localidad, Municipio. + = Date.today.strftime "%d de %B de %Y" + %tr + %td.arnegro12b + %p + %strong + Denuncia Ciudadana + %tr + %td + \  + %tr + %td.arnegro11 + %p{:style => "line-height:200%"} + El número de folio asignado a tu Queja y/o Denuncia es: + %br + %strong= "%010d" % @denuncia.id + %br + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam porttitor porta imperdiet. Aenean in tellus sapien. Etiam tristique augue non feugiat elementum. Suspendisse sit amet egestas quam, non lacinia sapien. Integer tristique imperdiet tortor, sit amet pellentesque lectus convallis quis. Phasellus mollis mauris eu ultricies imperdiet + %tr + %td + \  diff --git a/app/views/denuncia_mailer/confirmar_denuncia.text.haml b/app/views/denuncia_mailer/confirmar_denuncia.text.haml new file mode 100644 index 0000000..17fda4b --- /dev/null +++ b/app/views/denuncia_mailer/confirmar_denuncia.text.haml @@ -0,0 +1,13 @@ +DEPENDENCIA + +SECRETARÍA + +Localidad, Municipio += Date.today.strftime "%d de %B de %Y" + +Denuncia Ciudadana + +El número de folio asignado a tu Queja y/o Denuncia es: += "%010d" % @denuncia.id + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam porttitor porta imperdiet. Aenean in tellus sapien. Etiam tristique augue non feugiat elementum. Suspendisse sit amet egestas quam, non lacinia sapien. Integer tristique imperdiet tortor, sit amet pellentesque lectus convallis quis. Phasellus mollis mauris eu ultricies imperdiet. diff --git a/app/views/denuncias/_form.html.haml b/app/views/denuncias/_form.html.haml new file mode 100644 index 0000000..83fac6e --- /dev/null +++ b/app/views/denuncias/_form.html.haml @@ -0,0 +1,24 @@ += form_for @denuncia, html: { multipart: true, "data-ajax" => "false" } do |f| + = render 'error_messages', target: @denuncia + + %div{"data-role" => "fieldcontain"} + %fieldset{"data-role" => "controlgroup"} + = f.label :dependencia_id + = f.select :dependencia_id, Dependencia.all.collect { |d| [d.nombre, d.id] }, { include_blank: true } + + %div{"data-role" => "fieldcontain"} + %fieldset{"data-role" => "controlgroup"} + = f.label :funcionario + = f.text_field :funcionario, placeholder: "Ingresa el nombre del funcionario" + + %div{"data-role" => "fieldcontain"} + %fieldset{"data-role" => "controlgroup"} + = f.label :queja + = f.text_area :queja, placeholder: "Ingresa tu queja o denuncia" + + %div{"data-role" => "fieldcontain"} + %fieldset{"data-role" => "controlgroup"} + = f.label :email + = f.text_field :email, placeholder: "Para dar seguimiento a tu denuncia" + + = f.submit 'Crear denuncia', data: { corners: 'true', shadow: 'true', theme: theme(:denuncias_form_crear), icon: "check", iconpos: "left", transition: "fade" } diff --git a/app/views/denuncias/new.html.haml b/app/views/denuncias/new.html.haml new file mode 100644 index 0000000..57e8d89 --- /dev/null +++ b/app/views/denuncias/new.html.haml @@ -0,0 +1,56 @@ += content_for :header do + = render 'shared/cabecera' + +%p.ui-body-d.ui-corner-all{:style => "padding:0.5em;"} + Puedes adjuntar archivos a tu denuncia + %a.ui-icon-alt{"data-icon" => "info", "data-iconpos" => "notext", "data-inline" => "true", "data-rel" => "popup", "data-role" => "button", "data-theme" => theme(:denuncias_new_info_adjuntar), "data-transition" => "pop", :href => "#popupInfo"} Información + += render 'form' + += content_for :footer do + %div{"data-iconpos" => "top", "data-role" => "navbar"} + %ul + %li + %a{"data-icon" => "info", "data-rel" => "dialog", "data-theme" => theme(:denuncias_new_informacion), "data-transition" => "fade", "data-prefetch" => true, :href => home_about_path } + Información + %li + %a{"data-icon" => "search", "data-theme" => theme(:denuncias_new_archivo), "data-transition" => "fade", :href => "#upload-panel"} + Archivo + %li + %a{"data-icon" => "delete", "data-rel" => "popup", "data-theme" => theme(:denuncias_new_limpiar), "data-transition" => "pop", :href => "#confirm-clean"} + Limpiar + = render 'shared/lbs' + += content_for :extra do + #upload-panel{ data: { role: 'panel' } } + %h2 Archivos + %p + Puedes adjuntar fotografías o audio a tu denuncia + %input#archivos{ type: 'file', name: "archivos[]", multiple: true } + + %a{ href: '#', data: { rel: 'close', role: 'button', icon: 'delete', mini: 'true', inline: 'true' } } + Cerrar + + #confirm-clean{ data: { role: 'popup', dismissible: 'false' } } + %div{ data: { role: 'header' } } + %h1 Limpiar Formulario + + %div{ data: { role: 'content' } } + %h3 ¿Estás seguro de querer limpiar el formulario? + %p + Esta acción no se puede deshacer + %a{ href: '#', data: { role: 'button', inline: 'true', rel: 'back' } } + Cancelar + %a#clean-form{ href: '#', data: { role: 'button', inline: 'true', theme: theme(:denuncias_new_limpiar_confirm) } } + Limpiar + + #popupInfo.ui-content{"data-role" => "popup", "data-theme" => theme(:denuncias_new_popup_info), :style => "max-width:350px;"} + %p + Presiona el botón + %strong archivo + de la barra inferior para adjuntar archivos a tu denuncia + +:javascript + $(document).on('pageinit', function(event) { + cargaLimpiarFormulario(); + }); diff --git a/app/views/denuncias/show.html.haml b/app/views/denuncias/show.html.haml new file mode 100644 index 0000000..a525716 --- /dev/null +++ b/app/views/denuncias/show.html.haml @@ -0,0 +1,17 @@ += content_for :header do + = render 'shared/cabecera' + +%div{:style => " text-align:center"} + %p + El número de folio asignado a tu Queja o Denuncia es: + %h3 + = "%010d" % @denuncia.id + %p + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam porttitor porta imperdiet. Aenean in tellus sapien. Etiam tristique augue non feugiat elementum. Suspendisse sit amet egestas quam, non lacinia sapien. Integer tristique imperdiet tortor, sit amet pellentesque lectus convallis quis. Phasellus mollis mauris eu ultricies imperdiet + %p + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam porttitor porta imperdiet. Aenean in tellus sapien. Etiam tristique augue non feugiat elementum. Suspendisse sit amet egestas quam, non lacinia sapien. Integer tristique imperdiet tortor, sit amet pellentesque lectus convallis quis. Phasellus mollis mauris eu ultricies imperdiet + += link_to 'Deseo realizar otra denuncia', new_denuncia_path, data: { icon: "alert", iconpos: "left", role: "button", theme: theme(:denuncias_show_otra), transition: "fade" } + += content_for :footer do + = render 'shared/lbs' diff --git a/app/views/home/about.html.haml b/app/views/home/about.html.haml new file mode 100644 index 0000000..77b321d --- /dev/null +++ b/app/views/home/about.html.haml @@ -0,0 +1,11 @@ +.ui-corner-all{"data-overlay-theme" => theme(:about_dialog_overlay), "data-role" => "dialog", "data-theme" => theme(:about_dialog)} + .ui-corner-top{"data-role" => "header", "data-theme" => theme(:about_header)} + %h1 Información + .ui-corner-bottom.ui-content{"data-role" => "content", "data-theme" => theme(:about_content)} + %p + Denuncia Ciudadana es una aplicación móvil desarrollada sobre la web que permite el envío de denuncias ciudadanas, de forma anónima, con el único requisito de contar con una dirección de e - mail. + %p + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam porttitor porta imperdiet. Aenean in tellus sapien. Etiam tristique augue non feugiat elementum. Suspendisse sit amet egestas quam, non lacinia sapien. Integer tristique imperdiet tortor, sit amet pellentesque lectus convallis quis. Phasellus mollis mauris eu ultricies imperdiet + %p + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam porttitor porta imperdiet. Aenean in tellus sapien. Etiam tristique augue non feugiat elementum. Suspendisse sit amet egestas quam, non lacinia sapien. Integer tristique imperdiet tortor, sit amet pellentesque lectus convallis quis. Phasellus mollis mauris eu ultricies imperdiet + %a{"data-rel" => "back", "data-role" => "button", "data-theme" => theme(:about_cerrar), :href => "#"} Cerrar diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml new file mode 100644 index 0000000..d313daf --- /dev/null +++ b/app/views/home/index.html.haml @@ -0,0 +1,18 @@ += content_for :header do + = render 'shared/cabecera' + +%p.parrafo + Denuncia Ciudadana es una aplicación móvil desarrollada sobre la web que permite el envío de denuncias ciudadanas, de forma anónima, sólo contando con una dirección de e - mail. + +%p.parrafo + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam porttitor porta imperdiet. Aenean in tellus sapien. Etiam tristique augue non feugiat elementum. Suspendisse sit amet egestas quam, non lacinia sapien. Integer tristique imperdiet tortor, sit amet pellentesque lectus convallis quis. Phasellus mollis mauris eu ultricies imperdiet. + +%p.parrafo + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam porttitor porta imperdiet. Aenean in tellus sapien. Etiam tristique augue non feugiat elementum. Suspendisse sit amet egestas quam, non lacinia sapien. Integer tristique imperdiet tortor, sit amet pellentesque lectus convallis quis. Phasellus mollis mauris eu ultricies imperdiet. + += content_for :footer do + %div{"data-iconpos" => "right", "data-role" => "navbar"} + %ul + %li + = link_to 'Deseo realizar una denuncia', new_denuncia_path, data: { icon: "arrow-r", theme: theme(:index_new_denuncia), transition: "fade" } + = render 'shared/lbs' diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml new file mode 100644 index 0000000..b39adc7 --- /dev/null +++ b/app/views/layouts/application.html.haml @@ -0,0 +1,17 @@ +!!! +%html + %head + %title Denuncia Ciudadana + %meta{:charset => "utf-8"} + %meta{:content => "width=device-width, initial-scale=1", :name => "viewport"} + = stylesheet_link_tag "application", :media => "all" + = javascript_include_tag "application" + = csrf_meta_tags + %body{"data-role" => "page", "data-theme" => theme(:application_page)} + %div{"data-role" => "header", "data-theme" => theme(:application_header)} + = yield :header + %div{"data-role" => "content", "data-theme" => theme(:application_content)} + = yield + %div{"data-position" => "fixed", "data-role" => "footer", "data-theme" => theme(:application_footer)} + = yield :footer + = yield :extra diff --git a/app/views/shared/_cabecera.html.haml b/app/views/shared/_cabecera.html.haml new file mode 100644 index 0000000..aaf58a3 --- /dev/null +++ b/app/views/shared/_cabecera.html.haml @@ -0,0 +1 @@ +#cabecera diff --git a/app/views/shared/_lbs.html.haml b/app/views/shared/_lbs.html.haml new file mode 100644 index 0000000..b464843 --- /dev/null +++ b/app/views/shared/_lbs.html.haml @@ -0,0 +1,4 @@ +#desarrollado + Desarrollado por + %a{:href => "http://www.logicalbricks.com"} LogicalBricks Solutions + ® diff --git a/config.ru b/config.ru new file mode 100644 index 0000000..45525bb --- /dev/null +++ b/config.ru @@ -0,0 +1,4 @@ +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run Denunciapp::Application diff --git a/config/application.rb b/config/application.rb new file mode 100644 index 0000000..e0955e9 --- /dev/null +++ b/config/application.rb @@ -0,0 +1,62 @@ +require File.expand_path('../boot', __FILE__) + +require 'rails/all' + +if defined?(Bundler) + # If you precompile assets before deploying to production, use this line + Bundler.require(*Rails.groups(:assets => %w(development test))) + # If you want your assets lazily compiled in production, use this line + # Bundler.require(:default, :assets, Rails.env) +end + +module Denunciapp + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Custom directories with classes and modules you want to be autoloadable. + # config.autoload_paths += %W(#{config.root}/extras) + + # Only load the plugins named here, in the order given (default is alphabetical). + # :all can be used as a placeholder for all plugins not explicitly named. + # config.plugins = [ :exception_notification, :ssl_requirement, :all ] + + # Activate observers that should always be running. + # config.active_record.observers = :cacher, :garbage_collector, :forum_observer + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + config.i18n.default_locale = :es + + # Configure the default encoding used in templates for Ruby 1.9. + config.encoding = "utf-8" + + # Configure sensitive parameters which will be filtered from the log file. + config.filter_parameters += [:password] + + # Enable escaping HTML in JSON. + config.active_support.escape_html_entities_in_json = true + + # Use SQL instead of Active Record's schema dumper when creating the database. + # This is necessary if your schema can't be completely dumped by the schema dumper, + # like if you have constraints or database-specific column types + # config.active_record.schema_format = :sql + + # Enforce whitelist mode for mass assignment. + # This will create an empty whitelist of attributes available for mass-assignment for all models + # in your app. As such, your models will need to explicitly whitelist or blacklist accessible + # parameters by using an attr_accessible or attr_protected declaration. + config.active_record.whitelist_attributes = true + + # Enable the asset pipeline + config.assets.enabled = true + + # Version of your assets, change this if you want to expire all your assets + config.assets.version = '1.0' + end +end diff --git a/config/boot.rb b/config/boot.rb new file mode 100644 index 0000000..4489e58 --- /dev/null +++ b/config/boot.rb @@ -0,0 +1,6 @@ +require 'rubygems' + +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) + +require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) diff --git a/config/cucumber.yml b/config/cucumber.yml new file mode 100644 index 0000000..19b288d --- /dev/null +++ b/config/cucumber.yml @@ -0,0 +1,8 @@ +<% +rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : "" +rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}" +std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip" +%> +default: <%= std_opts %> features +wip: --tags @wip:3 --wip features +rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip diff --git a/config/database.yml b/config/database.yml new file mode 100644 index 0000000..09cc85a --- /dev/null +++ b/config/database.yml @@ -0,0 +1,28 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +development: + adapter: sqlite3 + database: db/development.sqlite3 + pool: 5 + timeout: 5000 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: &test + adapter: sqlite3 + database: db/test.sqlite3 + pool: 5 + timeout: 5000 + +production: + adapter: sqlite3 + database: db/production.sqlite3 + pool: 5 + timeout: 5000 + +cucumber: + <<: *test \ No newline at end of file diff --git a/config/environment.rb b/config/environment.rb new file mode 100644 index 0000000..e7f1d65 --- /dev/null +++ b/config/environment.rb @@ -0,0 +1,5 @@ +# Load the rails application +require File.expand_path('../application', __FILE__) + +# Initialize the rails application +Denunciapp::Application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb new file mode 100644 index 0000000..c53c9d8 --- /dev/null +++ b/config/environments/development.rb @@ -0,0 +1,42 @@ +Denunciapp::Application.configure do + # Settings specified here will take precedence over those in config/application.rb + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Log error messages when you accidentally call methods on nil. + config.whiny_nils = true + + # Show full error reports and disable caching + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Open email in browser instead of sending it + config.action_mailer.delivery_method = :letter_opener + + config.action_mailer.default_url_options = {:host => "localhost"} + + # Don't care if the mailer can't send + config.action_mailer.raise_delivery_errors = false + + # Print deprecation notices to the Rails logger + config.active_support.deprecation = :log + + # Only use best-standards-support built into browsers + config.action_dispatch.best_standards_support = :builtin + + # Raise exception on mass assignment protection for Active Record models + config.active_record.mass_assignment_sanitizer = :strict + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL) + config.active_record.auto_explain_threshold_in_seconds = 0.5 + + # Do not compress assets + config.assets.compress = false + + # Expands the lines which load the assets + config.assets.debug = true +end diff --git a/config/environments/production.rb b/config/environments/production.rb new file mode 100644 index 0000000..84b62bd --- /dev/null +++ b/config/environments/production.rb @@ -0,0 +1,69 @@ +Denunciapp::Application.configure do + # Settings specified here will take precedence over those in config/application.rb + + # Code is not reloaded between requests + config.cache_classes = true + + # Full error reports are disabled and caching is turned on + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + config.action_mailer.default_url_options = {:host => "denunciaciudadana.org"} + + # Disable Rails's static asset server (Apache or nginx will already do this) + config.serve_static_assets = false + + # Compress JavaScripts and CSS + config.assets.compress = true + + # Don't fallback to assets pipeline if a precompiled asset is missed + config.assets.compile = false + + # Generate digests for assets URLs + config.assets.digest = true + + # Defaults to nil and saved in location specified by config.assets.prefix + # config.assets.manifest = YOUR_PATH + + # Specifies the header that your server uses for sending files + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # See everything in the log (default is :info) + # config.log_level = :debug + + # Prepend all log lines with the following tags + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server + # config.action_controller.asset_host = "http://assets.example.com" + + # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) + # config.assets.precompile += %w( search.js ) + + # Disable delivery errors, bad email addresses will be ignored + # config.action_mailer.raise_delivery_errors = false + + # Enable threaded mode + # config.threadsafe! + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation can not be found) + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners + config.active_support.deprecation = :notify + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL) + # config.active_record.auto_explain_threshold_in_seconds = 0.5 +end diff --git a/config/environments/test.rb b/config/environments/test.rb new file mode 100644 index 0000000..b2d5610 --- /dev/null +++ b/config/environments/test.rb @@ -0,0 +1,37 @@ +Denunciapp::Application.configure do + # Settings specified here will take precedence over those in config/application.rb + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Configure static asset server for tests with Cache-Control for performance + config.serve_static_assets = true + config.static_cache_control = "public, max-age=3600" + + # Log error messages when you accidentally call methods on nil + config.whiny_nils = true + + # Show full error reports and disable caching + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment + config.action_controller.allow_forgery_protection = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Raise exception on mass assignment protection for Active Record models + config.active_record.mass_assignment_sanitizer = :strict + + # Print deprecation notices to the stderr + config.active_support.deprecation = :stderr +end diff --git a/config/initializers/active_admin.rb b/config/initializers/active_admin.rb new file mode 100644 index 0000000..9bf4ef2 --- /dev/null +++ b/config/initializers/active_admin.rb @@ -0,0 +1,213 @@ +ActiveAdmin.setup do |config| + + # == Site Title + # + # Set the title that is displayed on the main layout + # for each of the active admin pages. + # + config.site_title = "Denuncia Ciudadana" + + # Set the link url for the title. For example, to take + # users to your main site. Defaults to no link. + # + # config.site_title_link = "/" + + # Set an optional image to be displayed for the header + # instead of a string (overrides :site_title) + # + # Note: Recommended image height is 21px to properly fit in the header + # + # config.site_title_image = "/images/logo.png" + + # == Default Namespace + # + # Set the default namespace each administration resource + # will be added to. + # + # eg: + # config.default_namespace = :hello_world + # + # This will create resources in the HelloWorld module and + # will namespace routes to /hello_world/* + # + # To set no namespace by default, use: + # config.default_namespace = false + # + # Default: + # config.default_namespace = :admin + # + # You can customize the settings for each namespace by using + # a namespace block. For example, to change the site title + # within a namespace: + # + # config.namespace :admin do |admin| + # admin.site_title = "Custom Admin Title" + # end + # + # This will ONLY change the title for the admin section. Other + # namespaces will continue to use the main "site_title" configuration. + + # == User Authentication + # + # Active Admin will automatically call an authentication + # method in a before filter of all controller actions to + # ensure that there is a currently logged in admin user. + # + # This setting changes the method which Active Admin calls + # within the controller. + config.authentication_method = :authenticate_admin_user! + + + # == Current User + # + # Active Admin will associate actions with the current + # user performing them. + # + # This setting changes the method which Active Admin calls + # to return the currently logged in user. + config.current_user_method = :current_admin_user + + + # == Logging Out + # + # Active Admin displays a logout link on each screen. These + # settings configure the location and method used for the link. + # + # This setting changes the path where the link points to. If it's + # a string, the strings is used as the path. If it's a Symbol, we + # will call the method to return the path. + # + # Default: + config.logout_link_path = :destroy_admin_user_session_path + + # This setting changes the http method used when rendering the + # link. For example :get, :delete, :put, etc.. + # + # Default: + # config.logout_link_method = :get + + # == Root + # + # Set the action to call for the root path. You can set different + # roots for each namespace. + # + # Default: + # config.root_to = 'dashboard#index' + + # == Admin Comments + # + # Admin comments allow you to add comments to any model for admin use. + # Admin comments are enabled by default. + # + # Default: + # config.allow_comments = true + # + # You can turn them on and off for any given namespace by using a + # namespace config block. + # + # Eg: + # config.namespace :without_comments do |without_comments| + # without_comments.allow_comments = false + # end + + + # == Batch Actions + # + # Enable and disable Batch Actions + # + config.batch_actions = true + + + # == Controller Filters + # + # You can add before, after and around filters to all of your + # Active Admin resources and pages from here. + # + # config.before_filter :do_something_awesome + + + # == Register Stylesheets & Javascripts + # + # We recommend using the built in Active Admin layout and loading + # up your own stylesheets / javascripts to customize the look + # and feel. + # + # To load a stylesheet: + # config.register_stylesheet 'my_stylesheet.css' + + # You can provide an options hash for more control, which is passed along to stylesheet_link_tag(): + # config.register_stylesheet 'my_print_stylesheet.css', :media => :print + # + # To load a javascript file: + # config.register_javascript 'my_javascript.js' + + + # == CSV options + # + # Set the CSV builder separator (default is ",") + # config.csv_column_separator = ',' + # + # Set the CSV builder options (default is {}) + # config.csv_options = {} + + + # == Menu System + # + # You can add a navigation menu to be used in your application, or configure a provided menu + # + # To change the default utility navigation to show a link to your website & a logout btn + # + # config.namespace :admin do |admin| + # admin.build_menu :utility_navigation do |menu| + # menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank } + # admin.add_logout_button_to_menu menu + # end + # end + # + # If you wanted to add a static menu item to the default menu provided: + # + # config.namespace :admin do |admin| + # admin.build_menu :default do |menu| + # menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank } + # end + # end + + config.download_links = false + config.download_links = [:csv] + + # == Download Links + # + # You can disable download links on resource listing pages, + # or customize the formats shown per namespace/globally + # + # To disable/customize for the :admin namespace: + # + # config.namespace :admin do |admin| + # + # # Disable the links entirely + # admin.download_links = false + # + # # Only show XML & PDF options + # admin.download_links = [:xml, :pdf] + # + # end + + + # == Pagination + # + # Pagination is enabled by default for all resources. + # You can control the default per page count for all resources here. + # + # config.default_per_page = 30 + + + # == Filters + # + # By default the index screen includes a “Filters” sidebar on the right + # hand side with a filter for each attribute of the registered model. + # You can enable or disable them for all resources here. + # + # config.filters = true + + +end diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb new file mode 100644 index 0000000..83a67f9 --- /dev/null +++ b/config/initializers/devise.rb @@ -0,0 +1,240 @@ +# Use this hook to configure devise mailer, warden hooks and so forth. +# Many of these configuration options can be set straight in your model. +Devise.setup do |config| + # ==> Mailer Configuration + # Configure the e-mail address which will be shown in Devise::Mailer, + # note that it will be overwritten if you use your own mailer class with default "from" parameter. + config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com" + + # Configure the class responsible to send e-mails. + # config.mailer = "Devise::Mailer" + + # ==> ORM configuration + # Load and configure the ORM. Supports :active_record (default) and + # :mongoid (bson_ext recommended) by default. Other ORMs may be + # available as additional gems. + require 'devise/orm/active_record' + + # ==> Configuration for any authentication mechanism + # Configure which keys are used when authenticating a user. The default is + # just :email. You can configure it to use [:username, :subdomain], so for + # authenticating a user, both parameters are required. Remember that those + # parameters are used only when authenticating and not when retrieving from + # session. If you need permissions, you should implement that in a before filter. + # You can also supply a hash where the value is a boolean determining whether + # or not authentication should be aborted when the value is not present. + # config.authentication_keys = [ :email ] + + # Configure parameters from the request object used for authentication. Each entry + # given should be a request method and it will automatically be passed to the + # find_for_authentication method and considered in your model lookup. For instance, + # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. + # The same considerations mentioned for authentication_keys also apply to request_keys. + # config.request_keys = [] + + # Configure which authentication keys should be case-insensitive. + # These keys will be downcased upon creating or modifying a user and when used + # to authenticate or find a user. Default is :email. + config.case_insensitive_keys = [ :email ] + + # Configure which authentication keys should have whitespace stripped. + # These keys will have whitespace before and after removed upon creating or + # modifying a user and when used to authenticate or find a user. Default is :email. + config.strip_whitespace_keys = [ :email ] + + # Tell if authentication through request.params is enabled. True by default. + # It can be set to an array that will enable params authentication only for the + # given strategies, for example, `config.params_authenticatable = [:database]` will + # enable it only for database (email + password) authentication. + # config.params_authenticatable = true + + # Tell if authentication through HTTP Basic Auth is enabled. False by default. + # It can be set to an array that will enable http authentication only for the + # given strategies, for example, `config.http_authenticatable = [:token]` will + # enable it only for token authentication. + # config.http_authenticatable = false + + # If http headers should be returned for AJAX requests. True by default. + # config.http_authenticatable_on_xhr = true + + # The realm used in Http Basic Authentication. "Application" by default. + # config.http_authentication_realm = "Application" + + # It will change confirmation, password recovery and other workflows + # to behave the same regardless if the e-mail provided was right or wrong. + # Does not affect registerable. + # config.paranoid = true + + # By default Devise will store the user in session. You can skip storage for + # :http_auth and :token_auth by adding those symbols to the array below. + # Notice that if you are skipping storage for all authentication paths, you + # may want to disable generating routes to Devise's sessions controller by + # passing :skip => :sessions to `devise_for` in your config/routes.rb + config.skip_session_storage = [:http_auth] + + # ==> Configuration for :database_authenticatable + # For bcrypt, this is the cost for hashing the password and defaults to 10. If + # using other encryptors, it sets how many times you want the password re-encrypted. + # + # Limiting the stretches to just one in testing will increase the performance of + # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use + # a value less than 10 in other environments. + config.stretches = Rails.env.test? ? 1 : 10 + + # Setup a pepper to generate the encrypted password. + # config.pepper = "7fe67f50e1cf6b5f7b281f9c0b6b437d9ae5e10eeec5a60c90238254ecb44851eeb6ad1c9c79052b1ec2e8e9ba8ab029937c208e12bf589bb738daddee67a090" + + # ==> Configuration for :confirmable + # A period that the user is allowed to access the website even without + # confirming his account. For instance, if set to 2.days, the user will be + # able to access the website for two days without confirming his account, + # access will be blocked just in the third day. Default is 0.days, meaning + # the user cannot access the website without confirming his account. + # config.allow_unconfirmed_access_for = 2.days + + # A period that the user is allowed to confirm their account before their + # token becomes invalid. For example, if set to 3.days, the user can confirm + # their account within 3 days after the mail was sent, but on the fourth day + # their account can't be confirmed with the token any more. + # Default is nil, meaning there is no restriction on how long a user can take + # before confirming their account. + # config.confirm_within = 3.days + + # If true, requires any email changes to be confirmed (exactly the same way as + # initial account confirmation) to be applied. Requires additional unconfirmed_email + # db field (see migrations). Until confirmed new email is stored in + # unconfirmed email column, and copied to email column on successful confirmation. + config.reconfirmable = true + + # Defines which key will be used when confirming an account + # config.confirmation_keys = [ :email ] + + # ==> Configuration for :rememberable + # The time the user will be remembered without asking for credentials again. + # config.remember_for = 2.weeks + + # If true, extends the user's remember period when remembered via cookie. + # config.extend_remember_period = false + + # Options to be passed to the created cookie. For instance, you can set + # :secure => true in order to force SSL only cookies. + # config.rememberable_options = {} + + # ==> Configuration for :validatable + # Range for password length. Default is 8..128. + config.password_length = 8..128 + + # Email regex used to validate email formats. It simply asserts that + # an one (and only one) @ exists in the given string. This is mainly + # to give user feedback and not to assert the e-mail validity. + # config.email_regexp = /\A[^@]+@[^@]+\z/ + + # ==> Configuration for :timeoutable + # The time you want to timeout the user session without activity. After this + # time the user will be asked for credentials again. Default is 30 minutes. + # config.timeout_in = 30.minutes + + # If true, expires auth token on session timeout. + # config.expire_auth_token_on_timeout = false + + # ==> Configuration for :lockable + # Defines which strategy will be used to lock an account. + # :failed_attempts = Locks an account after a number of failed attempts to sign in. + # :none = No lock strategy. You should handle locking by yourself. + # config.lock_strategy = :failed_attempts + + # Defines which key will be used when locking and unlocking an account + # config.unlock_keys = [ :email ] + + # Defines which strategy will be used to unlock an account. + # :email = Sends an unlock link to the user email + # :time = Re-enables login after a certain amount of time (see :unlock_in below) + # :both = Enables both strategies + # :none = No unlock strategy. You should handle unlocking by yourself. + # config.unlock_strategy = :both + + # Number of authentication tries before locking an account if lock_strategy + # is failed attempts. + # config.maximum_attempts = 20 + + # Time interval to unlock the account if :time is enabled as unlock_strategy. + # config.unlock_in = 1.hour + + # ==> Configuration for :recoverable + # + # Defines which key will be used when recovering the password for an account + # config.reset_password_keys = [ :email ] + + # Time interval you can reset your password with a reset password key. + # Don't put a too small interval or your users won't have the time to + # change their passwords. + config.reset_password_within = 6.hours + + # ==> Configuration for :encryptable + # Allow you to use another encryption algorithm besides bcrypt (default). You can use + # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1, + # :authlogic_sha512 (then you should set stretches above to 20 for default behavior) + # and :restful_authentication_sha1 (then you should set stretches to 10, and copy + # REST_AUTH_SITE_KEY to pepper) + # config.encryptor = :sha512 + + # ==> Configuration for :token_authenticatable + # Defines name of the authentication token params key + # config.token_authentication_key = :auth_token + + # ==> Scopes configuration + # Turn scoped views on. Before rendering "sessions/new", it will first check for + # "users/sessions/new". It's turned off by default because it's slower if you + # are using only default views. + # config.scoped_views = false + + # Configure the default scope given to Warden. By default it's the first + # devise role declared in your routes (usually :user). + # config.default_scope = :user + + # Set this configuration to false if you want /users/sign_out to sign out + # only the current scope. By default, Devise signs out all scopes. + # config.sign_out_all_scopes = true + + # ==> Navigation configuration + # Lists the formats that should be treated as navigational. Formats like + # :html, should redirect to the sign in page when the user does not have + # access, but formats like :xml or :json, should return 401. + # + # If you have any extra navigational formats, like :iphone or :mobile, you + # should add them to the navigational formats lists. + # + # The "*/*" below is required to match Internet Explorer requests. + # config.navigational_formats = ["*/*", :html] + + # The default HTTP method used to sign out a resource. Default is :delete. + config.sign_out_via = :delete + + # ==> OmniAuth + # Add a new OmniAuth provider. Check the wiki for more information on setting + # up on your models and hooks. + # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo' + + # ==> Warden configuration + # If you want to use other strategies, that are not supported by Devise, or + # change the failure app, you can configure them inside the config.warden block. + # + # config.warden do |manager| + # manager.intercept_401 = false + # manager.default_strategies(:scope => :user).unshift :some_external_strategy + # end + + # ==> Mountable engine configurations + # When using Devise inside an engine, let's call it `MyEngine`, and this engine + # is mountable, there are some extra configurations to be taken into account. + # The following options are available, assuming the engine is mounted as: + # + # mount MyEngine, at: "/my_engine" + # + # The router that invoked `devise_for`, in the example above, would be: + # config.router_name = :my_engine + # + # When using omniauth, Devise cannot automatically set Omniauth path, + # so you need to do it manually. For the users scope, it would be: + # config.omniauth_path_prefix = "/my_engine/users/auth" +end diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb new file mode 100644 index 0000000..5d8d9be --- /dev/null +++ b/config/initializers/inflections.rb @@ -0,0 +1,15 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format +# (all these examples are active by default): +# ActiveSupport::Inflector.inflections do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end +# +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/config/initializers/load_theme.rb b/config/initializers/load_theme.rb new file mode 100644 index 0000000..f94e5b1 --- /dev/null +++ b/config/initializers/load_theme.rb @@ -0,0 +1 @@ +THEME = YAML.load_file( File.join( Rails.root, "config/theme/theme.yml" ) ) diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb new file mode 100644 index 0000000..72aca7e --- /dev/null +++ b/config/initializers/mime_types.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf +# Mime::Type.register_alias "text/html", :iphone diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb new file mode 100644 index 0000000..e36739f --- /dev/null +++ b/config/initializers/secret_token.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +Denunciapp::Application.config.secret_token = '0f1d864e08a5cf5a79add351f15e86048520da9a3877208d336ce72aaf75d388da6dfec63d5bbd11b94aee2927b3699b8f848a7e1f20845405e38bc9fa53db16' diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb new file mode 100644 index 0000000..02a835d --- /dev/null +++ b/config/initializers/session_store.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +Denunciapp::Application.config.session_store :cookie_store, key: '_denunciapp_session' + +# Use the database for sessions instead of the cookie-based default, +# which shouldn't be used to store highly confidential information +# (create the session table with "rails generate session_migration") +# Denunciapp::Application.config.session_store :active_record_store diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..999df20 --- /dev/null +++ b/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# Disable root element in JSON by default. +ActiveSupport.on_load(:active_record) do + self.include_root_in_json = false +end diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml new file mode 100644 index 0000000..d01f375 --- /dev/null +++ b/config/locales/devise.en.yml @@ -0,0 +1,59 @@ +# Additional translations at https://github.com/plataformatec/devise/wiki/I18n + +en: + devise: + confirmations: + confirmed: "Your account was successfully confirmed. You are now signed in." + send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes." + send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes." + failure: + already_authenticated: "You are already signed in." + inactive: "Your account was not activated yet." + invalid: "Invalid email or password." + invalid_token: "Invalid authentication token." + locked: "Your account is locked." + not_found_in_database: "Invalid email or password." + timeout: "Your session expired, please sign in again to continue." + unauthenticated: "You need to sign in or sign up before continuing." + unconfirmed: "You have to confirm your account before continuing." + mailer: + confirmation_instructions: + subject: "Confirmation instructions" + reset_password_instructions: + subject: "Reset password instructions" + unlock_instructions: + subject: "Unlock Instructions" + omniauth_callbacks: + failure: "Could not authenticate you from %{kind} because \"%{reason}\"." + success: "Successfully authenticated from %{kind} account." + passwords: + no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided." + send_instructions: "You will receive an email with instructions about how to reset your password in a few minutes." + send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes." + updated: "Your password was changed successfully. You are now signed in." + updated_not_active: "Your password was changed successfully." + registrations: + destroyed: "Bye! Your account was successfully cancelled. We hope to see you again soon." + signed_up: "Welcome! You have signed up successfully." + signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated." + signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked." + signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please open the link to activate your account." + update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address." + updated: "You updated your account successfully." + sessions: + signed_in: "Signed in successfully." + signed_out: "Signed out successfully." + unlocks: + send_instructions: "You will receive an email with instructions about how to unlock your account in a few minutes." + send_paranoid_instructions: "If your account exists, you will receive an email with instructions about how to unlock it in a few minutes." + unlocked: "Your account has been unlocked successfully. Please sign in to continue." + errors: + messages: + already_confirmed: "was already confirmed, please try signing in" + confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one" + expired: "has expired, please request a new one" + not_found: "not found" + not_locked: "was not locked" + not_saved: + one: "1 error prohibited this %{resource} from being saved:" + other: "%{count} errors prohibited this %{resource} from being saved:" diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 0000000..179c14c --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,5 @@ +# Sample localization file for English. Add more files in this directory for other locales. +# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. + +en: + hello: "Hello world" diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000..fe6ecb8 --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,69 @@ +Denunciapp::Application.routes.draw do + resources :denuncias, only: [:new, :create, :show] + post "denuncias/:id/adjuntar" => 'denuncias#adjuntar', as: :adjuntar + delete "archivos/:url_id" => 'archivos#destroy', as: :delete_archivo + + get "home/index" + + get "home/about" + + # The priority is based upon order of creation: + # first created -> highest priority. + + # Sample of regular route: + # match 'products/:id' => 'catalog#view' + # Keep in mind you can assign values other than :controller and :action + + # Sample of named route: + # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase + # This route can be invoked with purchase_url(:id => product.id) + + # Sample resource route (maps HTTP verbs to controller actions automatically): + # resources :products + + # Sample resource route with options: + # resources :products do + # member do + # get 'short' + # post 'toggle' + # end + # + # collection do + # get 'sold' + # end + # end + + # Sample resource route with sub-resources: + # resources :products do + # resources :comments, :sales + # resource :seller + # end + + # Sample resource route with more complex sub-resources + # resources :products do + # resources :comments + # resources :sales do + # get 'recent', :on => :collection + # end + # end + + # Sample resource route within a namespace: + # namespace :admin do + # # Directs /admin/products/* to Admin::ProductsController + # # (app/controllers/admin/products_controller.rb) + # resources :products + # end + + # You can have the root of your site routed with "root" + # just remember to delete public/index.html. + root :to => 'home#index' + + devise_for :admines_useres, ActiveAdmin::Devise.config + ActiveAdmin.routes(self) + + # See how all your routes lay out with "rake routes" + + # This is a legacy wild controller route that's not recommended for RESTful applications. + # Note: This route will make all actions in every controller accessible via GET requests. + # match ':controller(/:action(/:id))(.:format)' +end diff --git a/config/theme/theme.yml b/config/theme/theme.yml new file mode 100644 index 0000000..bcd84d8 --- /dev/null +++ b/config/theme/theme.yml @@ -0,0 +1,29 @@ +# application +application_page: "a" +application_header: "a" +application_content: "a" +application_footer: "a" + +# index +index_new_denuncia: "a" + +# denuncias new +denuncias_new_info_adjuntar: "a" +denuncias_new_informacion: "a" +denuncias_new_archivo: "a" +denuncias_new_limpiar: "a" +denuncias_new_limpiar_confirm: "a" +denuncias_new_popup_info: "a" + +# denuncias _form +denuncias_form_crear: "a" + +# denuncias show +denuncias_show_otra: "a" + +# about +about_dialog_overlay: "a" +about_dialog: "a" +about_header: "a" +about_content: "a" +about_cerrar: "a" diff --git a/db/migrate/20130407230637_create_dependencias.rb b/db/migrate/20130407230637_create_dependencias.rb new file mode 100644 index 0000000..7a3e8a8 --- /dev/null +++ b/db/migrate/20130407230637_create_dependencias.rb @@ -0,0 +1,9 @@ +class CreateDependencias < ActiveRecord::Migration + def change + create_table :dependencias do |t| + t.string :nombre + + t.timestamps + end + end +end diff --git a/db/migrate/20130407230903_create_denuncias.rb b/db/migrate/20130407230903_create_denuncias.rb new file mode 100644 index 0000000..61b0470 --- /dev/null +++ b/db/migrate/20130407230903_create_denuncias.rb @@ -0,0 +1,13 @@ +class CreateDenuncias < ActiveRecord::Migration + def change + create_table :denuncias do |t| + t.string :funcionario + t.text :queja + t.string :email + t.references :dependencia + + t.timestamps + end + add_index :denuncias, :dependencia_id + end +end diff --git a/db/migrate/20130408014045_devise_create_admines_useres.rb b/db/migrate/20130408014045_devise_create_admines_useres.rb new file mode 100644 index 0000000..349552f --- /dev/null +++ b/db/migrate/20130408014045_devise_create_admines_useres.rb @@ -0,0 +1,52 @@ +class DeviseCreateAdminesUseres < ActiveRecord::Migration + def migrate(direction) + super + # Create a default user + AdminUser.create!(:email => 'admin@example.com', :password => 'password', :password_confirmation => 'password') if direction == :up + end + + def change + create_table(:admines_useres) do |t| + ## Database authenticatable + t.string :email, :null => false, :default => "" + t.string :encrypted_password, :null => false, :default => "" + + ## Recoverable + t.string :reset_password_token + t.datetime :reset_password_sent_at + + ## Rememberable + t.datetime :remember_created_at + + ## Trackable + t.integer :sign_in_count, :default => 0 + t.datetime :current_sign_in_at + t.datetime :last_sign_in_at + t.string :current_sign_in_ip + t.string :last_sign_in_ip + + ## Confirmable + # t.string :confirmation_token + # t.datetime :confirmed_at + # t.datetime :confirmation_sent_at + # t.string :unconfirmed_email # Only if using reconfirmable + + ## Lockable + # t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts + # t.string :unlock_token # Only if unlock strategy is :email or :both + # t.datetime :locked_at + + ## Token authenticatable + # t.string :authentication_token + + + t.timestamps + end + + add_index :admines_useres, :email, :unique => true + add_index :admines_useres, :reset_password_token, :unique => true + # add_index :admines_useres, :confirmation_token, :unique => true + # add_index :admines_useres, :unlock_token, :unique => true + # add_index :admines_useres, :authentication_token, :unique => true + end +end diff --git a/db/migrate/20130408014110_create_admin_notes.rb b/db/migrate/20130408014110_create_admin_notes.rb new file mode 100644 index 0000000..e106af3 --- /dev/null +++ b/db/migrate/20130408014110_create_admin_notes.rb @@ -0,0 +1,17 @@ +class CreateAdminNotes < ActiveRecord::Migration + def self.up + create_table :admin_notes do |t| + t.string :resource_id, :null => false + t.string :resource_type, :null => false + t.references :admin_user, :polymorphic => true + t.text :body + t.timestamps + end + add_index :admin_notes, [:resource_type, :resource_id] + add_index :admin_notes, [:admin_user_type, :admin_user_id] + end + + def self.down + drop_table :admin_notes + end +end diff --git a/db/migrate/20130408014111_move_admin_notes_to_comments.rb b/db/migrate/20130408014111_move_admin_notes_to_comments.rb new file mode 100644 index 0000000..8833359 --- /dev/null +++ b/db/migrate/20130408014111_move_admin_notes_to_comments.rb @@ -0,0 +1,26 @@ +class MoveAdminNotesToComments < ActiveRecord::Migration + def self.up + remove_index :admin_notes, [:admin_user_type, :admin_user_id] + rename_table :admin_notes, :active_admin_comments + rename_column :active_admin_comments, :admin_user_type, :author_type + rename_column :active_admin_comments, :admin_user_id, :author_id + add_column :active_admin_comments, :namespace, :string + add_index :active_admin_comments, [:namespace] + add_index :active_admin_comments, [:author_type, :author_id] + + # Update all the existing comments to the default namespace + say "Updating any existing comments to the #{ActiveAdmin.application.default_namespace} namespace." + comments_table_name = ActiveRecord::Migrator.proper_table_name("active_admin_comments") + execute "UPDATE #{comments_table_name} SET namespace='#{ActiveAdmin.application.default_namespace}'" + end + + def self.down + remove_index :active_admin_comments, :column => [:author_type, :author_id] + remove_index :active_admin_comments, :column => [:namespace] + remove_column :active_admin_comments, :namespace + rename_column :active_admin_comments, :author_id, :admin_user_id + rename_column :active_admin_comments, :author_type, :admin_user_type + rename_table :active_admin_comments, :admin_notes + add_index :admin_notes, [:admin_user_type, :admin_user_id] + end +end diff --git a/db/migrate/20130518162539_add_finalizada_to_denuncias.rb b/db/migrate/20130518162539_add_finalizada_to_denuncias.rb new file mode 100644 index 0000000..f6dd723 --- /dev/null +++ b/db/migrate/20130518162539_add_finalizada_to_denuncias.rb @@ -0,0 +1,5 @@ +class AddFinalizadaToDenuncias < ActiveRecord::Migration + def change + add_column :denuncias, :finalizada, :boolean + end +end diff --git a/db/migrate/20130608171721_create_archivos.rb b/db/migrate/20130608171721_create_archivos.rb new file mode 100644 index 0000000..a59638a --- /dev/null +++ b/db/migrate/20130608171721_create_archivos.rb @@ -0,0 +1,11 @@ +class CreateArchivos < ActiveRecord::Migration + def change + create_table :archivos do |t| + t.references :denuncia + t.string :adjunto + + t.timestamps + end + add_index :archivos, :denuncia_id + end +end diff --git a/db/migrate/20130708035400_add_url_id_to_archivos.rb b/db/migrate/20130708035400_add_url_id_to_archivos.rb new file mode 100644 index 0000000..9fa2af8 --- /dev/null +++ b/db/migrate/20130708035400_add_url_id_to_archivos.rb @@ -0,0 +1,6 @@ +class AddUrlIdToArchivos < ActiveRecord::Migration + def change + add_column :archivos, :url_id, :string + add_index :archivos, :url_id + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..23e41cd --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,78 @@ +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended to check this file into your version control system. + +ActiveRecord::Schema.define(:version => 20130708035400) do + + create_table "active_admin_comments", :force => true do |t| + t.string "resource_id", :null => false + t.string "resource_type", :null => false + t.integer "author_id" + t.string "author_type" + t.text "body" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "namespace" + end + + add_index "active_admin_comments", ["author_type", "author_id"], :name => "index_active_admin_comments_on_author_type_and_author_id" + add_index "active_admin_comments", ["namespace"], :name => "index_active_admin_comments_on_namespace" + add_index "active_admin_comments", ["resource_type", "resource_id"], :name => "index_admin_notes_on_resource_type_and_resource_id" + + create_table "admines_useres", :force => true do |t| + t.string "email", :default => "", :null => false + t.string "encrypted_password", :default => "", :null => false + t.string "reset_password_token" + t.datetime "reset_password_sent_at" + t.datetime "remember_created_at" + t.integer "sign_in_count", :default => 0 + t.datetime "current_sign_in_at" + t.datetime "last_sign_in_at" + t.string "current_sign_in_ip" + t.string "last_sign_in_ip" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "admines_useres", ["email"], :name => "index_admines_useres_on_email", :unique => true + add_index "admines_useres", ["reset_password_token"], :name => "index_admines_useres_on_reset_password_token", :unique => true + + create_table "archivos", :force => true do |t| + t.integer "denuncia_id" + t.string "adjunto" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "url_id" + end + + add_index "archivos", ["denuncia_id"], :name => "index_archivos_on_denuncia_id" + add_index "archivos", ["url_id"], :name => "index_archivos_on_url_id" + + create_table "denuncias", :force => true do |t| + t.string "funcionario" + t.text "queja" + t.string "email" + t.integer "dependencia_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.boolean "finalizada" + end + + add_index "denuncias", ["dependencia_id"], :name => "index_denuncias_on_dependencia_id" + + create_table "dependencias", :force => true do |t| + t.string "nombre" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + +end diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 0000000..4edb1e8 --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1,7 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). +# +# Examples: +# +# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) +# Mayor.create(name: 'Emanuel', city: cities.first) diff --git a/doc/README_FOR_APP b/doc/README_FOR_APP new file mode 100644 index 0000000..fe41f5c --- /dev/null +++ b/doc/README_FOR_APP @@ -0,0 +1,2 @@ +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/features/crear_denuncia.feature b/features/crear_denuncia.feature new file mode 100644 index 0000000..8f3f8e1 --- /dev/null +++ b/features/crear_denuncia.feature @@ -0,0 +1,32 @@ +# language: es +@javascript + +Característica: Crear nueva denuncia + +Antecedentes: + Dado que cuento con un catálogo de dependencias + +Escenario: Visualizar formulario de denuncia + Dado que visito la página de inicio + Cuando doy click en el enlace "Deseo realizar una denuncia" + Entonces debo visualizar el formulario de denuncia + +Escenario: Crear nueva denuncia + Dado que visito la página de crear denuncia + Cuando capturo la información de la denuncia + Entonces debo visualizar el mensaje "El número de folio asignado a tu Queja o Denuncia es" + +Escenario: Crear nueva denuncia con imágenes adjuntas + Dado que visito la página de crear denuncia + Cuando capturo la información de la denuncia y adjunto imágenes + Entonces debo visualizar el mensaje "El número de folio asignado a tu Queja o Denuncia es" + +Escenario: Crear nueva denuncia con archivos adjuntos + Dado que visito la página de crear denuncia + Cuando capturo la información de la denuncia y adjunto archivos + Entonces debo visualizar el mensaje "La denuncia no pudo guardarse" + +Escenario: Limpiar formulario de denuncia + Dado que visito la página de crear denuncia + Cuando capturo la información de la denuncia y elijo la opción 'Limpiar' + Entonces el formulario se debe mostrar vacío diff --git a/features/inicio.feature b/features/inicio.feature new file mode 100644 index 0000000..6e1cb14 --- /dev/null +++ b/features/inicio.feature @@ -0,0 +1,8 @@ +# language: es +@javascript + +Característica: Visitar la página principal + +Escenario: + Cuando visito la página de inicio + Entonces debo visualizar el enlace "Deseo realizar una denuncia" diff --git a/features/step_definitions/crear_denuncia_steps.rb b/features/step_definitions/crear_denuncia_steps.rb new file mode 100644 index 0000000..84fdece --- /dev/null +++ b/features/step_definitions/crear_denuncia_steps.rb @@ -0,0 +1,66 @@ +# encoding: UTF-8 + +Dado(/^que cuento con un catálogo de dependencias$/) do + FactoryGirl.create :dependencia + FactoryGirl.create :dependencia, nombre: 'Fondo PyME' +end + +Dado(/^que visito la página de inicio$/) do + visit root_path +end + +Dado(/^que visito la página de crear denuncia$/) do + visit new_denuncia_path +end + +Cuando(/^capturo la información de la denuncia$/) do + rellenar_denuncia + click_button 'Crear denuncia' +end + +Cuando(/^capturo la información de la denuncia y adjunto imágenes$/) do + rellenar_denuncia + attach_file 'archivos', 'spec/fixtures/files/image-1.png' + click_button 'Crear denuncia' +end + +Cuando(/^capturo la información de la denuncia y adjunto archivos$/) do + rellenar_denuncia + attach_file 'archivos', 'spec/fixtures/files/file' + click_button 'Crear denuncia' +end + +Cuando(/^capturo la información de la denuncia y elijo la opción 'Limpiar'$/) do + rellenar_denuncia + within 'div[data-role="navbar"]' do + click_link 'Limpiar' + end + within '#confirm-clean' do + click_link 'Limpiar' + end +end + +Cuando(/^doy click en el enlace "(.*?)"$/) do |msg| + page.click_link(msg) +end + +Entonces(/^debo visualizar el formulario de denuncia$/) do + page.should have_selector('form#new_denuncia') +end + +Entonces(/^debo visualizar el mensaje "(.*?)"$/) do |msg| + page.should have_content(msg) +end + +Entonces(/^el formulario se debe mostrar vacío$/) do + field_labeled('Funcionario').value.should be_blank + field_labeled('Queja').value.should be_blank + field_labeled('Email').value.should be_blank +end + +def rellenar_denuncia + select 'Contraloría', from: 'Dependencia' + fill_in 'Funcionario', with: 'Funcionario' + fill_in 'Queja', with: 'Mi queja' + fill_in 'Email', with: 'denunciante@mail.com' +end diff --git a/features/step_definitions/inicio_steps.rb b/features/step_definitions/inicio_steps.rb new file mode 100644 index 0000000..df50348 --- /dev/null +++ b/features/step_definitions/inicio_steps.rb @@ -0,0 +1,9 @@ +# encoding: UTF-8 + +Cuando(/^visito la página de inicio$/) do + visit root_path +end + +Entonces(/^debo visualizar el enlace "(.*?)"$/) do |msg| + page.should have_link(msg) +end diff --git a/features/support/env.rb b/features/support/env.rb new file mode 100644 index 0000000..3d66fbb --- /dev/null +++ b/features/support/env.rb @@ -0,0 +1,60 @@ +# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril. +# It is recommended to regenerate this file in the future when you upgrade to a +# newer version of cucumber-rails. Consider adding your own code to a new file +# instead of editing this one. Cucumber will automatically load all features/**/*.rb +# files. + +require 'cucumber/rails' + +# Capybara defaults to CSS3 selectors rather than XPath. +# If you'd prefer to use XPath, just uncomment this line and adjust any +# selectors in your step definitions to use the XPath syntax. +# Capybara.default_selector = :xpath + +# By default, any exception happening in your Rails application will bubble up +# to Cucumber so that your scenario will fail. This is a different from how +# your application behaves in the production environment, where an error page will +# be rendered instead. +# +# Sometimes we want to override this default behaviour and allow Rails to rescue +# exceptions and display an error page (just like when the app is running in production). +# Typical scenarios where you want to do this is when you test your error pages. +# There are two ways to allow Rails to rescue exceptions: +# +# 1) Tag your scenario (or feature) with @allow-rescue +# +# 2) Set the value below to true. Beware that doing this globally is not +# recommended as it will mask a lot of errors for you! +# +ActionController::Base.allow_rescue = false + +# Remove/comment out the lines below if your app doesn't have a database. +# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead. +begin + DatabaseCleaner.strategy = :transaction +rescue NameError + raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it." +end + +# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios. +# See the DatabaseCleaner documentation for details. Example: +# +# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do +# # { :except => [:widgets] } may not do what you expect here +# # as Cucumber::Rails::Database.javascript_strategy overrides +# # this setting. +# DatabaseCleaner.strategy = :truncation +# end +# +# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do +# DatabaseCleaner.strategy = :transaction +# end +# + +# Possible values are :truncation and :transaction +# The :transaction strategy is faster, but might give you threading problems. +# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature +Cucumber::Rails::Database.javascript_strategy = :truncation + +require 'capybara/poltergeist' +Capybara.javascript_driver = :poltergeist diff --git a/lib/tasks/cucumber.rake b/lib/tasks/cucumber.rake new file mode 100644 index 0000000..9f53ce4 --- /dev/null +++ b/lib/tasks/cucumber.rake @@ -0,0 +1,65 @@ +# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril. +# It is recommended to regenerate this file in the future when you upgrade to a +# newer version of cucumber-rails. Consider adding your own code to a new file +# instead of editing this one. Cucumber will automatically load all features/**/*.rb +# files. + + +unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks + +vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first +$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil? + +begin + require 'cucumber/rake/task' + + namespace :cucumber do + Cucumber::Rake::Task.new({:ok => 'test:prepare'}, 'Run features that should pass') do |t| + t.binary = vendored_cucumber_bin # If nil, the gem's binary is used. + t.fork = true # You may get faster startup if you set this to false + t.profile = 'default' + end + + Cucumber::Rake::Task.new({:wip => 'test:prepare'}, 'Run features that are being worked on') do |t| + t.binary = vendored_cucumber_bin + t.fork = true # You may get faster startup if you set this to false + t.profile = 'wip' + end + + Cucumber::Rake::Task.new({:rerun => 'test:prepare'}, 'Record failing features and run only them if any exist') do |t| + t.binary = vendored_cucumber_bin + t.fork = true # You may get faster startup if you set this to false + t.profile = 'rerun' + end + + desc 'Run all features' + task :all => [:ok, :wip] + + task :statsetup do + require 'rails/code_statistics' + ::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features') + ::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features') + end + end + desc 'Alias for cucumber:ok' + task :cucumber => 'cucumber:ok' + + task :default => :cucumber + + task :features => :cucumber do + STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***" + end + + # In case we don't have the generic Rails test:prepare hook, append a no-op task that we can depend upon. + task 'test:prepare' do + end + + task :stats => 'cucumber:statsetup' +rescue LoadError + desc 'cucumber rake task not available (cucumber not installed)' + task :cucumber do + abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin' + end +end + +end diff --git a/public/404.html b/public/404.html new file mode 100644 index 0000000..9a48320 --- /dev/null +++ b/public/404.html @@ -0,0 +1,26 @@ + + + + The page you were looking for doesn't exist (404) + + + + + +
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+ + diff --git a/public/422.html b/public/422.html new file mode 100644 index 0000000..83660ab --- /dev/null +++ b/public/422.html @@ -0,0 +1,26 @@ + + + + The change you wanted was rejected (422) + + + + + +
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+ + diff --git a/public/500.html b/public/500.html new file mode 100644 index 0000000..f3648a0 --- /dev/null +++ b/public/500.html @@ -0,0 +1,25 @@ + + + + We're sorry, but something went wrong (500) + + + + + +
+

We're sorry, but something went wrong.

+
+ + diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..085187f --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,5 @@ +# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file +# +# To ban all spiders from the entire site uncomment the next two lines: +# User-Agent: * +# Disallow: / diff --git a/script/cucumber b/script/cucumber new file mode 100755 index 0000000..7fa5c92 --- /dev/null +++ b/script/cucumber @@ -0,0 +1,10 @@ +#!/usr/bin/env ruby + +vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first +if vendored_cucumber_bin + load File.expand_path(vendored_cucumber_bin) +else + require 'rubygems' unless ENV['NO_RUBYGEMS'] + require 'cucumber' + load Cucumber::BINARY +end diff --git a/script/rails b/script/rails new file mode 100755 index 0000000..f8da2cf --- /dev/null +++ b/script/rails @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby +# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. + +APP_PATH = File.expand_path('../../config/application', __FILE__) +require File.expand_path('../../config/boot', __FILE__) +require 'rails/commands' diff --git a/spec/controllers/denuncias_controller_spec.rb b/spec/controllers/denuncias_controller_spec.rb new file mode 100644 index 0000000..616b94a --- /dev/null +++ b/spec/controllers/denuncias_controller_spec.rb @@ -0,0 +1,172 @@ +require 'spec_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to specify the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. +# +# Compared to earlier versions of this generator, there is very limited use of +# stubs and message expectations in this spec. Stubs are only used when there +# is no simpler way to get a handle on the object needed for the example. +# Message expectations are only used when there is no simpler way to specify +# that an instance is receiving a specific message. + +describe DenunciasController do + + # This should return the minimal set of attributes required to create a valid + # Denuncia. As you add validations to Denuncia, be sure to + # update the return value of this method accordingly. + def valid_attributes + { 'funcionario' => 'Nombre Funcionario', 'queja' => 'Descripcion de la denuncia', 'email' => 'denunciante@mail.com', dependencia_id: dependencia.id} + end + + # This should return the minimal set of values that should be in the session + # in order to pass any filters (e.g. authentication) defined in + # DenunciasController. Be sure to keep this updated too. + def valid_session + {} + end + + let(:dependencia) { FactoryGirl.create :dependencia } + + describe "GET index" do + it "returns http error" do + expect { get :index }.to raise_error + end + end + + describe "GET new" do + it "returns http success" do + response.should be_success + end + + it "assigns a newly build denuncia as @denuncia" do + get :new, valid_session + assigns(:denuncia).should be_a(Denuncia) + assigns(:denuncia).should_not be_persisted + end + + it "renders the build denuncia to create" do + get :new, valid_session + response.should render_template 'new' + end + end + + describe "POST create" do + describe "with valid params" do + it "assigns a newly created denuncia as @denuncia" do + post :create, {:denuncia => valid_attributes}, valid_session + assigns(:denuncia).should be_a(Denuncia) + end + + it "creates a new Denuncia" do + post :create, {:denuncia => valid_attributes}, valid_session + assigns(:denuncia).should be_persisted + end + + it "redirects to the created denuncia" do + post :create, {:denuncia => valid_attributes}, valid_session + response.should redirect_to(Denuncia.last) + end + + it 'should render a notice message' do + post :create, {:denuncia => valid_attributes}, valid_session + flash[:notice].should == 'Su denuncia ha sido creada exitosamente.' + end + + it 'should not contain errors' do + post :create, {:denuncia => valid_attributes}, valid_session + assigns(:denuncia).errors.should be_empty + end + end + + describe "with invalid params" do + it "assigns a newly created but unsaved denuncia as @denuncia" do + # Trigger the behavior that occurs when invalid params are submitted + Denuncia.any_instance.stub(:save).and_return(false) + post :create, {:denuncia => { "funcionario" => "invalid value" }}, valid_session + assigns(:denuncia).should be_a_new(Denuncia) + assigns(:denuncia).should_not be_persisted + end + + it "re-renders the 'new' template" do + # Trigger the behavior that occurs when invalid params are submitted + Denuncia.any_instance.stub(:save).and_return(false) + post :create, {:denuncia => { "funcionario" => "invalid value" }}, valid_session + response.should render_template("new") + end + end + + describe 'with attached files' do + describe 'images' do + before :each do + @file_1 = fixture_file_upload('/files/image-1.png', 'image/png') + @file_2 = fixture_file_upload('/files/image-2.png', 'image/png') + end + + it 'saves the denuncia with attached images' do + post :create, {:denuncia => valid_attributes, archivos: [@file_1, @file_2]}, valid_session + assigns(:denuncia).should be_persisted + assigns(:denuncia).archivos.length.should eq 2 + assigns(:denuncia).archivos[0].adjunto.to_s.should match /image-1.png/ + assigns(:denuncia).archivos[1].adjunto.to_s.should match /image-2.png/ + end + end + + describe 'not images' do + before :each do + @file = fixture_file_upload('/files/file', 'text/plain') + end + + it 'does not save the denuncia' do + post :create, {:denuncia => valid_attributes, archivos: [@file]}, valid_session + assigns(:denuncia).should_not be_persisted + assigns(:denuncia).archivos.length.should eq 1 + end + end + + describe 'mixed types' do + before :each do + @image = fixture_file_upload('/files/image-1.png', 'image/png') + @file = fixture_file_upload('/files/file', 'text/plain') + end + + it 'saves the denuncia with attached images' do + post :create, {:denuncia => valid_attributes, archivos: [@image, @file]}, valid_session + assigns(:denuncia).should_not be_persisted + assigns(:denuncia).archivos.length.should eq 2 + assigns(:denuncia).errors.full_messages.length.should eq 1 + assigns(:denuncia).errors.full_messages[0].should match /allowed types: jpg, jpeg, gif, png/ + end + end + end + end + + describe "PUT update" do + it "returns http error" do + expect { put :update }.to raise_error + end + end + + describe "GET show" do + it "assigns the requested denuncia as @denuncia" do + denuncia = Denuncia.new + denuncia.finalize valid_attributes + get :show, {:id => denuncia.to_param}, valid_session + assigns(:denuncia).should eq(denuncia) + end + end + + describe "DELETE destroy" do + it "returns http error" do + expect { delete :destroy }.to raise_error + end + end +end diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb new file mode 100644 index 0000000..0c4c591 --- /dev/null +++ b/spec/controllers/home_controller_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe HomeController do + + describe "GET 'index'" do + it "returns http success" do + get 'index' + response.should be_success + end + end + + describe "GET 'about'" do + it "returns http success" do + get 'about' + response.should be_success + end + end + +end diff --git a/spec/factories/admines_useres.rb b/spec/factories/admines_useres.rb new file mode 100644 index 0000000..7d84a5f --- /dev/null +++ b/spec/factories/admines_useres.rb @@ -0,0 +1,6 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :admin_user do + end +end diff --git a/spec/factories/archivos.rb b/spec/factories/archivos.rb new file mode 100644 index 0000000..b1181d3 --- /dev/null +++ b/spec/factories/archivos.rb @@ -0,0 +1,8 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :archivo do + denuncia nil + adjunto "MyString" + end +end diff --git a/spec/factories/denuncias.rb b/spec/factories/denuncias.rb new file mode 100644 index 0000000..0242e14 --- /dev/null +++ b/spec/factories/denuncias.rb @@ -0,0 +1,12 @@ +# encoding: UTF-8 +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :denuncia do + funcionario "Juan Pérez" + queja "Muy prepotente en su trato" + email "denunciante@mail.com" + association :dependencia, factory: :dependencia + finalizada true + end +end diff --git a/spec/factories/dependencias.rb b/spec/factories/dependencias.rb new file mode 100644 index 0000000..fac9798 --- /dev/null +++ b/spec/factories/dependencias.rb @@ -0,0 +1,8 @@ +# encoding: UTF-8 +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :dependencia do + nombre "Contraloría" + end +end diff --git a/spec/fixtures/denuncia_mailer/confirmar_denuncia b/spec/fixtures/denuncia_mailer/confirmar_denuncia new file mode 100644 index 0000000..ba29af1 --- /dev/null +++ b/spec/fixtures/denuncia_mailer/confirmar_denuncia @@ -0,0 +1,3 @@ +DenunciaMailer#confirmar_denuncia + +Hi, find me in app/views/denuncia_mailer/confirmar_denuncia diff --git a/spec/fixtures/files/file b/spec/fixtures/files/file new file mode 100644 index 0000000..e69de29 diff --git a/spec/fixtures/files/image-1.png b/spec/fixtures/files/image-1.png new file mode 100644 index 0000000..9d2ea73 Binary files /dev/null and b/spec/fixtures/files/image-1.png differ diff --git a/spec/fixtures/files/image-2.png b/spec/fixtures/files/image-2.png new file mode 100644 index 0000000..9d2ea73 Binary files /dev/null and b/spec/fixtures/files/image-2.png differ diff --git a/spec/helpers/denuncias_helper_spec.rb b/spec/helpers/denuncias_helper_spec.rb new file mode 100644 index 0000000..117332c --- /dev/null +++ b/spec/helpers/denuncias_helper_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +# Specs in this file have access to a helper object that includes +# the DenunciasHelper. For example: +# +# describe DenunciasHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# helper.concat_strings("this","that").should == "this that" +# end +# end +# end +describe DenunciasHelper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/home_helper_spec.rb b/spec/helpers/home_helper_spec.rb new file mode 100644 index 0000000..4a37633 --- /dev/null +++ b/spec/helpers/home_helper_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +# Specs in this file have access to a helper object that includes +# the HomeHelper. For example: +# +# describe HomeHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# helper.concat_strings("this","that").should == "this that" +# end +# end +# end +describe HomeHelper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/mailers/denuncia_mailer_spec.rb b/spec/mailers/denuncia_mailer_spec.rb new file mode 100644 index 0000000..ad135e9 --- /dev/null +++ b/spec/mailers/denuncia_mailer_spec.rb @@ -0,0 +1,21 @@ +# encoding: UTF-8 +require "spec_helper" + +describe DenunciaMailer do + describe "confirmar_denuncia" do + let(:denuncia) { FactoryGirl.create :denuncia } + let(:mail) { DenunciaMailer.confirmar_denuncia(denuncia) } + + it "renders the headers" do + mail.subject.should eq 'Denuncia generada desde Denuncia Ciudadana' + mail.to.should eq ["denunciante@mail.com"] + mail.from.should eq ["from@example.com"] + end + + it "renders number of denuncia in body" do + folio = "%010d" % denuncia.id + mail.body.encoded.should match(/#{folio}/) + end + end + +end diff --git a/spec/models/admin_user_spec.rb b/spec/models/admin_user_spec.rb new file mode 100644 index 0000000..3d15302 --- /dev/null +++ b/spec/models/admin_user_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe AdminUser do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/archivo_spec.rb b/spec/models/archivo_spec.rb new file mode 100644 index 0000000..e36b2a0 --- /dev/null +++ b/spec/models/archivo_spec.rb @@ -0,0 +1,24 @@ +require 'spec_helper' + +describe Archivo do + it { should belong_to :denuncia } + it { should allow_mass_assignment_of :adjunto } + it { should_not allow_mass_assignment_of :denuncia_id } + + describe '#url_id' do + context 'valid?' do + before :each do + @archivo = Archivo.new + @archivo.valid? + end + + it 'should not be when validated' do + @archivo.url_id.should_not be_empty + end + + it 'should contain a hash when validated' do + @archivo.url_id.length.should == 40 + end + end + end +end diff --git a/spec/models/denuncia_spec.rb b/spec/models/denuncia_spec.rb new file mode 100644 index 0000000..ec1a27d --- /dev/null +++ b/spec/models/denuncia_spec.rb @@ -0,0 +1,45 @@ +require 'spec_helper' + +describe Denuncia do + + def valid_attributes + { 'funcionario' => 'Nombre Funcionario', 'queja' => 'Descripcion de la denuncia', 'email' => 'denunciante@mail.com', dependencia_id: dependencia.id} + end + + let(:dependencia) { FactoryGirl.create :dependencia } + + it { should belong_to :dependencia } + it { should have_many :archivos } + + it { should validate_presence_of :email } + it { should validate_presence_of :funcionario } + it { should validate_presence_of :queja } + it { should validate_presence_of :dependencia } + it { should validate_presence_of :finalizada } + + it { should accept_nested_attributes_for :archivos } + + it { should allow_mass_assignment_of :email } + it { should allow_mass_assignment_of :funcionario } + it { should allow_mass_assignment_of :queja } + it { should allow_mass_assignment_of :dependencia_id } + it { should allow_mass_assignment_of :archivos_attributes } + + describe '#email' do + it { should allow_value("denunciante@mail.com").for(:email) } + it { should_not allow_value("foo").for(:email) } + end + + describe '#finalize' do + it 'returns true' do + denuncia = Denuncia.new + denuncia.finalize(valid_attributes).should be_true + end + + it 'returns false' do + denuncia = Denuncia.new + denuncia.finalize({}).should be_false + end + end + +end diff --git a/spec/models/dependencia_spec.rb b/spec/models/dependencia_spec.rb new file mode 100644 index 0000000..2e1132b --- /dev/null +++ b/spec/models/dependencia_spec.rb @@ -0,0 +1,6 @@ +require 'spec_helper' + +describe Dependencia do + it { should have_many :denuncias } + it { should validate_presence_of :nombre } +end diff --git a/spec/routing/denuncias_routing_spec.rb b/spec/routing/denuncias_routing_spec.rb new file mode 100644 index 0000000..1742d48 --- /dev/null +++ b/spec/routing/denuncias_routing_spec.rb @@ -0,0 +1,35 @@ +require "spec_helper" + +describe DenunciasController do + describe "routing" do + + it "routes to #index" do + expect(get: "/denuncias").not_to be_routable + end + + it "routes to #new" do + get("/denuncias/new").should route_to("denuncias#new") + end + + it "routes to #show" do + get("/denuncias/1").should route_to("denuncias#show", :id => "1") + end + + it "routes to #edit" do + expect(get: "/denuncias/1/edit").not_to be_routable + end + + it "routes to #create" do + post("/denuncias").should route_to("denuncias#create") + end + + it "routes to #update" do + expect(put: "/denuncias/1").not_to be_routable + end + + it "routes to #destroy" do + expect(delete: "/denuncias/1").not_to be_routable + end + + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..0909127 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,38 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +ENV["RAILS_ENV"] ||= 'test' +require File.expand_path("../../config/environment", __FILE__) +require 'rspec/rails' +require 'rspec/autorun' + +# Requires supporting ruby files with custom matchers and macros, etc, +# in spec/support/ and its subdirectories. +Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} + +RSpec.configure do |config| + # ## Mock Framework + # + # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: + # + # config.mock_with :mocha + # config.mock_with :flexmock + # config.mock_with :rr + + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_path = "#{::Rails.root}/spec/fixtures" + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true + + # If true, the base class of anonymous controllers will be inferred + # automatically. This will be the default behavior in future versions of + # rspec-rails. + config.infer_base_class_for_anonymous_controllers = false + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = "random" +end diff --git a/test/performance/browsing_test.rb b/test/performance/browsing_test.rb new file mode 100644 index 0000000..3fea27b --- /dev/null +++ b/test/performance/browsing_test.rb @@ -0,0 +1,12 @@ +require 'test_helper' +require 'rails/performance_test_help' + +class BrowsingTest < ActionDispatch::PerformanceTest + # Refer to the documentation for all available options + # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory] + # :output => 'tmp/performance', :formats => [:flat] } + + def test_homepage + get '/' + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..8bf1192 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,13 @@ +ENV["RAILS_ENV"] = "test" +require File.expand_path('../../config/environment', __FILE__) +require 'rails/test_help' + +class ActiveSupport::TestCase + # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. + # + # Note: You'll currently still have to declare fixtures explicitly in integration tests + # -- they do not yet inherit this setting + fixtures :all + + # Add more helper methods to be used by all tests here... +end