]> cat aescling's git repositories - mastodon.git/commitdiff
Fixing more configuration issues with ActionCable
authorEugen Rochko <eugen@zeonfederated.com>
Thu, 18 Aug 2016 16:39:35 +0000 (18:39 +0200)
committerEugen Rochko <eugen@zeonfederated.com>
Thu, 18 Aug 2016 16:39:35 +0000 (18:39 +0200)
app/controllers/application_controller.rb
config/environments/production.rb
config/initializers/ostatus.rb
spec/controllers/api/salmon_controller_spec.rb

index 91f76d311b7f08aee713245c383058a3529c3ff5..c190abdf2bbe6ecbeb3e5ed7ba000cc61bbd4b3f 100644 (file)
@@ -3,11 +3,11 @@ class ApplicationController < ActionController::Base
   # For APIs, you may want to use :null_session instead.
   protect_from_forgery with: :exception
 
-  force_ssl if: "ENV['LOCAL_HTTPS'] == 'true'"
+  force_ssl if: "Rails.env.production? && ENV['LOCAL_HTTPS'] == 'true'"
 
   # Profiling
   before_action do
-    if (current_user && current_user.admin?) || Rails.env == 'development'
+    if (current_user && current_user.admin?) || Rails.env.development?
       Rack::MiniProfiler.authorize_request
     end
   end
index 09b77654f331b4f49f4487eaa8fd31d947d60e4f..e5cb01151fc2eed5214a79850ac63b5d184e17e8 100644 (file)
@@ -80,4 +80,6 @@ Rails.application.configure do
   }
 
   config.action_mailer.delivery_method = :smtp
+
+  config.action_cable.allowed_request_origins = ["http#{config.x.use_https ? 's' : ''}://#{config.x.local_domain}"]
 end
index 056d30f49f6b5782c9f57d41387ae27124093243..3cb17c7181fe9f3a4354ee9a6e4eaed6abaf2645 100644 (file)
@@ -4,6 +4,4 @@ Rails.application.configure do
   config.x.use_https    = ENV['LOCAL_HTTPS'] == 'true'
 
   config.action_mailer.default_url_options = { host: config.x.local_domain, protocol: config.x.use_https ? 'https://' : 'http://' }
-
-  config.action_cable.allowed_request_origins = ["http#{config.x.use_https ? 's' : ''}://#{config.x.local_domain}"]
 end
index 8b356640f9fa685720326d88f90569204c43e9ba..785e1723b133e239d87811fd8cb56e6c58437909 100644 (file)
@@ -1,7 +1,7 @@
 require 'rails_helper'
 
 RSpec.describe Api::SalmonController, type: :controller do
-  let(:account) { Fabricate(:account, username: 'catsrgr8', user: Fabricate(:user)) }
+  let(:account) { Fabricate(:user, account: Fabricate(:account, username: 'catsrgr8')).account }
 
   before do
     stub_request(:get, "https://quitter.no/.well-known/host-meta").to_return(request_fixture('.host-meta.txt'))
@@ -16,6 +16,10 @@ RSpec.describe Api::SalmonController, type: :controller do
       post :update, params: { id: account.id }
     end
 
+    it 'contains XML in the request body' do
+      expect(request.body.read).to be_a String
+    end
+
     it 'returns http success' do
       expect(response).to have_http_status(:success)
     end