Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Empezando a poner generar una API rest en los controladores

Los simple forms por defecto son form-horizontal
Añadido encoding a todos los ficheros
Tests de helpers tambien
  • Loading branch information...
commit 2831e0c2ee40942285b2d9b87c003b28824eda9c 1 parent 8b1e814
miguel.camba authored

Showing 62 changed files with 351 additions and 93 deletions. Show diff stats Hide diff stats

  1. +8 3 Gemfile
  2. +7 0 Gemfile.lock
  3. +1 0  app/assets/javascripts/application.js
  4. +11 0 app/assets/javascripts/common.js.coffee
  5. +37 3 app/assets/javascripts/users.js.coffee
  6. +1 0  app/controllers/application_controller.rb
  7. +1 0  app/controllers/issues_controller.rb
  8. +1 0  app/controllers/projects_controller.rb
  9. +2 1  app/controllers/sessions_controller.rb
  10. +14 5 app/controllers/users_controller.rb
  11. +2 2 app/controllers/welcome_controller.rb
  12. +38 0 app/helpers/application_helper.rb
  13. +1 0  app/helpers/issues_helper.rb
  14. +1 0  app/helpers/projects_helper.rb
  15. +1 0  app/helpers/sessions_helper.rb
  16. +1 0  app/helpers/users_helper.rb
  17. +1 0  app/models/issue.rb
  18. +1 0  app/models/project.rb
  19. +4 2 app/models/user.rb
  20. +2 1  app/models/with_creator.rb
  21. +2 1  app/models/with_responsable.rb
  22. +5 4 app/views/layouts/application.html.haml
  23. +1 1  app/views/sessions/_login_form.html.haml
  24. +2 2 app/views/sessions/create.js.coffee
  25. +0 1  app/views/users/create.html.haml
  26. +72 20 app/views/users/my_profile.html.haml
  27. +5 15 app/views/users/new.html.haml
  28. +0 6 app/views/welcome/signup.html.haml
  29. +1 0  config/application.rb
  30. +1 0  config/boot.rb
  31. +1 0  config/environment.rb
  32. +1 0  config/environments/development.rb
  33. +1 0  config/environments/production.rb
  34. +1 0  config/environments/test.rb
  35. +1 0  config/initializers/backtrace_silencers.rb
  36. +1 0  config/initializers/inflections.rb
  37. +1 0  config/initializers/mime_types.rb
  38. +1 0  config/initializers/secret_token.rb
  39. +1 0  config/initializers/session_store.rb
  40. +19 19 config/initializers/simple_form.rb
  41. +1 0  config/initializers/sorcery.rb
  42. +1 0  config/initializers/wrap_parameters.rb
  43. +1 0  config/routes.rb
  44. +1 0  db/migrate/20120425210953_create_projects.rb
  45. +1 0  db/migrate/20120425211013_create_issues.rb
  46. +1 0  db/migrate/20120427064910_create_users.rb
  47. +1 0  db/migrate/20120427065047_add_creator_to_project.rb
  48. +1 0  db/migrate/20120427065225_add_responsable_to_issues.rb
  49. +1 0  db/migrate/20120427124402_add_creator_to_issues.rb
  50. +1 0  db/migrate/20120427131211_add_responsable_to_project.rb
  51. +11 0 db/migrate/20120502070424_add_personal_data_to_user.rb
  52. +8 2 db/schema.rb
  53. +1 0  db/seeds.rb
  54. +2 1  spec/factories.rb
  55. +56 0 spec/helpers/application_helper_spec.rb
  56. +2 1  spec/models/issue_spec.rb
  57. +2 1  spec/models/project_spec.rb
  58. +1 0  spec/models/user_spec.rb
  59. +1 0  spec/spec_helper.rb
  60. +1 0  spec/support/models/custom_matchers.rb
  61. +2 1  spec/support/models/with_creator_shared_examples.rb
  62. +2 1  spec/support/models/with_responsable_shared_examples.rb
11 Gemfile
@@ -22,6 +22,7 @@ group :assets do
22 22 end
23 23
24 24 gem 'jquery-rails'
  25 +gem 'underscore-rails'
25 26 gem 'haml-rails'
26 27 gem 'decent_exposure'
27 28 gem 'bcrypt-ruby'
@@ -39,14 +40,18 @@ group :development do
39 40 gem 'quiet_assets'
40 41 end
41 42
42   -group :test, :development do
43   - gem 'foreigner'
  43 +group :test do
44 44 gem 'rspec-rails'
45   - gem 'factory_girl_rails'
  45 + gem 'rspec-html-matchers'
46 46 gem 'shoulda-matchers'
47 47 gem 'ipsum'
48 48 end
49 49
  50 +group :test, :development do
  51 + gem 'foreigner'
  52 + gem 'factory_girl_rails'
  53 +end
  54 +
