spec/support/rails5/app.rb in influxdb-rails-1.0.0 vs spec/support/rails5/app.rb in influxdb-rails-1.0.1.beta1

- old
+ new

@@ -1,47 +1,69 @@ require "action_controller/railtie" -require "active_record" +require "active_record/railtie" +require "active_job" app = Class.new(Rails::Application) app.config.secret_key_base = "1234567890abcdef1234567890abcdef" app.config.secret_token = "1234567890abcdef1234567890abcdef" app.config.session_store :cookie_store, key: "_myapp_session" app.config.active_support.deprecation = :log app.config.eager_load = false app.config.root = __dir__ Rails.backtrace_cleaner.remove_silencers! +ActiveJob::Base.logger = Rails.logger app.initialize! app.routes.draw do - resources :widgets + resources :metrics, only: %i[index show] + resources :exceptions, only: :index end InfluxDB::Rails.configure do |config| end -ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") +ENV["DATABASE_URL"] = "sqlite3::memory:" ActiveRecord::Schema.define do - create_table :widgets, force: true do |t| - t.string :title + create_table :metrics, force: true do |t| + t.string :name t.timestamps end end -class Widget < ActiveRecord::Base; end +class MetricJob < ActiveJob::Base + queue_as :default + + def perform + # Do something later + end +end + +class Metric < ActiveRecord::Base; end class ApplicationController < ActionController::Base; end -class WidgetsController < ApplicationController +class MetricsController < ApplicationController prepend_view_path File.join(__dir__, "..", "views") before_action do - InfluxDB::Rails.current.values = { key: :value } + InfluxDB::Rails.current.values = { additional_value: :value } + InfluxDB::Rails.current.tags = { additional_tag: :value } end def index - Widget.create!(title: "test") + InfluxDB::Rails.instrument "name", tags: { block_tag: :block_tag }, values: { block_value: :block_value } do + 1 + 1 + end + MetricJob.perform_later + Metric.create!(name: "name") end - def new + def show + @metric = Metric.find_by(name: "name") + end +end + +class ExceptionsController < ApplicationController + def index 1 / 0 end end Object.const_set(:ApplicationHelper, Module.new)