mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-15 19:31:26 +00:00
Merge pull request #1877 from dsander/fix-scenario-import
Fix scenario import when merges are required
This commit is contained in:
commit
410ece8682
5 changed files with 58 additions and 5 deletions
|
@ -17,9 +17,9 @@ class ScenarioImportsController < ApplicationController
|
|||
private
|
||||
|
||||
def scenario_import_params
|
||||
merges = params[:scenario_import].delete(:merges)
|
||||
params.require(:scenario_import).permit(:url, :data, :file, :do_import) do |params|
|
||||
merges = params[:scenario_import].delete(:merges).try(:permit!)
|
||||
params.require(:scenario_import).permit(:url, :data, :file, :do_import).tap do |params|
|
||||
params[:merges] = merges
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
35
spec/data_fixtures/twitter_scenario.json
Normal file
35
spec/data_fixtures/twitter_scenario.json
Normal file
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"schema_version": 1,
|
||||
"name": "Twitter",
|
||||
"description": "No description provided",
|
||||
"source_url": false,
|
||||
"guid": "d91bf1508595a65b4a00b74d59857918",
|
||||
"tag_fg_color": "#ffffff",
|
||||
"tag_bg_color": "#5bc0de",
|
||||
"icon": "pencil",
|
||||
"exported_at": "2017-01-17T19:08:31Z",
|
||||
"agents": [
|
||||
{
|
||||
"type": "Agents::TwitterStreamAgent",
|
||||
"name": "Twitter Counts",
|
||||
"disabled": false,
|
||||
"guid": "03c77bb9ec0fb2415f7c399ba849289d",
|
||||
"options": {
|
||||
"filters": [
|
||||
"ruby vulnerability",
|
||||
"rails security",
|
||||
"huginn"
|
||||
],
|
||||
"expected_update_period_in_days": "2",
|
||||
"generate": "counts"
|
||||
},
|
||||
"schedule": "every_10m",
|
||||
"keep_events_for": 604800
|
||||
}
|
||||
],
|
||||
"links": [
|
||||
],
|
||||
"control_links": [
|
||||
|
||||
]
|
||||
}
|
|
@ -43,4 +43,13 @@ describe ScenarioImportsController do
|
|||
click_on 'Finish Import'
|
||||
expect(page).to have_text('Import successful!')
|
||||
end
|
||||
|
||||
it 'imports a scenario which requires a service' do
|
||||
visit new_scenario_imports_path
|
||||
attach_file('Option 2: Upload a Scenario JSON File', File.join(Rails.root, 'spec/data_fixtures/twitter_scenario.json'))
|
||||
click_on 'Start Import'
|
||||
check('I confirm that I want to import these Agents.')
|
||||
expect { click_on 'Finish Import' }.to change(Scenario, :count).by(1)
|
||||
expect(page).to have_text('Import successful!')
|
||||
end
|
||||
end
|
||||
|
|
11
spec/fixtures/services.yml
vendored
11
spec/fixtures/services.yml
vendored
|
@ -14,4 +14,13 @@ global:
|
|||
expires_at: <%= Time.parse("2015-01-01 00:00:00") %>
|
||||
options: <%= { user_id: 12345 }.to_yaml.inspect %>
|
||||
user: jane
|
||||
global: true
|
||||
global: true
|
||||
twitter:
|
||||
token: 1234token
|
||||
secret: 56789secret
|
||||
refresh_token: refresh12345
|
||||
provider: twitter
|
||||
name: test
|
||||
expires_at: <%= Time.parse("2015-01-01 00:00:00") %>
|
||||
options: <%= { user_id: 12345 }.to_yaml.inspect %>
|
||||
user: bob
|
||||
|
|
|
@ -19,7 +19,7 @@ shared_examples_for Oauthable do
|
|||
describe "valid_services_for" do
|
||||
it "should return all available services without specifying valid_oauth_providers" do
|
||||
@agent = Agents::OauthableTestAgent.new
|
||||
expect(@agent.valid_services_for(users(:bob)).collect(&:id).sort).to eq([services(:generic), services(:global)].collect(&:id).sort)
|
||||
expect(@agent.valid_services_for(users(:bob)).collect(&:id).sort).to eq([services(:generic), services(:twitter), services(:global)].collect(&:id).sort)
|
||||
end
|
||||
|
||||
it "should filter the services based on the agent defaults" do
|
||||
|
|
Loading…
Add table
Reference in a new issue