50 55 # To use ActiveModel has_secure_password
51 56 # gem 'bcrypt-ruby', '~> 3.0.0'
52 57
7 Gemfile.lock
@@ -123,6 +123,7 @@ GEM
123 123 mime-types (1.18)
124 124 multi_json (1.3.2)
125 125 multipart-post (1.1.5)
  126 + nokogiri (1.5.2)
126 127 oauth (0.4.6)
127 128 oauth2 (0.5.2)
128 129 faraday (~> 0.7)
@@ -168,6 +169,9 @@ GEM
168 169 rspec-core (2.9.0)
169 170 rspec-expectations (2.9.1)
170 171 diff-lcs (~> 1.1.3)
  172 + rspec-html-matchers (0.3.5)
  173 + nokogiri (>= 1.4.4)
  174 + rspec (>= 2.0.0)
171 175 rspec-mocks (2.9.0)
172 176 rspec-rails (2.9.0)
173 177 actionpack (>= 3.0)
@@ -212,6 +216,7 @@ GEM
212 216 uglifier (1.2.4)
213 217 execjs (>= 0.3.0)
214 218 multi_json (>= 1.0.2)
  219 + underscore-rails (1.3.1)
215 220
216 221 PLATFORMS
217 222 ruby
@@ -233,6 +238,7 @@ DEPENDENCIES
233 238 pry-rails
234 239 quiet_assets
235 240 rails (= 3.2.3)
  241 + rspec-html-matchers
236 242 rspec-rails
237 243 sass-rails (~> 3.2.3)
238 244 shoulda-matchers
@@ -243,3 +249,4 @@ DEPENDENCIES
243 249 thin-rails
244 250 twitter-bootstrap-rails!
245 251 uglifier (>= 1.0.3)
  252 + underscore-rails
1  app/assets/javascripts/application.js
@@ -12,5 +12,6 @@
12 12 //
13 13 //= require jquery
14 14 //= require jquery_ujs
  15 +//= require underscore
15 16 //= require twitter/bootstrap
16 17 //= require_tree .
11 app/assets/javascripts/common.js.coffee
... ... @@ -0,0 +1,11 @@
  1 +jQuery ->
  2 + $('.toggle-edition').click (e)->
  3 + e.preventDefault()
  4 + $button = $(this)
  5 + $form = $button.closest('form')
  6 + if $button.hasClass 'edit'
  7 + $form.find('input').removeClass('disabled').prop('disabled', false)
  8 + $button.removeClass('edit').addClass('btn-danger').html('<i class="icon-remove"></i> Cancelar')
  9 + else
  10 + $form.find('input').addClass('disabled').prop('disabled', true)
  11 + $button.addClass('edit').removeClass('btn-danger').html('<i class="icon-edit"></i> Editar')
40 app/assets/javascripts/users.js.coffee
... ... @@ -1,3 +1,37 @@
1   -# Place all the behaviors and hooks related to the matching controller here.
2   -# All this logic will automatically be available in application.js.
3   -# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
  1 +# Templates al estilo moustache
  2 +_.templateSettings =
  3 + interpolate : /\{\{(.+?)\}\}/g
  4 +
  5 +# Función para poner un alert en su sitio predefinido a un form (marcado por .alert-container)
  6 +$.fn.extend
  7 + bootstrapAlert: (text, level = 'error') ->
  8 + alertClass = if level then "alert-#{level}" else ''
  9 + alertTemplate = _.template $('#alertTemplate').html()
  10 + $(this).find('.alert-container').html alertTemplate({ text: text, klass: alertClass })
  11 + hideValidationErrors: () ->
  12 + $(this).find('.control-group').removeClass('error')
  13 + $(this).find('.help-block.error').remove()
  14 + $(this).find('.alert-error').alert('close')
  15 + showValidationErrors: (jsonErrors) ->
  16 + $(this).hideValidationErrors()
  17 + for field, errors of jsonErrors
  18 + $input = $("##{$(this).data('model')}_#{field}")
  19 + $input.closest('.control-group').addClass('error')
  20 + $input.after "<p class='help-block error'>#{errors.join('. ')}</p>"
  21 + bootstrapValidation: (response) ->
  22 + json = $.parseJSON(response.responseText)
  23 + $(this).showValidationErrors(json.errors)
  24 + $(this).bootstrapAlert '<strong>Oh oh!</strong> Parece que hay algún dato erróneo'
  25 +
  26 +jQuery ->
  27 + # Cuando enviar un formulario de usuario, en realidad se envía una petición de JSON que devuelve
  28 + # el objeto actualizado o los errores.
  29 + $('.user_form').submit (e)->
  30 + $form = $(this)
  31 + e.preventDefault()
  32 + $.post("#{@action}.json", $(this).serialize())
  33 + .success (response) ->
  34 + $form.hideValidationErrors()
  35 + $form.bootstrapAlert '<strong>Listo!</strong> Se han actualizado los datos', 'success'
  36 + .error (response) ->
  37 + $form.bootstrapValidation(response)
1  app/controllers/application_controller.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 class ApplicationController < ActionController::Base
2 3 protect_from_forgery
3 4
1  app/controllers/issues_controller.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 class IssuesController < ApplicationController
2 3
3 4 def index
1  app/controllers/projects_controller.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 class ProjectsController < ApplicationController
2 3
3 4 #
3  app/controllers/sessions_controller.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 class SessionsController < ApplicationController
2 3 layout 'login'
3 4
@@ -20,7 +21,7 @@ def create
20 21 render :new
21 22 end
22 23 end
23   - format.js
  24 + format.js { flash[:success] = "Login correct" }
24 25 end
25 26 end
26 27
19 app/controllers/users_controller.rb
... ... @@ -1,4 +1,5 @@
1 1 class UsersController < ApplicationController
  2 + respond_to :html, :json
2 3 #
3 4 # Filters
4 5 #
@@ -12,16 +13,24 @@ class UsersController < ApplicationController
12 13 expose(:user)
13 14
14 15 def new
  16 + respond_with user
  17 + end
  18 +
  19 + def edit
  20 + respond_with user
15 21 end
16 22
17 23 def create
18 24 if user.save
19   - auto_login(user)
20   - flash.now.alert = "Email or password was invalid."
21   - redirect_to root_url, :notice => "Signed up!"
22   - else
23   - render :new
  25 + auto_login user
  26 + flash[:notice] = "User was created successfully."
24 27 end
  28 + respond_with user, location: root_url
  29 + end
  30 +
  31 + def update
  32 + flash[:notice] = "User was created updated." if user.save
  33 + respond_with user
25 34 end
26 35
27 36 # def index
4 app/controllers/welcome_controller.rb
... ... @@ -1,9 +1,9 @@
  1 +# -*- encoding : utf-8 -*-
1 2 class WelcomeController < ApplicationController
2 3 before_filter :redirect_to_welcome_unless_logged, only: :index
3 4
4   -
5 5 private
6 6 def redirect_to_welcome_unless_logged
7 7 redirect_to welcome_path unless logged_in?
8 8 end
9   -end
  9 +end
38 app/helpers/application_helper.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 module ApplicationHelper
2 3
3 4 # Sobreescribo link_to para que acepte opciones útiles.
@@ -13,4 +14,41 @@ def link_to(body, url, html_options = {})
13 14 super body, url, html_options
14 15 end
15 16
  17 + def default_text_for_bootstrap_alert(level)
  18 + text = case level.to_s
  19 + when 'notice' then nil
  20 + when 'error' then '<strong>Oh oh!</strong> Parece que hay algún dato erróneo'
  21 + when 'alert' then nil
  22 + when 'success' then '<strong>Listo!</strong> Se han actualizado los datos'
  23 + else nil
  24 + end
  25 + return nil unless text
  26 + text.html_safe
  27 + end
  28 +
  29 + # Renderiza un alert estilado para bootstrap, con boton de cerrar.
  30 + def bootstrap_alert(text = nil, level = nil)
  31 + text ||= default_text_for_bootstrap_alert(level)
  32 + content_tag :div, class: "alert fade in #{flash_class(level)}" do
  33 + button_tag('×', class: 'close', 'data-dismiss' => "alert") + content_tag(:div, text, class: 'text-center')
  34 + end
  35 + end
  36 +
  37 + # Renderiza los flashes (:notice, :error, :success ...) con estilo de alerts de bootstrap
  38 + def bootstrap_flashes
  39 + [:notice, :error, :alert, :success].map do |level|
  40 + bootstrap_alert(flash[level], level) unless flash[level].blank?
  41 + end.join.html_safe
  42 + end
  43 +
  44 + # Dado un tipo de mensaje flash, devuelve la clase del alert de bootstrap correspondiente
  45 + def flash_class(level)
  46 + case level.to_s
  47 + when 'notice' then "alert-info"
  48 + when 'error' then "alert-error"
  49 + when 'alert' then "alert-warning"
  50 + when 'success' then "alert-success"
  51 + end
  52 + end
  53 +
16 54 end
1  app/helpers/issues_helper.rb
... ... @@ -1,2 +1,3 @@
  1 +# -*- encoding : utf-8 -*-
1 2 module IssuesHelper
2 3 end
1  app/helpers/projects_helper.rb
... ... @@ -1,2 +1,3 @@
  1 +# -*- encoding : utf-8 -*-
1 2 module ProjectsHelper
2 3 end
1  app/helpers/sessions_helper.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 module SessionsHelper
2 3
3 4 def username_placeholder
1  app/helpers/users_helper.rb
... ... @@ -1,2 +1,3 @@
  1 +# -*- encoding : utf-8 -*-
