Coder Social home page Coder Social logo

job-vacancy's Introduction

PadrinoBook - The Guide To Master The Elegant Ruby Web Framework

This book describes how I developed an application in Padrino. Feel free to fork this project and to correct my grammar. You can find the official page of the book under padrinobook.

Current version

You can find the current preview version under softcover.io.

Repository of the Job Vacancy Application

In this book I'm developing the job vacancy application. You can checkout the sources if you want to see the final result from this book.

Contribute/Contact

Feature requests, bugs, questions, etc. can be sent to [email protected]. You can even fork this project, and create pull requests as you like. I will then add you to the contributor list.

If you like my work, you can let me know how much money you would spend for this book. And don't worry, this book will be free at anytime.

License

This software is licensed under the MIT license.

© Matthias Günther [email protected].

job-vacancy's People

Contributors

bitdeli-chef avatar matzfan avatar wikimatze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

job-vacancy's Issues

missing test users_controller_spec.rb

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 ...

Problems testing edit action for user_controller

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.