This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class TestController < ApplicationController | |
| before_action :authenticate_user! | |
| def custom | |
| render text: 'response' | |
| end | |
| end | |
| describe TestController do | |
| describe "authenticate_user!" do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "github.com/go-martini/martini" | |
| "github.com/martini-contrib/render" | |
| "runtime" | |
| ) | |
| type myClassic struct { | |
| *martini.Martini |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jruby-1.7.12 | |
| puma -e production -t 100:100 <framework>.ru | |
| wrk -t4 -c100 -d2s http://0.0.0.0:9292/ | |
| Ruby | |
| Rack: 17800.91 | |
| Hobbit: 15742.50 | |
| Cuba: 14828.45 | |
| JRuby + Rack + Torqbox ~ 60k req/s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| myApp.controller "AccountController", AccountController = ($scope, $cookies, $log, $location, authenticationService, toaster, userService) -> | |
| $scope.login = (userData, loginForm) -> | |
| if loginForm.$valid | |
| authenticationService.login(userData, $scope.antiForgeryToken).success((response) -> | |
| if response.status | |
| userService.user.username = response.data.userName | |
| userService.user.isLogged = response.data.isLogged | |
| toaster.pop "success", "You are signed in!", "", 2000, true | |
| $location.path "/MembersPage" | |
| else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module JsonApiHelpers | |
| def json_response | |
| @json_response ||= JSON.parse(response.body) | |
| end | |
| end | |
| RSpec.configure do |config| | |
| config.include JsonApiHelpers, type: :controller | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AuthService | |
| def self.authorize(auth_data) | |
| provider = Provider.find_or_create_by(name: auth_data['name'], uid: auth_data['uid']) | |
| if provider.user.present? | |
| provider.user | |
| else | |
| user = User.find_or_create_with_oauth(auth_data['info']) | |
| provider.update(user: user) | |
| user |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ApplicationController | |
| current_user | |
| when current_user already assigned | |
| returns it without calling db | |
| when current_user is nil | |
| and user_id stores in session | |
| finds and returns it from db | |
| and user_id doesn't exists in session | |
| returns nil | |
| signed_in? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Error log | |
| 05:04:08 - INFO - Running: spec/models/identity_spec.rb | |
| 05:04:08 - ERROR - Guard::RSpec failed to achieve its <run_on_modifications>, exception was: | |
| > [#] NoMethodError: undefined method `parse_options' for #<RSpec::Core::ConfigurationOptions:0x007fad670937a8 @args=[]> | |
| > [#] /Users/alder/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/guard-rspec-4.2.2/lib/guard/rspec/command.rb:33:in `_rspec_formatters' | |
| > [#] /Users/alder/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/guard-rspec-4.2.2/lib/guard/rspec/command.rb:29:in `_visual_formatter' | |
| > [#] /Users/alder/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/guard-rspec-4.2.2/lib/guard/rspec/command.rb:21:in `_parts' | |
| > [#] /Users/alder/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/guard-rspec-4.2.2/lib/guard/rspec/command.rb:14:in `initialize' | |
| > [#] /Users/alder/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/guard-rspec-4.2.2/lib/guard/rspec/runner.rb:39:in `new' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module ConvertingTool | |
| extend ActiveSupport::Concern | |
| def self.convert(file_path) | |
| # TODO: make schema file cache | |
| schema_path = Rails.root.join('data', 'schemes', 'FB2_2_html.xsl') | |
| require 'nokogiri' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ➜ dynamo git:(master) MIX_ENV=test mix do deps.get, test | |
| * Getting mimetypes (git://github.com/spawngrid/mimetypes.git) | |
| Cloning into '/Users/alder/Projects/Testing/elixir/dynamo/deps/mimetypes'... | |
| remote: Reusing existing pack: 189, done. | |
| remote: Total 189 (delta 0), reused 0 (delta 0) | |
| Receiving objects: 100% (189/189), 150.75 KiB | 103.00 KiB/s, done. | |
| Resolving deltas: 100% (93/93), done. | |
| Checking connectivity... done. | |
| * Getting cowboy (git://github.com/extend/cowboy.git) | |
| Cloning into '/Users/alder/Projects/Testing/elixir/dynamo/deps/cowboy'... |