Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
547
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.16 KB | None | 0 0
  1. Started GET "/signup" for 33.33.33.1 at 2017-05-09 16:54:38 +0000
  2. Cannot render console from 33.33.33.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
  3. ActiveRecord::SchemaMigration Load (1.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
  4. Processing by ChefsController#new as HTML
  5. Rendering chefs/new.html.erb within layouts/application
  6. Rendered shared/_page_title.html.erb (0.9ms)
  7. Rendered shared/_errors.html.erb (1.6ms)
  8. Rendered chefs/new.html.erb within layouts/application (61.2ms)
  9. Rendered layouts/_navigation.html.erb (1.7ms)
  10. Rendered layouts/_messages.html.erb (2.0ms)
  11. Rendered layouts/_footer.html.erb (1.0ms)
  12. Completed 200 OK in 2750ms (Views: 2688.6ms | ActiveRecord: 10.1ms)
  13. Started POST "/chefs" for 33.33.33.1 at 2017-05-09 16:55:31 +0000
  14. Cannot render console from 33.33.33.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
  15. Processing by ChefsController#create as HTML
  16. Parameters: {"utf8"=>"✓", "authenticity_token"=>"IyvuDTHgojOl5TbzhbFUIdoKuPAgT8bNRZbNUXMSu1vW0O6Adv9m11lvUNyiyxZ66TGPHS5QIc4sv1k+D73z4g==", "chef"=>{"chefname"=>"Rosey", "email"=>"rosey@email.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Create my account"}
  17. No template found for ChefsController#create, rendering head :no_content
  18. Completed 204 No Content in 119ms (ActiveRecord: 0.0ms)
  19.  
  20. Started GET "/signup" for 33.33.33.1 at 2017-05-09 16:47:26 +0000
  21. Cannot render console from 33.33.33.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
  22. ActiveRecord::SchemaMigration Load (1.0ms) SELECT "schema_migrations".* FROM "schema_migrations"
  23. Processing by ChefsController#new as HTML
  24. Rendering chefs/new.html.erb within layouts/application
  25. Rendered shared/_page_title.html.erb (0.6ms)
  26. Rendered shared/_errors.html.erb (1.4ms)
  27. Rendered chefs/new.html.erb within layouts/application (55.2ms)
  28. Rendered layouts/_navigation.html.erb (2.0ms)
  29. Rendered layouts/_messages.html.erb (1.6ms)
  30. Rendered layouts/_footer.html.erb (1.3ms)
  31. Completed 200 OK in 2715ms (Views: 2658.1ms | ActiveRecord: 10.2ms)
  32. Started POST "/chefs" for 33.33.33.1 at 2017-05-09 16:47:44 +0000
  33. Cannot render console from 33.33.33.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
  34. Processing by ChefsController#create as HTML
  35. Parameters: {"utf8"=>"✓", "authenticity_token"=>"iemTuDyzszxzGbyGIJebE4PVcNyqPByufC4UPfH4dc98EpM1e6x32I+T2qkH7dlIsO5HMaQj+60VB4BSjVc9dg==", "chef"=>{"chefname"=>"hilma", "email"=>"", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Create my account"}
  36. No template found for ChefsController#create, rendering head :no_content
  37. Completed 204 No Content in 123ms (ActiveRecord: 0.0ms)
  38.  
  39. $ rails test
  40.  
  41. Running via Spring preloader in process 3082
  42. Run options: --seed 41146
  43. # Running:
  44. ........................F
  45. Failure:
  46. ChefsSignupTest#test_accept_valid_signup [/vagrant/ketokitchen/test/integration/chefs_signup_test.rb:22]:
  47. "Chef.count" didn't change by 1.
  48. Expected: 1
  49. Actual: 0
  50. bin/rails test test/integration/chefs_signup_test.rb:20
  51. F
  52. Failure:
  53. ChefsSignupTest#test_reject_an_invalid_signup [/vagrant/ketokitchen/test/integration/chefs_signup_test.rb:15]:
  54. expecting <"chefs/new"> but rendering with <[]>
  55. bin/rails test test/integration/chefs_signup_test.rb:9
  56. 30 runs, 73 assertions, 2 failures, 0 errors, 0 skips
  57.  
  58. > @chef = Chef.new
  59. => #<Chef id: nil, chefname: nil, email: nil, created_at: nil, updated_at: nil, password_digest: nil>
  60. > @chef = Chef.new(chefname: "test", email: "test@example.com", password: "secretpswd", password_confirmation: "secretpswd")
  61. => #<Chef id: nil, chefname: "test", email: "test@example.com", created_at: nil, updated_at: nil, password_digest: "$2a$10$oyThgQldfqvhIlLvDhMRLOoCQZXW81qneuXjzDKYxTH...">
  62. > @chef
  63. => #<Chef id: nil, chefname: "test", email: "test@example.com", created_at: nil, updated_at: nil, password_digest: "$2a$10$oyThgQldfqvhIlLvDhMRLOoCQZXW81qneuXjzDKYxTH...">
  64. > @chef.save
  65. (0.8ms) BEGIN
  66. Chef Exists (6.0ms) SELECT 1 AS one FROM "chefs" WHERE LOWER("chefs"."email") = LOWER($1) LIMIT $2 [["email", "test@example.com"], ["LIMIT", 1]]
  67. SQL (4.8ms) INSERT INTO "chefs" ("chefname", "email", "created_at", "updated_at", "password_digest") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["chefname", "test"], ["email", "test@example.com"], ["created_at", 2017-05-09 17:05:58 UTC], ["updated_at", 2017-05-09 17:05:58 UTC], ["password_digest", "$2a$10$oyThgQldfqvhIlLvDhMRLOoCQZXW81qneuXjzDKYxTHNMUj5kVPAm"]]
  68. (1.4ms) COMMIT
  69. => true
  70. > @chef.chefname
  71. => "test"
  72.  
  73. > Chef.all
  74. Chef Load (4.2ms) SELECT "chefs".* FROM "chefs"
  75. => #<ActiveRecord::Relation [#<Chef id: 1, chefname: "Dean", email: "deananes@gmail.com",
  76. created_at: "2017-04-15 18:59:09", updated_at: "2017-05-01 22:59:14", password_digest: nil>,
  77. #<Chef id: 2, chefname: "jen diamond", email: "thejendiamond@gmail.com",
  78. created_at: "2017-04-29 03:57:22", updated_at: "2017-05-05 18:57:25",
  79. password_digest: "$2a$10$YVJthUQoAU2kD.O3zECHMu/74BmOPzmjRSPupJJXe.n...">,
  80. #<Chef id: 3, chefname: "Toby", email: "toby@email.com", created_at: "2017-05-08 23:10:55",
  81. updated_at: "2017-05-08 23:10:55",
  82. password_digest: "$2a$10$4FEv0WCKHpmWGD4Iwxh5mOrRSRNULA2bZlRsvDUDsSs...">,
  83. #<Chef id: 4, chefname: "test", email: "test@example.com", created_at: "2017-05-09 17:05:58",
  84. updated_at: "2017-05-09 17:05:58",
  85. password_digest: "$2a$10$oyThgQldfqvhIlLvDhMRLOoCQZXW81qneuXjzDKYxTH...">]>
  86.  
  87. > @chef = Chef.find(1)
  88. Chef Load (0.7ms) SELECT "chefs".* FROM "chefs" WHERE "chefs"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
  89. => #<Chef id: 1, chefname: "Dean", email: "deananes@gmail.com",
  90. created_at: "2017-04-15 18:59:09", updated_at: "2017-05-01 22:59:14",
  91. password_digest: nil> > @chef
  92. > @chef.destroy
  93. (1.0ms) BEGIN
  94. SQL (0.7ms) DELETE FROM "chefs" WHERE "chefs"."id" = $1 [["id", 1]]
  95. (0.8ms) COMMIT
  96. => #<Chef id: 1, chefname: "Dean", email: "deananes@gmail.com", created_at: "2017-04-15 18:59:09", updated_at: "2017-05-01 22:59:14", password_digest: nil>
  97. > Chef.all
  98. Chef Load (1.0ms) SELECT "chefs".* FROM "chefs"
  99. => #<ActiveRecord::Relation [
  100. #<Chef id: 2, chefname: "jen diamond",
  101. email: "thejendiamond@gmail.com", created_at: "2017-04-29 03:57:22",
  102. updated_at: "2017-05-05 18:57:25",
  103. password_digest: "$2a$10$YVJthUQoAU2kD.O3zECHMu/74BmOPzmjRSPupJJXe.n...">,
  104. #<Chef id: 3, chefname: "Toby", email: "toby@email.com",
  105. created_at: "2017-05-08 23:10:55", updated_at: "2017-05-08 23:10:55",
  106. password_digest: "$2a$10$4FEv0WCKHpmWGD4Iwxh5mOrRSRNULA2bZlRsvDUDsSs...">,
  107. #<Chef id: 4, chefname: "test", email: "test@example.com",
  108. created_at: "2017-05-09 17:05:58", updated_at: "2017-05-09 17:05:58",
  109. password_digest: "$2a$10$oyThgQldfqvhIlLvDhMRLOoCQZXW81qneuXjzDKYxTH...">]>
  110.  
  111. Rails.application.routes.draw do
  112. root 'pages#home'
  113. get 'pages/home', to: 'pages#home'
  114. resources :recipes
  115. get '/signup', to: 'chefs#new'
  116. resources :chefs, except: [:new]
  117. end
  118.  
  119. class Chef < ApplicationRecord
  120. has_many :recipes
  121. validates :chefname, presence: true, length: { maximum: 30 }
  122. VALID_EMAIL_REGEX = /A([w+-].?)+@[a-zd-]+(.[a-z]+)*.[a-z]+z/i
  123. validates :email, presence: true, length: { maximum: 50 }, uniqueness: {case_sensitive: false},
  124. format: { with: VALID_EMAIL_REGEX}
  125. validates :password, presence: true, length: { minimum: 8 }
  126. has_secure_password
  127. end
  128.  
  129. class ChefsController < ApplicationController
  130. def index
  131. @chefs = Chef.all
  132. end
  133. def new
  134. @chef = Chef.new
  135. end
  136. def create
  137. @chef = Chef.new(chef_params)
  138. if @chef.save
  139. flash[:success] = "Welcome #{@chef.chefname} to MyRecipes App!"
  140. redirect_to chef_path(@chef)
  141. else
  142. render 'new'
  143. end
  144. end
  145. def show
  146. @chef = Chef.find(params[:id])
  147. end
  148. private
  149. def chef_params
  150. params.require(:chef).permit(:chefname, :email,
  151. :password, :password_confirmation)
  152. end
  153. end
  154.  
  155. <%= render 'shared/page_title', title: 'Sign up' %>
  156. <%= render 'shared/errors', obj: @chef %>
  157. <div class="row">
  158. <div class="col-md-12">
  159. <%= form_for(@chef, :html => {class: "form-horizontal", role: "form"}) do |f| %>
  160. <div class="form-group">
  161. <div class="control-label col-md-2">
  162. <%= f.label :chefname, "Choose Chefname" %>
  163. </div>
  164. <div class="col-md-8">
  165. <%= f.text_field :chefname, class: "form-control",
  166. placeholder: "Enter your name", autofocus: true %>
  167. </div>
  168. </div>
  169. <div class="form-group">
  170. <div class="control-label col-md-2">
  171. <%= f.label :email %>
  172. </div>
  173. <div class="col-md-8">
  174. <%= f.email_field :email, class: "form-control",
  175. placeholder: "Enter your email" %>
  176. </div>
  177. </div>
  178. <div class="form-group">
  179. <div class="control-label col-md-2">
  180. <%= f.label :password %>
  181. </div>
  182. <div class="col-md-8">
  183. <%= f.password_field :password, class: "form-control",
  184. placeholder: "Choose a password" %>
  185. </div>
  186. </div>
  187. <div class="form-group">
  188. <div class="control-label col-md-2">
  189. <%= f.label :password_confirmation, "Confirm Password" %>
  190. </div>
  191. <div class="col-md-8">
  192. <%= f.password_field :password_confirmation, class: "form-control",
  193. placeholder: "Confirm password" %>
  194. </div>
  195. </div>
  196. <div class="form-group">
  197. <div class="col-md-offset-2 col-md-10">
  198. <%= f.submit "Create my account", class: "btn btn-primary btn-lg btn-xlarge" %>
  199. </div>
  200. </div>
  201. <% end %>
  202. <div class="col-md-4 col-md-offset-4 colormatch">
  203. [ <%= link_to "Cancel request and return to recipes listing", recipes_path %> ]
  204. </div>
  205. </div>
  206. </div>
  207.  
  208. <p><%= @chef.chefname %></p>
  209.  
  210. require 'test_helper'
  211. class ChefsSignupTest < ActionDispatch::IntegrationTest
  212. test 'should get the signup path' do
  213. get signup_path
  214. assert_response :success
  215. end
  216. test 'reject an invalid signup' do
  217. get signup_path
  218. assert_no_difference "Chef.count" do
  219. post chefs_path, params: { chef: { chefname: " ", email: " ",
  220. password: "password", password_confirmation: " " } }
  221. end
  222. assert_template 'chefs/new'
  223. assert_select 'h2.panel-title'
  224. assert_select 'div.panel-body'
  225. end
  226. test 'accept valid signup' do
  227. get signup_path
  228. assert_difference 'Chef.count', 1 do
  229. post chefs_path, params: {chef: {chefname: 'Jen', email: 'thejendiamond@gmail.com',
  230. password: 'secretpswd', password_confirmation: 'secretpswd'}}
  231. end
  232. follow_redirect!
  233. assert_template 'chefs/show'
  234. assert_not flash.empty?
  235. end
  236. end
  237.  
  238. ActiveRecord::Schema.define(version: 20170505183354) do
  239. # These are extensions that must be enabled in order to support this database
  240. enable_extension "plpgsql"
  241. create_table "chefs", force: :cascade do |t|
  242. t.string "chefname"
  243. t.string "email"
  244. t.datetime "created_at", null: false
  245. t.datetime "updated_at", null: false
  246. t.string "password_digest"
  247. end
  248. create_table "recipes", force: :cascade do |t|
  249. t.string "name"
  250. t.text "description"
  251. t.datetime "created_at", null: false
  252. t.datetime "updated_at", null: false
  253. t.integer "chef_id"
  254. end
  255. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement