Kaynağa Gözat

Merge branch 'master' into event_does_not_require_url

Andrew Cantino 9 yıl önce
ebeveyn
işleme
55212ed2cf

+ 2 - 1
.gitignore

@@ -25,4 +25,5 @@ deployment/cookbooks
 .ruby-gemset
 .ruby-version
 manifest.yml
-config/unicorn.rb
+config/unicorn.rb
+db/schema.rb

+ 6 - 1
Gemfile

@@ -160,7 +160,12 @@ on_heroku = ENV['ON_HEROKU'] ||
             ENV['HEROKU_POSTGRESQL_GOLD_URL'] ||
             File.read(File.join(File.dirname(__FILE__), 'Procfile')) =~ /intended for Heroku/
 
-ENV['DATABASE_ADAPTER'] ||= 'postgresql' if on_heroku
+ENV['DATABASE_ADAPTER'] ||=
+  if on_heroku
+    'postgresql'
+  else
+    'mysql2'
+  end
 
 if_true(on_heroku) do
   gem 'rails_12factor', group: :production

+ 1 - 1
app/models/agents/data_output_agent.rb

@@ -214,7 +214,7 @@ module Agents
 
           return [<<-XML, 200, 'text/xml']
 <?xml version="1.0" encoding="UTF-8" ?>
-<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/">
+<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
 <channel>
  <atom:link href=#{feed_url(secret: params['secret'], format: :xml).encode(xml: :attr)} rel="self" type="application/rss+xml" />
  <atom:icon>#{feed_icon.encode(xml: :text)}</atom:icon>

+ 0 - 188
db/schema.rb

