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
| require 'active_support/concern' | |
| module Processable | |
| extend ActiveSupport::Concern | |
| included do | |
| scope :processed, ->{ where processed: true } | |
| scope :unprocessed, ->{ where processed: false } | |
| 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 Task < ActiveRecord::Base | |
| include Processable | |
| 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
| require 'rails_helper' | |
| RSpec.describe Processable do | |
| before(:all) do | |
| Temping.create :processable_model do | |
| include Processable | |
| with_columns do |t| | |
| t.boolean :processable, default: false | |
| 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
| require 'rails_helper' | |
| RSpec.describe Processable do | |
| # ... | |
| describe '#mark_as_processed!' do | |
| it 'updates the processed column to true' do | |
| subject | |
| .expects(:update_column) | |
| .with(:processed, true) |
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
| if ENV['DISABLE_ASYNC'] | |
| require 'sidekiq/testing' | |
| Sidekiq::Testing.inline! | |
| 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
| version: 8.4.3 (api:1/proto:86-101) | |
| srcversion: F97798065516C94BE0F27DC | |
| 0: cs:Connected ro:Secondary/Secondary ds:UpToDate/UpToDate C r----- | |
| ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0 |
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
| angular.module('controllers', []).controller('SessionsController', ['$scope', '$translate', | |
| ($scope, $translate)-> | |
| $scope.labels = [] | |
| $translate(['models.user.labels.email', 'models.user.labels.password']).then( | |
| (translations)-> | |
| $scope.foo = 'bar' | |
| $scope.labels = translations['models.user.labels.email'] | |
| console.log 'promise resolved' | |
| ) |
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 TranslationsController < ApplicationController | |
| respond_to :json | |
| def show | |
| @locale = params[:id].to_sym | |
| @translations = I18n.with_locale(@locale) do | |
| I18n.backend.send(:translations)[@locale] | |
| 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
| app = angular.module('app', [ | |
| 'pascalprecht.translate' | |
| ]); | |
| app.config(['$translateProvider', function($translateProvider) { | |
| $translateProvider.useStaticFilesLoader({ | |
| prefix: 'translations/', | |
| suffix: '.json' | |
| }); |
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
| Rails.application.routes.draw do | |
| resources :translations, only: :show | |
| end |
OlderNewer