mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-15 19:31:26 +00:00
Fix specs and deprecation warnings
This commit is contained in:
parent
ee485990f5
commit
201b784562
10 changed files with 47 additions and 44 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -28,3 +28,4 @@ manifest.yml
|
||||||
config/unicorn.rb
|
config/unicorn.rb
|
||||||
db/schema.rb
|
db/schema.rb
|
||||||
.local/
|
.local/
|
||||||
|
spec/examples.txt
|
||||||
|
|
6
Gemfile
6
Gemfile
|
@ -152,7 +152,7 @@ group :development do
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem 'coveralls', '~> 0.8.12', require: false
|
gem 'coveralls', '~> 0.8.12', require: false
|
||||||
gem 'capybara', '~> 2.13.0'
|
gem 'capybara', '~> 2.18'
|
||||||
gem 'capybara-screenshot'
|
gem 'capybara-screenshot'
|
||||||
gem 'capybara-select2', require: false
|
gem 'capybara-select2', require: false
|
||||||
gem 'delorean'
|
gem 'delorean'
|
||||||
|
@ -160,9 +160,9 @@ group :development do
|
||||||
gem 'pry-rails'
|
gem 'pry-rails'
|
||||||
gem 'pry-byebug'
|
gem 'pry-byebug'
|
||||||
gem 'rr'
|
gem 'rr'
|
||||||
gem 'rspec', '~> 3.5'
|
gem 'rspec', '~> 3.7'
|
||||||
gem 'rspec-collection_matchers', '~> 1.1.0'
|
gem 'rspec-collection_matchers', '~> 1.1.0'
|
||||||
gem 'rspec-rails', '~> 3.5.2'
|
gem 'rspec-rails', '~> 3.7'
|
||||||
gem 'rspec-html-matchers', '~> 0.8'
|
gem 'rspec-html-matchers', '~> 0.8'
|
||||||
gem 'rails-controller-testing'
|
gem 'rails-controller-testing'
|
||||||
gem 'shoulda-matchers'
|
gem 'shoulda-matchers'
|
||||||
|
|
54
Gemfile.lock
54
Gemfile.lock
|
@ -136,8 +136,8 @@ GEM
|
||||||
i18n (>= 0.7, < 2)
|
i18n (>= 0.7, < 2)
|
||||||
minitest (~> 5.1)
|
minitest (~> 5.1)
|
||||||
tzinfo (~> 1.1)
|
tzinfo (~> 1.1)
|
||||||
addressable (2.5.1)
|
addressable (2.5.2)
|
||||||
public_suffix (~> 2.0, >= 2.0.2)
|
public_suffix (>= 2.0.2, < 4.0)
|
||||||
arel (9.0.0)
|
arel (9.0.0)
|
||||||
aws-sdk-core (2.2.15)
|
aws-sdk-core (2.2.15)
|
||||||
jmespath (~> 1.0)
|
jmespath (~> 1.0)
|
||||||
|
@ -163,13 +163,13 @@ GEM
|
||||||
capistrano-rails (1.1.3)
|
capistrano-rails (1.1.3)
|
||||||
capistrano (~> 3.1)
|
capistrano (~> 3.1)
|
||||||
capistrano-bundler (~> 1.1)
|
capistrano-bundler (~> 1.1)
|
||||||
capybara (2.13.0)
|
capybara (2.18.0)
|
||||||
addressable
|
addressable
|
||||||
mime-types (>= 1.16)
|
mini_mime (>= 0.1.3)
|
||||||
nokogiri (>= 1.3.3)
|
nokogiri (>= 1.3.3)
|
||||||
rack (>= 1.0.0)
|
rack (>= 1.0.0)
|
||||||
rack-test (>= 0.5.4)
|
rack-test (>= 0.5.4)
|
||||||
xpath (~> 2.0)
|
xpath (>= 2.0, < 4.0)
|
||||||
capybara-screenshot (1.0.17)
|
capybara-screenshot (1.0.17)
|
||||||
capybara (>= 1.0, < 3)
|
capybara (>= 1.0, < 3)
|
||||||
launchy
|
launchy
|
||||||
|
@ -466,7 +466,7 @@ GEM
|
||||||
pry (~> 0.10)
|
pry (~> 0.10)
|
||||||
pry-rails (0.3.4)
|
pry-rails (0.3.4)
|
||||||
pry (>= 0.9.10)
|
pry (>= 0.9.10)
|
||||||
public_suffix (2.0.5)
|
public_suffix (3.0.2)
|
||||||
rack (2.0.4)
|
rack (2.0.4)
|
||||||
rack-livereload (0.3.16)
|
rack-livereload (0.3.16)
|
||||||
rack
|
rack
|
||||||
|
@ -521,32 +521,32 @@ GEM
|
||||||
netrc (~> 0.8)
|
netrc (~> 0.8)
|
||||||
retriable (3.0.2)
|
retriable (3.0.2)
|
||||||
rr (1.1.2)
|
rr (1.1.2)
|
||||||
rspec (3.5.0)
|
rspec (3.7.0)
|
||||||
rspec-core (~> 3.5.0)
|
rspec-core (~> 3.7.0)
|
||||||
rspec-expectations (~> 3.5.0)
|
rspec-expectations (~> 3.7.0)
|
||||||
rspec-mocks (~> 3.5.0)
|
rspec-mocks (~> 3.7.0)
|
||||||
rspec-collection_matchers (1.1.2)
|
rspec-collection_matchers (1.1.2)
|
||||||
rspec-expectations (>= 2.99.0.beta1)
|
rspec-expectations (>= 2.99.0.beta1)
|
||||||
rspec-core (3.5.4)
|
rspec-core (3.7.1)
|
||||||
rspec-support (~> 3.5.0)
|
rspec-support (~> 3.7.0)
|
||||||
rspec-expectations (3.5.0)
|
rspec-expectations (3.7.0)
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.5.0)
|
rspec-support (~> 3.7.0)
|
||||||
rspec-html-matchers (0.9.1)
|
rspec-html-matchers (0.9.1)
|
||||||
nokogiri (~> 1)
|
nokogiri (~> 1)
|
||||||
rspec (>= 3.0.0.a, < 4)
|
rspec (>= 3.0.0.a, < 4)
|
||||||
rspec-mocks (3.5.0)
|
rspec-mocks (3.7.0)
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.5.0)
|
rspec-support (~> 3.7.0)
|
||||||
rspec-rails (3.5.2)
|
rspec-rails (3.7.2)
|
||||||
actionpack (>= 3.0)
|
actionpack (>= 3.0)
|
||||||
activesupport (>= 3.0)
|
activesupport (>= 3.0)
|
||||||
railties (>= 3.0)
|
railties (>= 3.0)
|
||||||
rspec-core (~> 3.5.0)
|
rspec-core (~> 3.7.0)
|
||||||
rspec-expectations (~> 3.5.0)
|
rspec-expectations (~> 3.7.0)
|
||||||
rspec-mocks (~> 3.5.0)
|
rspec-mocks (~> 3.7.0)
|
||||||
rspec-support (~> 3.5.0)
|
rspec-support (~> 3.7.0)
|
||||||
rspec-support (3.5.0)
|
rspec-support (3.7.1)
|
||||||
rturk (2.12.1)
|
rturk (2.12.1)
|
||||||
erector
|
erector
|
||||||
nokogiri
|
nokogiri
|
||||||
|
@ -653,8 +653,8 @@ GEM
|
||||||
httparty (> 0.6.0)
|
httparty (> 0.6.0)
|
||||||
json (> 1.4.0)
|
json (> 1.4.0)
|
||||||
xmpp4r (0.5.6)
|
xmpp4r (0.5.6)
|
||||||
xpath (2.0.0)
|
xpath (3.0.0)
|
||||||
nokogiri (~> 1.3)
|
nokogiri (~> 1.8)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
|
@ -669,7 +669,7 @@ DEPENDENCIES
|
||||||
capistrano (~> 3.4.0)
|
capistrano (~> 3.4.0)
|
||||||
capistrano-bundler (~> 1.1.4)
|
capistrano-bundler (~> 1.1.4)
|
||||||
capistrano-rails (~> 1.1)
|
capistrano-rails (~> 1.1)
|
||||||
capybara (~> 2.13.0)
|
capybara (~> 2.18)
|
||||||
capybara-screenshot
|
capybara-screenshot
|
||||||
capybara-select2
|
capybara-select2
|
||||||
coffee-rails (~> 4.2)
|
coffee-rails (~> 4.2)
|
||||||
|
@ -737,10 +737,10 @@ DEPENDENCIES
|
||||||
rails-html-sanitizer (~> 1.0.4)
|
rails-html-sanitizer (~> 1.0.4)
|
||||||
rb-kqueue (>= 0.2)
|
rb-kqueue (>= 0.2)
|
||||||
rr
|
rr
|
||||||
rspec (~> 3.5)
|
rspec (~> 3.7)
|
||||||
rspec-collection_matchers (~> 1.1.0)
|
rspec-collection_matchers (~> 1.1.0)
|
||||||
rspec-html-matchers (~> 0.8)
|
rspec-html-matchers (~> 0.8)
|
||||||
rspec-rails (~> 3.5.2)
|
rspec-rails (~> 3.7)
|
||||||
rturk (~> 2.12.1)
|
rturk (~> 2.12.1)
|
||||||
ruby-growl (~> 4.1.0)
|
ruby-growl (~> 4.1.0)
|
||||||
rufus-scheduler (~> 3.4.2)
|
rufus-scheduler (~> 3.4.2)
|
||||||
|
|
|
@ -2,7 +2,7 @@ class JobsController < ApplicationController
|
||||||
before_action :authenticate_admin!
|
before_action :authenticate_admin!
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@jobs = Delayed::Job.order("coalesce(failed_at,'1000-01-01'), run_at asc").page(params[:page])
|
@jobs = Delayed::Job.order(Arel.sql("coalesce(failed_at,'1000-01-01'), run_at asc")).page(params[:page])
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render layout: !request.xhr? }
|
format.html { render layout: !request.xhr? }
|
||||||
|
|
|
@ -8,7 +8,7 @@ class WorkerStatusController < ApplicationController
|
||||||
events = events.where('id > ?', since_id)
|
events = events.where('id > ?', since_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
result = events.select('COUNT(id) AS count', 'MIN(id) AS min_id', 'MAX(id) AS max_id').reorder('min(created_at)').first
|
result = events.select('COUNT(id) AS count', 'MIN(id) AS min_id', 'MAX(id) AS max_id').reorder(Arel.sql('min(created_at)')).first
|
||||||
count, min_id, max_id = result.count, result.min_id, result.max_id
|
count, min_id, max_id = result.count, result.min_id, result.max_id
|
||||||
|
|
||||||
case max_id
|
case max_id
|
||||||
|
|
|
@ -104,13 +104,13 @@ module AgentHelper
|
||||||
agent_ids = agents.map(&:id)
|
agent_ids = agents.map(&:id)
|
||||||
cache[:links_as_receiver] = Hash[Link.where(receiver_id: agent_ids)
|
cache[:links_as_receiver] = Hash[Link.where(receiver_id: agent_ids)
|
||||||
.group(:receiver_id)
|
.group(:receiver_id)
|
||||||
.pluck('receiver_id', 'count(receiver_id) as id')]
|
.pluck(:receiver_id, Arel.sql('count(receiver_id) as id'))]
|
||||||
cache[:links_as_source] = Hash[Link.where(source_id: agent_ids)
|
cache[:links_as_source] = Hash[Link.where(source_id: agent_ids)
|
||||||
.group(:source_id)
|
.group(:source_id)
|
||||||
.pluck('source_id', 'count(source_id) as id')]
|
.pluck(:source_id, Arel.sql('count(source_id) as id'))]
|
||||||
cache[:control_links_as_controller] = Hash[ControlLink.where(controller_id: agent_ids)
|
cache[:control_links_as_controller] = Hash[ControlLink.where(controller_id: agent_ids)
|
||||||
.group(:controller_id)
|
.group(:controller_id)
|
||||||
.pluck('controller_id', 'count(controller_id) as id')]
|
.pluck(:controller_id, Arel.sql('count(controller_id) as id'))]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -258,7 +258,7 @@ describe AgentsController do
|
||||||
post :update, params: {:id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name")}, :format => :json
|
post :update, params: {:id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name")}, :format => :json
|
||||||
expect(agents(:bob_website_agent).reload.name).to eq("New name")
|
expect(agents(:bob_website_agent).reload.name).to eq("New name")
|
||||||
expect(JSON.parse(response.body)['name']).to eq("New name")
|
expect(JSON.parse(response.body)['name']).to eq("New name")
|
||||||
expect(response).to be_success
|
expect(response).to be_successful
|
||||||
end
|
end
|
||||||
|
|
||||||
it "will not accept Agent sources owned by other users" do
|
it "will not accept Agent sources owned by other users" do
|
||||||
|
|
|
@ -29,7 +29,7 @@ describe WebRequestsController do
|
||||||
post :handle_request, params: {:user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "my_secret", :key => "value", :another_key => "5"}
|
post :handle_request, params: {:user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "my_secret", :key => "value", :another_key => "5"}
|
||||||
expect(@agent.reload.last_web_request_at).to be_within(2).of(Time.now)
|
expect(@agent.reload.last_web_request_at).to be_within(2).of(Time.now)
|
||||||
expect(response.body).to eq("success")
|
expect(response.body).to eq("success")
|
||||||
expect(response).to be_success
|
expect(response).to be_successful
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should call receive_web_request" do
|
it "should call receive_web_request" do
|
||||||
|
@ -40,12 +40,12 @@ describe WebRequestsController do
|
||||||
expect(@agent.memory[:web_request_method]).to eq("post")
|
expect(@agent.memory[:web_request_method]).to eq("post")
|
||||||
expect(response.body).to eq("success")
|
expect(response.body).to eq("success")
|
||||||
expect(response.headers['Content-Type']).to eq('text/plain; charset=utf-8')
|
expect(response.headers['Content-Type']).to eq('text/plain; charset=utf-8')
|
||||||
expect(response).to be_success
|
expect(response).to be_successful
|
||||||
|
|
||||||
post :handle_request, params: {:user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "not_my_secret", :no => "go"}
|
post :handle_request, params: {:user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "not_my_secret", :no => "go"}
|
||||||
expect(@agent.reload.memory[:web_request_values]).not_to eq({ 'no' => "go" })
|
expect(@agent.reload.memory[:web_request_values]).not_to eq({ 'no' => "go" })
|
||||||
expect(response.body).to eq("failure")
|
expect(response.body).to eq("failure")
|
||||||
expect(response).to be_missing
|
expect(response.status).to eq(404)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should accept gets" do
|
it "should accept gets" do
|
||||||
|
@ -55,7 +55,7 @@ describe WebRequestsController do
|
||||||
expect(@agent.memory[:web_request_format]).to eq("text/html")
|
expect(@agent.memory[:web_request_format]).to eq("text/html")
|
||||||
expect(@agent.memory[:web_request_method]).to eq("get")
|
expect(@agent.memory[:web_request_method]).to eq("get")
|
||||||
expect(response.body).to eq("success")
|
expect(response.body).to eq("success")
|
||||||
expect(response).to be_success
|
expect(response).to be_successful
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should pass through the received format" do
|
it "should pass through the received format" do
|
||||||
|
@ -109,12 +109,12 @@ describe WebRequestsController do
|
||||||
|
|
||||||
it "should fail on incorrect users" do
|
it "should fail on incorrect users" do
|
||||||
post :handle_request, params: {:user_id => users(:jane).to_param, :agent_id => @agent.id, :secret => "my_secret", :no => "go"}
|
post :handle_request, params: {:user_id => users(:jane).to_param, :agent_id => @agent.id, :secret => "my_secret", :no => "go"}
|
||||||
expect(response).to be_missing
|
expect(response.status).to eq(404)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should fail on incorrect agents" do
|
it "should fail on incorrect agents" do
|
||||||
post :handle_request, params: {:user_id => users(:bob).to_param, :agent_id => 454545, :secret => "my_secret", :no => "go"}
|
post :handle_request, params: {:user_id => users(:bob).to_param, :agent_id => 454545, :secret => "my_secret", :no => "go"}
|
||||||
expect(response).to be_missing
|
expect(response.status).to eq(404)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "legacy update_location endpoint" do
|
describe "legacy update_location endpoint" do
|
||||||
|
@ -141,7 +141,7 @@ describe WebRequestsController do
|
||||||
|
|
||||||
it "should raise a 404 error when given an invalid user id" do
|
it "should raise a 404 error when given an invalid user id" do
|
||||||
post :update_location, params: {user_id: "123", secret: "not_my_secret", longitude: 123, latitude: 45, something: "else"}
|
post :update_location, params: {user_id: "123", secret: "not_my_secret", longitude: 123, latitude: 45, something: "else"}
|
||||||
expect(response).to be_missing
|
expect(response.status).to eq(404)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should only look at agents with the given secret" do
|
it "should only look at agents with the given secret" do
|
||||||
|
|
|
@ -215,7 +215,7 @@ describe Agents::ImapFolderAgent do
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(Event.last.payload).to eq(expected_payloads.last.update(
|
expect(Event.last.payload).to eq(expected_payloads.last.update(
|
||||||
'body' => "<div dir=\"ltr\">Some HTML reply<br></div>\n",
|
'body' => "<div dir=\"ltr\">Some HTML reply<br></div>\r\n",
|
||||||
'matches' => { 'a' => 'some subject', 'b' => 'HTML' },
|
'matches' => { 'a' => 'some subject', 'b' => 'HTML' },
|
||||||
'mime_type' => 'text/html',
|
'mime_type' => 'text/html',
|
||||||
))
|
))
|
||||||
|
|
|
@ -66,6 +66,8 @@ RSpec.configure do |config|
|
||||||
|
|
||||||
config.render_views
|
config.render_views
|
||||||
|
|
||||||
|
config.example_status_persistence_file_path = "./spec/examples.txt"
|
||||||
|
|
||||||
config.include Devise::Test::ControllerHelpers, type: :controller
|
config.include Devise::Test::ControllerHelpers, type: :controller
|
||||||
config.include SpecHelpers
|
config.include SpecHelpers
|
||||||
config.include Delorean
|
config.include Delorean
|
||||||
|
|
Loading…
Add table
Reference in a new issue