padrinobook / job-vacancy Goto Github PK
View Code? Open in Web Editor NEWA sample app written in Padrino for displaying job offers
A sample app written in Padrino for displaying job offers
it "should redirect if user is correct" do
user.confirmation = true
User.should_receive(:find_by_email).and_return(user)
post "sessions/create", user.attributes
last_response.should be_redirect
end
is in the book but not in the application ...
Read through http://betterspecs.org and make the specs better.
The controller:
JobVacancy::App.controllers :users do
before :edit, :update do
redirect('/login') unless signed_in?
@user = User.find_by_id(params[:id])
redirect('/login') unless current_user?(@user)
end
get :edit, :map => '/users/:id/edit' do
@user = User.find_by_id(params[:id])
render 'users/edit'
end
put :update, :map => '/users/:id' do
@user = User.find_by_id(params[:id])
unless @user
flash[:error] = "User is not registered in our platform."
render 'users/edit'
end
if @user.update_attributes(params[:user])
flash[:notice] = "You have updated your profile."
render 'users/edit'
else
flash[:error] = "Your profile was not updated."
render 'users/edit'
end
end
end
The spec
require 'spec_helper'
describe "UsersController" do
describe "GET edit" do
let(:user) { build(:user) }
it "render the view for editing a user" do
User.should_receive(:find_by_id).at_least(:once).with(anything()).and_return(user)
get "/users/#{user.id}/edit"
# I come to this point but the last response is not okay but and routing error, as you can see in the output next to this code example
require 'pry'; binding.pry
last_response.should be_ok
end
end
end
The output of the last_response
is:
#<Rack::MockResponse:0xbad94ad0
@block=nil,
@body=
["<!DOCTYPE html>\n<html>\n<head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n <title>Padr
@body_string=nil,
@chunked=false,
@errors=
"Padrino::Routing::UnrecognizedException - route mapping for url(:\"users edit\") could not be found!:\n\t/home/wikimatze/.g
@header=
{"Content-Type"=>"text/html",
"Content-Length"=>"233416",
"Set-Cookie"=>
"rack.session=BAh7CUkiD3Nlc3Npb25faWQGOgZFVEkiRTQyOTAyNDQ0MGU4MmM3MDgxZWZk%0AZjRjZGQwODFjMWFmOTEwMGFkMWVhZjI5OTk2NjM2MTE5M
@length=233416,
@original_headers=
{"Content-Type"=>"text/html",
"Content-Length"=>"233416",
I even turned of the the csrf protection in config/apps.rb
Padrino.configure_apps do
# enable :sessions
# set :session_secret, '6a3ec199b53b002a3bfaf60ec746b9182c095950b41f182790a81a0e36d96884'
# set :protection, true
# set :protect_from_csrf, true
end
It is working if I run the application.
It doesn't make sense ...
Try to replace them with whisper
https://github.com/krisleech/wisper (other examples can be found here http://stackoverflow.com/questions/15165260/rails-observer-alternatives-for-4-0).
I am created one user in database but not able to login. please help
Try it out: https://github.com/email-spec/email-spec
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.