1 2 module UsersHelper
2 3 end
1  app/models/issue.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 class Issue < ActiveRecord::Base
2 3 attr_accessible :title, :code, :description, :project, :status, :percentage
3 4 include WithResponsable
1  app/models/project.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 class Project < ActiveRecord::Base
2 3 attr_accessible :name
3 4 include WithResponsable
6 app/models/user.rb
... ... @@ -1,7 +1,9 @@
  1 +# -*- encoding : utf-8 -*-
1 2 class User < ActiveRecord::Base
2 3 authenticates_with_sorcery!
3 4
4   - attr_accessible :username, :email, :password, :password_confirmation
  5 + attr_accessible :username, :email, :password, :password_confirmation, :name, :surname1, :surname2, :twitter,
  6 + :github
5 7
6 8 #
7 9 # Relations
@@ -14,7 +16,7 @@ class User < ActiveRecord::Base
14 16 #
15 17 validates :username, presence: true, uniqueness: true, length: 5..20
16 18 validates :email, presence: true, uniqueness: true, email: true
17   - validates :password, presence: { on: :create }, confirmation: true, length: 5..20
  19 + validates :password, presence: { on: :create }, confirmation: true, length: { in: 5..20, on: :create }
18 20
19 21 #
20 22 # Métodos de instancia
3  app/models/with_creator.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 module WithCreator
2 3
3 4 def self.included(base)
@@ -20,4 +21,4 @@ def created_by?(usr)
20 21 creator == usr
21 22 end
22 23
23   -end
  24 +end
3  app/models/with_responsable.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 module WithResponsable
2 3
3 4 def self.included(base)
@@ -15,4 +16,4 @@ def assigned_to?(usr)
15 16 responsable == usr
16 17 end
17 18
18   -end
  19 +end
9 app/views/layouts/application.html.haml
@@ -14,14 +14,14 @@
14 14 %span.icon-bar
15 15 %span.icon-bar
16 16 %span.icon-bar
17   - = link_to 'Pinkmine', '#', class: 'brand'
  17 + = link_to 'Pinkmine', root_url, class: 'brand'
18 18 .btn-group.pull-right
19 19 %a.btn.dropdown-toggle{ 'data-toggle' => 'dropdown', href: "#" }
20   - %i.icon-user= " #{current_user ? current_user.username : 'Username'}"
  20 + %i.icon-home= " #{current_user ? current_user.username : 'Username'}"
21 21 %span.caret
22 22 %ul.dropdown-menu
23   - %li= link_to 'Profile', my_profile_path, icon: 'pencil'
24   - %li= link_to 'Stats', my_profile_path, icon: 'home'
  23 + %li= link_to 'Profile', my_profile_path, icon: 'user'
  24 + %li= link_to 'Stats', my_profile_path, icon: 'calendar'
25 25 %li.divider
26 26 %li= link_to 'Sign Out', logout_path, icon: 'off'
27 27 .nav-collapse
@@ -31,4 +31,5 @@
31 31 %li= link_to 'Contact', '#contact'
32 32
33 33 .container-fluid
  34 + .row-fluid= bootstrap_flashes
34 35 = yield
2  app/views/sessions/_login_form.html.haml
... ... @@ -1,5 +1,5 @@
1 1 - remote ||= false
2   -= form_tag sessions_path, remote: remote, class: 'form-horizontal', id: 'loginForm' do |f|
  2 += form_tag sessions_path, remote: remote, class: 'form-horizontal', id: 'login_form' do |f|
3 3 = render 'login_error' if action_name == 'create'
4 4 %fieldset
5 5 .control-group
4 app/views/sessions/create.js.coffee
@@ -2,6 +2,6 @@
2 2 window.location = "<%= root_url %>"
3 3 <% else %>
4 4 $alertError = $("<%= j render 'login_error' %>")
5   - $('#loginForm .alert-error').remove()
6   - $('#loginForm fieldset').before $alertError.fadeIn(50)
  5 + $('#login_form .alert-error').remove()
  6 + $('#login_form fieldset').before $alertError.fadeIn(50)
7 7 <% end %>
1  app/views/users/create.html.haml
... ... @@ -1 +0,0 @@
1   -%h1 Usuario creado!!
92 app/views/users/my_profile.html.haml
... ... @@ -1,30 +1,82 @@
  1 +/ Template de alerts
  2 +%script#alertTemplate{ type: "text/template" }
  3 + .alert{ class: "{{klass}}"}
  4 + %a.close{ 'data-dismiss' => 'alert', href: "#"}×
  5 + {{text}}
  6 +
  7 +/ Contenido estático
