+ <% flash.each do |message_type, message| %>
+ <%= content_tag(:div, message, class: "alert alert-#{message_type}") %>
+
+ <% end %>
<%= yield %>
<%= render 'layouts/footer' %>
+ <%#= debug(params) if Rails.env.development? %>
+ <%= debug(params.to_yaml) if Rails.env.development? %>
+ <%= debug(Time.now) if Rails.env.development? %>
diff --git a/app/views/shared/_error_messages.html.erb b/app/views/shared/_error_messages.html.erb
new file mode 100644
index 0000000..634c203
--- /dev/null
+++ b/app/views/shared/_error_messages.html.erb
@@ -0,0 +1,12 @@
+<% if @user.errors.any? %>
+
+
+ The form contains <%= pluralize(@user.errors.count, "error") %>.
+
+
+ <% @user.errors.full_messages.each do |msg| %>
+
<%= msg %>
+ <% end %>
+
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb
index 9c841e8..94fdcfd 100644
--- a/app/views/users/new.html.erb
+++ b/app/views/users/new.html.erb
@@ -1,3 +1,24 @@
<% provide(:title, 'Sign up') %>
diff --git a/config/routes.rb b/config/routes.rb
index 6f6cf03..c8ac7c6 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,16 +1,19 @@
Rails.application.routes.draw do
- get "users/new"
- get "static_pages/home"
- get "static_pages/help"
- get "static_pages/about"
- get "static_pages/contact"
+ # get "users/new"
+ # get "static_pages/home"
+ # get "static_pages/help"
+ # get "static_pages/about"
+ # get "static_pages/contact"
+
+ root "static_pages#home"
get '/help', to: 'static_pages#help'
get '/about', to: 'static_pages#about'
get '/contact', to: 'static_pages#contact'
get '/signup', to: 'users#new'
- root "static_pages#home"
+ resources :users
+
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
diff --git a/test/integration/users_signup_test.rb b/test/integration/users_signup_test.rb
new file mode 100644
index 0000000..f18a70b
--- /dev/null
+++ b/test/integration/users_signup_test.rb
@@ -0,0 +1,29 @@
+require "test_helper"
+
+class UsersSignupTest < ActionDispatch::IntegrationTest
+ test "invalid signup information" do
+ get signup_path
+ assert_no_difference 'User.count' do
+ post users_path, params: { user: { name: "",
+ email: "user@invalid",
+ password: "foo",
+ password_confirmation: "bar" } }
+ end
+ assert_template 'users/new'
+ assert_select 'div#error_explanation'
+ assert_select 'div.alert-danger'
+ end
+
+ test "valid signup information" do
+ get signup_path
+ assert_difference 'User.count', 1 do
+ post users_path, params: { user: {name: "Example User",
+ email: "user@example.com",
+ password: "password",
+ password_confirmation: "password" } }
+ end
+ follow_redirect!
+ assert_template 'users/show'
+ assert_not flash.notice
+ end
+end