Skip to content

Instantly share code, notes, and snippets.

View stabenfeldt's full-sized avatar
🎯
Focusing

Martin Stabenfeldt stabenfeldt

🎯
Focusing
View GitHub Profile
- content_for :breadcrumb do
= link_to 'Mine prosjekter', projects_path
| >
= @department.title
table
thead
th
th Kunde
class ExcelController < ApplicationController
layout :resolve_layout
def dagsrapport
project = Project.find(params[:project_id])
profession = Profession.find(params[:profession_id])
overtime = params[:overtime]
file_name = Dagsrapport.new(project: project, profession: profession,
overtime: overtime).create_spreadsheet
respond_to do |format|
module V1
class Base < API
puts "in Base"
version 'v1', using: :path, vendor: 'orwapp', cascade: false
mount Users
end
end
class API < Grape::API
prefix 'api'
format :json
default_format :json
mount ::V1::Base
end
require 'spec_helper'
describe V1::Users do
describe 'GET /api/v1/users' do
it 'returns array of users' do
3.times { Fabricate :user }
get '/api/v1/users', {}, https_and_authorization
response.status.should eq 200
expected_ids = User.all.page(1).map { |a| a.id.to_s }
expected_ids.each { |id| response.body.should match id }
module V1
class Users < Base
resource :users do
desc 'Lookup of single user'
get 'martin' do
'hello'
end
module V1
module Entities
class Users < Grape::Entity
expose :id, :first_name, :last_name
end
end
end
module V1
module Entities
class Tasks < Grape::Entity
expose :id, :description, :project_id, :project_url
end
def project_url
'http://db.no'
end
end
module V1
module Entities
class Tasks < Grape::Entity
#expose :id, :description, :project_id
#expose :project_url
expose :attr_not_on_wrapped_object
end
def attr_not_on_wrapped_object
42
require 'spec_helper'
describe V1::Users do
describe 'GET /api/v1/users/:id' do
it 'lists a specific user' do
user = Fabricate :user
user.should be_valid
get "/api/v1/users/#{ user.id }"
response.status.should == 200