1 8 .row-fluid
2 9 .span3
3   - .well.sidebar-nav
4   - %ul.nav.nav-tabs.nav-stacked
5   - %li.nav-header Mis datos
6   - %li.active= link_to 'Cuenta', '#account', icon: 'user', 'data-toggle' => "tab"
7   - %li= link_to 'Datos personales', '#personal', icon: 'book', 'data-toggle' => "tab"
8   - %li= link_to 'Asociaciones', '#associations', icon: 'home', 'data-toggle' => "tab"
9   - %li= link_to 'Alertas', '#alerts', icon: 'envelope', 'data-toggle' => "tab"
10   - %li.nav-header Seguridad
11   - %li= link_to 'RSS Keys', '#rss', icon: 'qrcode', 'data-toggle' => "tab"
12   - %li= link_to 'API keys', '#api', icon: 'barcode', 'data-toggle' => "tab"
  10 + .sidebar-nav
  11 + .well
  12 + %ul.nav.nav-pills.nav-stacked
  13 + %li.nav-header Mis datos
  14 + %li.active= link_to 'Cuenta', '#account', icon: 'user', 'data-toggle' => "tab"
  15 + %li= link_to 'Datos personales', '#personal', icon: 'book', 'data-toggle' => "tab"
  16 + %li= link_to 'Asociaciones', '#associations', icon: 'home', 'data-toggle' => "tab"
  17 + %li= link_to 'Alertas', '#alerts', icon: 'envelope', 'data-toggle' => "tab"
  18 + %li.nav-header Seguridad
  19 + %li= link_to 'RSS Keys', '#rss', icon: 'qrcode', 'data-toggle' => "tab"
  20 + %li= link_to 'API keys', '#api', icon: 'barcode', 'data-toggle' => "tab"
  21 + %li.divider
  22 + %li= link_to 'Help', '#help', icon: 'question-sign', 'data-toggle' => "tab"
13 23 .span9
14 24 .tab-content
15 25 #account.tab-pane.active
16   - %h2 Cuenta
17   - .row
18   - .span2
19   - %label Email
20   - .span3 info@pinkmine.com
21   - .span2
22   - %label Otro dato
23   - .span3 03/09/1986
  26 + = simple_form_for current_user, html: { class: 'user_form', 'data-model' => 'user' } do |f|
  27 + %fieldset
  28 + .row-fluid
  29 + %legend
  30 + Mi cuenta
  31 + = link_to ' Editar', '#', class: 'btn btn-mini pull-right toggle-edition edit', icon: 'edit'
  32 + .alert-container.text-center
  33 + .row-fluid
  34 + .span6
  35 + = f.input :username, disabled: true
  36 + = f.input :email, disabled: true
  37 + .span6
  38 + = f.input :password, disabled: true
  39 + = f.input :password_confirmation, disabled: true
  40 + .row-fluid
  41 + .span12.text-center
  42 + = f.button :submit, class: 'btn-primary', disabled: true
24 43 #personal.tab-pane
25   - %h2 Datos personales
  44 + = simple_form_for current_user, html: { class: 'user_form', 'data-model' => 'user' } do |f|
  45 + %fieldset
  46 + .row-fluid
  47 + %legend
  48 + Datos personales
  49 + = link_to ' Editar', '#', class: 'btn btn-mini pull-right toggle-edition edit', icon: 'edit'
  50 + .alert-container.text-center
  51 + .row-fluid
  52 + .span6
  53 + = f.input :name, disabled: true
  54 + = f.input :surname1, disabled: true
  55 + = f.input :surname2, disabled: true
  56 + .span6
  57 + = f.input :twitter, disabled: true
  58 + = f.input :github, disabled: true
  59 + .row-fluid
  60 + .span12.text-center
  61 + = f.button :submit, class: 'btn-primary', disabled: true
26 62 #associations.tab-pane
27   - %h2 Asociaciones
  63 + = simple_form_for current_user, html: { class: 'user_form', 'data-model' => 'user' } do |f|
  64 + %fieldset
  65 + .row-fluid
  66 + %legend
  67 + Asociaciones
  68 + = link_to ' Editar', '#', class: 'btn btn-mini pull-right toggle-edition edit', icon: 'edit'
  69 + .alert-container.text-center
  70 + .row-fluid
  71 + .span6
  72 + = f.input :username, disabled: true
  73 + = f.input :email, disabled: true
  74 + .span6
  75 + = f.input :password, disabled: true
  76 + = f.input :password_confirmation, disabled: true
  77 + .row-fluid
  78 + .span12.text-center
  79 + = f.button :submit, class: 'btn-primary', disabled: true
28 80 #alerts.tab-pane
29 81 %h2 Alertas
30 82 #rss.tab-pane
20 app/views/users/new.html.haml
... ... @@ -1,10 +1,13 @@
1   -- remote ||= false
2   -= simple_form_for user, html: { class: 'form-horizontal', id: 'signupForm' } do |f|
  1 += simple_form_for user do |f|
3 2 .row-fluid
4 3 .span2
5 4 .span8
6 5 %fieldset
7 6 %legend Datos de usuario
  7 + - if f.object.errors.any?
  8 + .row-fluid
  9 + .margin-1em
  10 + .span12= bootstrap_alert nil, :error
