Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: elomar/microblog
base: c12f572dae
...
head fork: elomar/microblog
compare: 0500cc13f1
  • 12 commits
  • 12 files changed
  • 0 commit comments
  • 1 contributor
View
3  app/assets/javascripts/usuarios.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/
View
3  app/assets/stylesheets/usuarios.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the Usuarios controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
View
4 app/controllers/usuarios_controller.rb
@@ -0,0 +1,4 @@
+class UsuariosController < ApplicationController
+ def new
+ end
+end
View
2  app/helpers/usuarios_helper.rb
@@ -0,0 +1,2 @@
+module UsuariosHelper
+end
View
8 app/models/usuario.rb
@@ -0,0 +1,8 @@
+class Usuario < ActiveRecord::Base
+ attr_accessible :nome, :email
+
+ validates :nome, presence: true, length: { maximum: 50 }
+
+ VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
+ validates :email, presence: true, format: VALID_EMAIL_REGEX, uniqueness: { case_sensitive: false }
+end
View
2  app/views/paginas/index.html.erb
@@ -3,4 +3,4 @@
<h1>MicroBlog</h1>
<p>Está é uma aplicação exemplo pro módulo de Rails.</p>
-<%= link_to "Crie sua conta!", '#', class: "signup_button round" %>
+<%= link_to "Crie sua conta!", signup_path, class: "signup_button round" %>
View
3  app/views/usuarios/new.html.erb
@@ -0,0 +1,3 @@
+<% provide(:title, "Cadastre-se") %>
+<h1>Cadastre-se</h1>
+<p>Find me in app/views/usuarios/new.html.erb</p>
View
4 config/routes.rb
@@ -1,6 +1,10 @@
Microblog::Application.routes.draw do
+ get "usuarios/new"
+
root to: "paginas#index"
+ match "/signup", to: "usuarios#new"
+
match "/ajuda", to: "paginas#ajuda"
match "/sobre", to: "paginas#sobre"
View
10 db/migrate/20120309215824_create_usuarios.rb
@@ -0,0 +1,10 @@
+class CreateUsuarios < ActiveRecord::Migration
+ def change
+ create_table :usuarios do |t|
+ t.string :nome
+ t.string :email
+
+ t.timestamps
+ end
+ end
+end
View
23 db/schema.rb
@@ -0,0 +1,23 @@
+# 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 => 20120309215824) do
+
+ create_table "usuarios", :force => true do |t|
+ t.string "nome"
+ t.string "email"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+end
View
65 spec/models/usuario_spec.rb
@@ -0,0 +1,65 @@
+# encoding: utf-8
+
+require 'spec_helper'
+
+describe Usuario do
+ before { @usuario = Usuario.new(nome: "Exemplo Usuario", email: "usuario@exemplo.com") }
+
+ subject { @usuario }
+
+ it { should respond_to(:nome) }
+ it { should respond_to(:email) }
+
+ it { should be_valid }
+
+ describe "quando nome está em branco" do
+ before { @usuario.nome = " " }
+ it { should_not be_valid }
+ end
+
+ describe "quando email está em branco" do
+ before { @usuario.email = " " }
+ it { should_not be_valid }
+ end
+
+ describe "quando nome é grande demais" do
+ before { @usuario.nome = "a" * 51 }
+ it { should_not be_valid }
+ end
+
+ describe "quando email é inválido" do
+ emails_invalidos = %w[usuario@foo,com usuario_at_foo.org example.usuario@foo.]
+ emails_invalidos.each do |email_invalido|
+ before { @usuario.email = email_invalido }
+ it { should_not be_valid }
+ end
+ end
+
+ describe "quando email é válido" do
+ emails_validos = %w[usuario@foo.com A_usuario@f.b.org frst.lst@foo.jp a+b@baz.cn]
+ emails_validos.each do |email_valido|
+ before { @usuario.email = email_valido }
+ it { should be_valid }
+ end
+ end
+
+ describe "quando email já está em uso" do
+ before do
+ usuario_mesmo_email = @usuario.dup
+ usuario_mesmo_email.save
+ end
+
+ it { should_not be_valid }
+ end
+
+ describe "quando email já está em uso em maiúsculas" do
+ before do
+ usuario_mesmo_email = @usuario.dup
+ usuario_mesmo_email.email = @usuario.email.upcase
+ usuario_mesmo_email.save
+ end
+
+ it { should_not be_valid }
+ end
+
+end
View
14 spec/requests/usuarios_spec.rb
@@ -0,0 +1,14 @@
+# encoding: utf-8
+
+require 'spec_helper'
+
+describe "Usuarios" do
+ subject { page }
+
+ describe "página de signup" do
+ before { visit signup_path }
+
+ it { should have_selector('h1', text: 'Cadastre-se') }
+ it { should have_selector('title', text: 'MicroBlog IT | Cadastre-se') }
+ end
+end

No commit comments for this range

Something went wrong with that request. Please try again.