@@ -1,188 +0,0 @@
-# encoding: UTF-8
-# This file is auto-generated from the current state of the database. Instead
-# of editing this file, please use the migrations feature of Active Record to
-# incrementally modify your database, and then regenerate this schema definition.
-#
-# Note that this schema.rb definition is the authoritative source for your
-# database schema. If you need to create the application database on another
-# system, you should be using db:schema:load, not running all the migrations
-# from scratch. The latter is a flawed and unsustainable approach (the more migrations
-# you'll amass, the slower it'll run and the greater likelihood for issues).
-#
-# It's strongly recommended that you check this file into your version control system.
-
-ActiveRecord::Schema.define(version: 20150808115436) do
-
-  create_table "agent_logs", force: :cascade do |t|
-    t.integer  "agent_id",          limit: 4,                 null: false
-    t.text     "message",           limit: 65535,             null: false, charset: "utf8mb4", collation: "utf8mb4_bin"
-    t.integer  "level",             limit: 4,     default: 3, null: false
-    t.integer  "inbound_event_id",  limit: 4
-    t.integer  "outbound_event_id", limit: 4
-    t.datetime "created_at"
-    t.datetime "updated_at"
-  end
-
-  create_table "agents", force: :cascade do |t|
-    t.integer  "user_id",               limit: 4
-    t.text     "options",               limit: 65535,                                   charset: "utf8mb4", collation: "utf8mb4_bin"
-    t.string   "type",                  limit: 255,                                                         collation: "utf8_bin"
-    t.string   "name",                  limit: 255,                                     charset: "utf8mb4", collation: "utf8mb4_bin"
-    t.string   "schedule",              limit: 255,                                                         collation: "utf8_bin"
-    t.integer  "events_count",          limit: 4,          default: 0,     null: false
-    t.datetime "last_check_at"
-    t.datetime "last_receive_at"
-    t.integer  "last_checked_event_id", limit: 4
-    t.datetime "created_at"
-    t.datetime "updated_at"
-    t.text     "memory",                limit: 4294967295,                              charset: "utf8mb4", collation: "utf8mb4_bin"
-    t.datetime "last_web_request_at"
-    t.integer  "keep_events_for",       limit: 4,          default: 0,     null: false
-    t.datetime "last_event_at"
-    t.datetime "last_error_log_at"
-    t.boolean  "propagate_immediately", limit: 1,          default: false, null: false
-    t.boolean  "disabled",              limit: 1,          default: false, null: false
-    t.string   "guid",                  limit: 255,                        null: false, charset: "ascii",   collation: "ascii_bin"
-    t.integer  "service_id",            limit: 4
-  end
-
-  add_index "agents", ["guid"], name: "index_agents_on_guid", using: :btree
-  add_index "agents", ["schedule"], name: "index_agents_on_schedule", using: :btree
-  add_index "agents", ["type"], name: "index_agents_on_type", using: :btree
-  add_index "agents", ["user_id", "created_at"], name: "index_agents_on_user_id_and_created_at", using: :btree
-
-  create_table "control_links", force: :cascade do |t|
-    t.integer  "controller_id",     limit: 4, null: false
-    t.integer  "control_target_id", limit: 4, null: false
-    t.datetime "created_at"
-    t.datetime "updated_at"
-  end
-
-  add_index "control_links", ["control_target_id"], name: "index_control_links_on_control_target_id", using: :btree
-  add_index "control_links", ["controller_id", "control_target_id"], name: "index_control_links_on_controller_id_and_control_target_id", unique: true, using: :btree
-
-  create_table "delayed_jobs", force: :cascade do |t|
-    t.integer  "priority",   limit: 4,        default: 0
-    t.integer  "attempts",   limit: 4,        default: 0
-    t.text     "handler",    limit: 16777215,             charset: "utf8mb4", collation: "utf8mb4_bin"
-    t.text     "last_error", limit: 65535,                charset: "utf8mb4", collation: "utf8mb4_bin"
-    t.datetime "run_at"
-    t.datetime "locked_at"
-    t.datetime "failed_at"
-    t.string   "locked_by",  limit: 255
-    t.string   "queue",      limit: 255
-    t.datetime "created_at"
-    t.datetime "updated_at"
-  end
-
-  add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree
-
-  create_table "events", force: :cascade do |t|
-    t.integer  "user_id",    limit: 4
-    t.integer  "agent_id",   limit: 4
-    t.decimal  "lat",                         precision: 15, scale: 10
-    t.decimal  "lng",                         precision: 15, scale: 10
-    t.text     "payload",    limit: 16777215,                           charset: "utf8mb4", collation: "utf8mb4_bin"
-    t.datetime "created_at"
-    t.datetime "updated_at"
-    t.datetime "expires_at"
-  end
-
-  add_index "events", ["agent_id", "created_at"], name: "index_events_on_agent_id_and_created_at", using: :btree
-  add_index "events", ["expires_at"], name: "index_events_on_expires_at", using: :btree
-  add_index "events", ["user_id", "created_at"], name: "index_events_on_user_id_and_created_at", using: :btree
-
-  create_table "links", force: :cascade do |t|
-    t.integer  "source_id",            limit: 4
-    t.integer  "receiver_id",          limit: 4
-    t.datetime "created_at"
-    t.datetime "updated_at"
-    t.integer  "event_id_at_creation", limit: 4, default: 0, null: false
-  end
-
-  add_index "links", ["receiver_id", "source_id"], name: "index_links_on_receiver_id_and_source_id", using: :btree
-  add_index "links", ["source_id", "receiver_id"], name: "index_links_on_source_id_and_receiver_id", using: :btree
-
-  create_table "scenario_memberships", force: :cascade do |t|
-    t.integer  "agent_id",    limit: 4, null: false
-    t.integer  "scenario_id", limit: 4, null: false
-    t.datetime "created_at"
-    t.datetime "updated_at"
-  end
-
-  add_index "scenario_memberships", ["agent_id"], name: "index_scenario_memberships_on_agent_id", using: :btree
-  add_index "scenario_memberships", ["scenario_id"], name: "index_scenario_memberships_on_scenario_id", using: :btree
-
-  create_table "scenarios", force: :cascade do |t|
-    t.string   "name",         limit: 255,                   null: false, charset: "utf8mb4", collation: "utf8mb4_bin"
-    t.integer  "user_id",      limit: 4,                     null: false
-    t.datetime "created_at"
-    t.datetime "updated_at"
-    t.text     "description",  limit: 65535,                              charset: "utf8mb4", collation: "utf8mb4_bin"
-    t.boolean  "public",       limit: 1,     default: false, null: false
-    t.string   "guid",         limit: 255,                   null: false, charset: "ascii",   collation: "ascii_bin"
-    t.string   "source_url",   limit: 255
-    t.string   "tag_bg_color", limit: 255
-    t.string   "tag_fg_color", limit: 255
-  end
-
-  add_index "scenarios", ["user_id", "guid"], name: "index_scenarios_on_user_id_and_guid", unique: true, using: :btree
-
-  create_table "services", force: :cascade do |t|
-    t.integer  "user_id",       limit: 4,                     null: false
-    t.string   "provider",      limit: 255,                   null: false, collation: "utf8_general_ci"
-    t.string   "name",          limit: 255,                   null: false, collation: "utf8_general_ci"
-    t.text     "token",         limit: 65535,                 null: false, collation: "utf8_general_ci"
-    t.text     "secret",        limit: 65535,                              collation: "utf8_general_ci"
-    t.text     "refresh_token", limit: 65535,                              collation: "utf8_general_ci"
-    t.datetime "expires_at"
-    t.boolean  "global",        limit: 1,     default: false
-    t.text     "options",       limit: 65535,                              collation: "utf8_general_ci"
-    t.datetime "created_at"
-    t.datetime "updated_at"
-    t.string   "uid",           limit: 255,                                collation: "utf8_general_ci"
-  end
-
-  add_index "services", ["provider"], name: "index_services_on_provider", using: :btree
-  add_index "services", ["uid"], name: "index_services_on_uid", using: :btree
-  add_index "services", ["user_id", "global"], name: "index_services_on_user_id_and_global", using: :btree
-
-  create_table "user_credentials", force: :cascade do |t|
-    t.integer  "user_id",          limit: 4,                      null: false
-    t.string   "credential_name",  limit: 255,                    null: false
-    t.text     "credential_value", limit: 65535,                  null: false
-    t.datetime "created_at"
-    t.datetime "updated_at"
-    t.string   "mode",             limit: 255,   default: "text", null: false, collation: "utf8_bin"
-  end
-
-  add_index "user_credentials", ["user_id", "credential_name"], name: "index_user_credentials_on_user_id_and_credential_name", unique: true, using: :btree
-
-  create_table "users", force: :cascade do |t|
-    t.string   "email",                  limit: 255, default: "",    null: false,                     collation: "utf8_bin"
-    t.string   "encrypted_password",     limit: 255, default: "",    null: false, charset: "ascii",   collation: "ascii_bin"
-    t.string   "reset_password_token",   limit: 255,                                                  collation: "utf8_bin"
-    t.datetime "reset_password_sent_at"
-    t.datetime "remember_created_at"
-    t.integer  "sign_in_count",          limit: 4,   default: 0
-    t.datetime "current_sign_in_at"
-    t.datetime "last_sign_in_at"
-    t.string   "current_sign_in_ip",     limit: 255
-    t.string   "last_sign_in_ip",        limit: 255
-    t.datetime "created_at"
-    t.datetime "updated_at"
-    t.boolean  "admin",                  limit: 1,   default: false, null: false
-    t.integer  "failed_attempts",        limit: 4,   default: 0
-    t.string   "unlock_token",           limit: 255
-    t.datetime "locked_at"
-    t.string   "username",               limit: 191,                 null: false, charset: "utf8mb4", collation: "utf8mb4_unicode_ci"
-    t.string   "invitation_code",        limit: 255,                                                  collation: "utf8_bin"
-    t.integer  "scenario_count",         limit: 4,   default: 0,     null: false
-  end
-
-  add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
-  add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
-  add_index "users", ["unlock_token"], name: "index_users_on_unlock_token", unique: true, using: :btree
-  add_index "users", ["username"], name: "index_users_on_username", unique: true, using: :btree
-
-end