8 11 .row-fluid
9 12 .margin-1em
10 13 .span6
@@ -13,19 +16,6 @@
13 16 .span6
14 17 = f.input :password
15 18 = f.input :password_confirmation
16   - / .row-fluid.margin-1em
17   - / .span2
18   - / .span8
19   - / %fieldset
20   - / %legend Datos personales
21   - / .row-fluid
22   - / .margin-1em
23   - / .span6
24   - / = f.input :username #, input_html: { class: 'input-xlarge' }
25   - / = f.input :email #, input_html: { class: 'input-xlarge' }
26   - / .span6
27   - / = f.input :password
28   - / = f.input :password_confirmation
29 19 .row-fluid
30 20 .span2
31 21 .span8
6 app/views/welcome/signup.html.haml
... ... @@ -1,6 +0,0 @@
1   -.row-fluid
2   - = form_for '/signup' do |f|
3   - .span3.offset2
4   - %p Email
5   - .span6
6   - = f.text_field :login
1  config/application.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 require File.expand_path('../boot', __FILE__)
2 3
3 4 require 'rails/all'
1  config/boot.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 require 'rubygems'
2 3
3 4 # Set up gems listed in the Gemfile.
1  config/environment.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 # Load the rails application
2 3 require File.expand_path('../application', __FILE__)
3 4
1  config/environments/development.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 Pinkmine::Application.configure do
2 3 # Settings specified here will take precedence over those in config/application.rb
3 4
1  config/environments/production.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 Pinkmine::Application.configure do
2 3 # Settings specified here will take precedence over those in config/application.rb
3 4
1  config/environments/test.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 Pinkmine::Application.configure do
2 3 # Settings specified here will take precedence over those in config/application.rb
3 4
1  config/initializers/backtrace_silencers.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 # Be sure to restart your server when you modify this file.
2 3
3 4 # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
1  config/initializers/inflections.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 # Be sure to restart your server when you modify this file.
2 3
3 4 # Add new inflection rules using the following format
1  config/initializers/mime_types.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 # Be sure to restart your server when you modify this file.
2 3
3 4 # Add new mime types for use in respond_to blocks:
1  config/initializers/secret_token.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 # Be sure to restart your server when you modify this file.
2 3
3 4 # Your secret key for verifying the integrity of signed cookies.
1  config/initializers/session_store.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 # Be sure to restart your server when you modify this file.
2 3
3 4 Pinkmine::Application.config.session_store :cookie_store, key: '_pinkmine_session'
38 config/initializers/simple_form.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 # Use this setup block to configure all options available in SimpleForm.
2 3 SimpleForm.setup do |config|
3 4 # Wrappers are used by the form builder to generate a
@@ -5,8 +6,7 @@
5 6 # wrapper, change the order or even add your own to the
6 7 # stack. The options given below are used to wrap the
7 8 # whole input.
8   - config.wrappers :default, :class => :input,
9   - :hint_class => :field_with_hint, :error_class => :field_with_errors do |b|
  9 + config.wrappers :default, class: :input, hint_class: :field_with_hint, error_class: :field_with_errors do |b|
10 10 ## Extensions enabled by default
11 11 # Any of these extensions can be disabled for a
12 12 # given input by passing: `f.input EXTENSION_NAME => false`.
@@ -41,44 +41,44 @@
41 41
42 42 ## Inputs
43 43 b.use :label_input
44   - b.use :hint, :wrap_with => { :tag => :span, :class => :hint }
45   - b.use :error, :wrap_with => { :tag => :span, :class => :error }
  44 + b.use :hint, wrap_with: { tag: :span, class: :hint }
  45 + b.use :error, wrap_with: { tag: :span, class: :error }
46 46 end
47 47
48   - config.wrappers :bootstrap, :tag => 'div', :class => 'control-group', :error_class => 'error' do |b|
  48 + config.wrappers :bootstrap, tag: 'div', class: 'control-group', error_class: 'error' do |b|
49 49 b.use :html5
50 50 b.use :placeholder
51 51 b.use :label
52   - b.wrapper :tag => 'div', :class => 'controls' do |ba|
  52 + b.wrapper tag: 'div', class: 'controls' do |ba|
53 53 ba.use :input
54   - ba.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
55   - ba.use :hint, :wrap_with => { :tag => 'p', :class => 'help-block' }
  54 + ba.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
  55 + ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
56 56 end
57 57 end
58 58
59   - config.wrappers :prepend, :tag => 'div', :class => "control-group", :error_class => 'error' do |b|
  59 + config.wrappers :prepend, tag: 'div', class: "control-group", error_class: 'error' do |b|
60 60 b.use :html5
61 61 b.use :placeholder
62 62 b.use :label
63   - b.wrapper :tag => 'div', :class => 'controls' do |input|
64   - input.wrapper :tag => 'div', :class => 'input-prepend' do |prepend|
  63 + b.wrapper tag: 'div', class: 'controls' do |input|
  64 + input.wrapper tag: 'div', class: 'input-prepend' do |prepend|
65 65 prepend.use :input
66 66 end
67   - input.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block' }
68   - input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
  67 + input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
  68 + input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
69 69 end
70 70 end
71 71
72   - config.wrappers :append, :tag => 'div', :class => "control-group", :error_class => 'error' do |b|
  72 + config.wrappers :append, tag: 'div', class: "control-group", error_class: 'error' do |b|
73 73 b.use :html5
74 74 b.use :placeholder
75 75 b.use :label
76   - b.wrapper :tag => 'div', :class => 'controls' do |input|
77   - input.wrapper :tag => 'div', :class => 'input-append' do |append|
  76 + b.wrapper tag: 'div', class: 'controls' do |input|
  77 + input.wrapper tag: 'div', class: 'input-append' do |append|
78 78 append.use :input
79 79 end
80   - input.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block' }
81   - input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
  80 + input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
  81 + input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
82 82 end
83 83 end
84 84
@@ -136,7 +136,7 @@
136 136 config.label_class = 'control-label'
137 137
138 138 # You can define the class to use on all forms. Default is simple_form.
139   - # config.form_class = :simple_form
  139 + config.form_class = 'simple_form form-horizontal'
140 140
141 141 # You can define which elements should obtain additional classes
142 142 # config.generate_additional_classes_for = [:wrapper, :label, :input]
1  config/initializers/sorcery.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 # The first thing you need to configure is which modules you need in your app.
2 3 # The default is nothing which will include only core features (password encryption, login/logout).
3 4 # Available submodules are: :user_activation, :http_basic_auth, :remember_me,
1  config/initializers/wrap_parameters.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 # Be sure to restart your server when you modify this file.
2 3 #
3 4 # This file contains settings for ActionController::ParamsWrapper which
1  config/routes.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 Pinkmine::Application.routes.draw do
2 3 get "logout" => "sessions#destroy", as: "logout"
3 4 get "login" => "sessions#new", as: "login"
1  db/migrate/20120425210953_create_projects.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 class CreateProjects < ActiveRecord::Migration
2 3 def change
3 4 create_table :projects do |t|
1  db/migrate/20120425211013_create_issues.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 class CreateIssues < ActiveRecord::Migration
2 3 def change
3 4 create_table :issues do |t|
1  db/migrate/20120427064910_create_users.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 class CreateUsers < ActiveRecord::Migration
2 3 def change
3 4 create_table :users do |t|
1  db/migrate/20120427065047_add_creator_to_project.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 class AddCreatorToProject < ActiveRecord::Migration
2 3 def change
3 4 add_column :projects, :creator_id, :integer
1  db/migrate/20120427065225_add_responsable_to_issues.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 class AddResponsableToIssues < ActiveRecord::Migration
2 3 def change
3 4 add_column :issues, :responsable_id, :integer
1  db/migrate/20120427124402_add_creator_to_issues.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 class AddCreatorToIssues < ActiveRecord::Migration
2 3 def change
3 4 add_column :issues, :creator_id, :integer
1  db/migrate/20120427131211_add_responsable_to_project.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 class AddResponsableToProject < ActiveRecord::Migration
2 3 def change
3 4 add_column :projects, :responsable_id, :integer
11 db/migrate/20120502070424_add_personal_data_to_user.rb
... ... @@ -0,0 +1,11 @@
  1 +# -*- encoding : utf-8 -*-
  2 +class AddPersonalDataToUser < ActiveRecord::Migration
  3 + def change
  4 + add_column :users, :name, :string
  5 + add_column :users, :surname1, :string
  6 + add_column :users, :surname2, :string
  7 + add_column :users, :born_on, :date
  8 + add_column :users, :twitter, :string
  9 + add_column :users, :github, :string
  10 + end
  11 +end
10 db/schema.rb
... ... @@ -1,4 +1,4 @@
1   -# encoding: UTF-8
  1 +# -*- encoding : utf-8 -*-
2 2 # This file is auto-generated from the current state of the database. Instead
3 3 # of editing this file, please use the migrations feature of Active Record to
4 4 # incrementally modify your database, and then regenerate this schema definition.
@@ -11,7 +11,7 @@
11 11 #
12 12 # It's strongly recommended to check this file into your version control system.
13 13
14   -ActiveRecord::Schema.define(:version => 20120427131211) do
  14 +ActiveRecord::Schema.define(:version => 20120502070424) do
15 15
16 16 create_table "issues", :force => true do |t|
17 17 t.string "title"
@@ -43,6 +43,12 @@
43 43 t.datetime "remember_me_token_expires_at"
44 44 t.datetime "created_at", :null => false
45 45 t.datetime "updated_at", :null => false
  46 + t.string "name"
  47 + t.string "surname1"
  48 + t.string "surname2"
  49 + t.date "born_on"
  50 + t.string "twitter"
  51 + t.string "github"