+ 1 - 1
lib/gemfile_helper.rb

@@ -14,7 +14,7 @@ class GemfileHelper
       root = Pathname.new(File.join(File.dirname(__FILE__), '..'))
       sanity_check Dotenv.load(
                                 root.join(".env.local"),
-                                root.join(".env.#{ENV['RAILS_ENV']}"),
+                                root.join(".env.#{ENV['RAILS_ENV'] || 'development'}"),
                                 root.join(".env")
                               )
     end

+ 2 - 2
spec/models/agents/data_output_agent_spec.rb

@@ -153,7 +153,7 @@ describe Agents::DataOutputAgent do
         expect(content_type).to eq('text/xml')
         expect(content.gsub(/\s+/, '')).to eq Utils.unindent(<<-XML).gsub(/\s+/, '')
           <?xml version="1.0" encoding="UTF-8" ?>
-          <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/">
+          <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
           <channel>
            <atom:link href="https://yoursite.com/users/#{agent.user.id}/web_requests/#{agent.id}/secret1.xml" rel="self" type="application/rss+xml"/>
            <atom:icon>https://yoursite.com/favicon.ico</atom:icon>
@@ -392,7 +392,7 @@ describe Agents::DataOutputAgent do
         expect(content_type).to eq('text/xml')
         expect(content.gsub(/\s+/, '')).to eq Utils.unindent(<<-XML).gsub(/\s+/, '')
           <?xml version="1.0" encoding="UTF-8" ?>
-          <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/">
+          <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
           <channel>
            <atom:link href="https://yoursite.com/users/#{agent.user.id}/web_requests/#{agent.id}/secret1.xml" rel="self" type="application/rss+xml"/>
            <atom:icon>https://yoursite.com/favicon.ico</atom:icon>