46 52 end
47 53
48 54 add_index "users", ["remember_me_token"], :name => "index_users_on_remember_me_token"
1  db/seeds.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 # This file should contain all the record creation needed to seed the database with its default values.
2 3 # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3 4 #
3  spec/factories.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 FactoryGirl.define do
2 3
3 4 #
@@ -30,4 +31,4 @@
30 31 status 'unstarted'
31 32 end
32 33
33   -end
  34 +end
56 spec/helpers/application_helper_spec.rb
... ... @@ -0,0 +1,56 @@
  1 +# -*- encoding : utf-8 -*-
  2 +describe ApplicationHelper do
  3 +
  4 + describe '#link_to' do
  5 + it 'accepts an :icon option that outputs an icon class attribute' do
  6 + link_to('Nowhere', '/route', icon: 'user').should have_tag('a i.icon-user')
  7 + end
  8 + end
  9 +
  10 + describe '#default_text_for_bootstrap_alert' do
  11 + it "should have default texts for notice and success alerts" do
  12 + helper.default_text_for_bootstrap_alert(:success).should == '<strong>Listo!</strong> Se han actualizado los datos'
  13 + helper.default_text_for_bootstrap_alert('error').should == '<strong>Oh oh!</strong> Parece que hay algún dato erróneo'
  14 + helper.default_text_for_bootstrap_alert(:other_thing).should be_nil
  15 + end
  16 + end
  17 +
  18 + describe '#bootstrap_alert' do
  19 + let(:alert) { helper.bootstrap_alert(received_text, :success) }
  20 + context 'when it dont receives any text' do
  21 + let(:received_text) { nil }
  22 + it 'should render a boostrap-styled alerts, fetching for a default text for that kind of alert' do
  23 + alert.should have_tag('.alert.alert-success') { with_tag('button.close') }
  24 + alert.should =~ /Se han actualizado los datos/
  25 + end
  26 + end
  27 + context 'when it receives a text' do
  28 + let(:received_text) { 'Alert de prueba' }
  29 + it 'should render a boostrap-styled alerts with that text' do
  30 + alert.should have_tag('.alert.alert-success') { with_tag('button.close') }
  31 + alert.should =~ /Alert de prueba/
  32 + end
  33 + end
  34 + end
  35 +
  36 + describe '#bootstrap_flashes' do
  37 + let(:flashes){ helper.bootstrap_flashes }
  38 + it "should display an alert for each kind of flash entry" do
  39 + flash[:notice] = "Flash notice"
  40 + flash[:success] = "Flash success"
  41 + flash[:error] = "Flash explaining error"
  42 + flashes.should have_tag('.alert.alert-info', text: 'Flash notice')
  43 + flashes.should have_tag('.alert.alert-success', text: 'Flash success')
  44 + flashes.should have_tag('.alert.alert-error', text: 'Flash explaining error')
  45 + end
  46 + end
  47 +
  48 + describe '#flash_class' do
  49 + it "should return the proper bootstrap class for the alert" do
  50 + helper.flash_class(:notice).should == 'alert-info'
  51 + helper.flash_class(:alert).should == 'alert-warning'
  52 + helper.flash_class('error').should == 'alert-error'
  53 + end
  54 + end
  55 +
  56 +end
3  spec/models/issue_spec.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 describe Issue do
2 3
3 4 it_behaves_like "an object with responsable"
@@ -96,4 +97,4 @@
96 97 subject.should_not be_opened
97 98 end
98 99
99   -end
  100 +end
3  spec/models/project_spec.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 describe Project do
2 3 let(:saved_project){ Project.create }
3 4
@@ -25,4 +26,4 @@
25 26 saved_project.highest_code.should == '5'
26 27 end
27 28
28   -end
  29 +end
1  spec/models/user_spec.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 describe User do
2 3
3 4 #
1  spec/spec_helper.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 require 'rubygems'
2 3 require 'spork'
3 4 #uncomment the following line to use spork with the debugger
1  spec/support/models/custom_matchers.rb
... ... @@ -0,0 +1 @@
  1 +# -*- encoding : utf-8 -*-
3  spec/support/models/with_creator_shared_examples.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 shared_examples_for "an object with creator" do
2 3 #
3 4 # Relations
@@ -19,4 +20,4 @@
19 20 subject.should be_created_by user
20 21 end
21 22
22   -end
  23 +end
3  spec/support/models/with_responsable_shared_examples.rb
... ... @@ -1,3 +1,4 @@
  1 +# -*- encoding : utf-8 -*-
1 2 shared_examples_for "an object with responsable" do
2 3 #
3 4 # Relations
@@ -13,4 +14,4 @@
13 14 subject.should be_assigned_to user
14 15 end
15 16
16   -end
  17 +end

0 comments on commit 2831e0c

Please sign in to comment.
Something went wrong with that request. Please try again.