Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #14842, #14752, #14751 - fix tests #173

Merged
merged 2 commits into from Apr 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/remote_execution_feature.rb
@@ -1,7 +1,7 @@
class RemoteExecutionFeature < ActiveRecord::Base
attr_accessible :label, :name, :provided_input_names, :description, :job_template_id

validate :label, :name, :presence => true, :unique => true
validates :label, :name, :presence => true, :uniqueness => true

belongs_to :job_template

Expand Down
4 changes: 2 additions & 2 deletions db/migrate/20150612121541_add_job_template_to_template.rb
@@ -1,6 +1,6 @@
class AddJobTemplateToTemplate < ActiveRecord::Migration
def change
add_column :templates, :job_name, :string
add_column :templates, :provider_type, :string
add_column :templates, :job_name, :string, :limit => 255
add_column :templates, :provider_type, :string, :limit => 255
end
end
12 changes: 6 additions & 6 deletions db/migrate/20150616080015_create_template_input.rb
@@ -1,13 +1,13 @@
class CreateTemplateInput < ActiveRecord::Migration
def change
create_table :template_inputs do |t|
t.string :name, :null => false
t.string :name, :null => false, :limit => 255
t.boolean :required, :null => false, :default => false
t.string :input_type, :null => false
t.string :fact_name
t.string :variable_name
t.string :puppet_class_name
t.string :puppet_parameter_name
t.string :input_type, :null => false, :limit => 255
t.string :fact_name, :limit => 255
t.string :variable_name, :limit => 255
t.string :puppet_class_name, :limit => 255
t.string :puppet_parameter_name, :limit => 255
t.text :description
t.integer :template_id

Expand Down
4 changes: 2 additions & 2 deletions db/migrate/20150708133241_add_targeting.rb
@@ -1,10 +1,10 @@
class AddTargeting < ActiveRecord::Migration
def change
create_table :targetings do |t|
t.string :search_query
t.string :search_query, :limit => 255
t.references :bookmark
t.references :user
t.string :targeting_type, :null => false
t.string :targeting_type, :null => false, :limit => 255
t.timestamps
end

Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20150708133242_add_invocation.rb
Expand Up @@ -2,7 +2,7 @@ class AddInvocation< ActiveRecord::Migration
def change
create_table :job_invocations do |t|
t.references :targeting, :null => false
t.string :job_name, :null => false
t.string :job_name, :null => false, :limit => 255
end

add_index :job_invocations, [:targeting_id], :name => 'job_invocations_targeting_id'
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20150708133305_add_template_invocation.rb
Expand Up @@ -12,7 +12,7 @@ def change
create_table :template_invocation_input_values do |t|
t.references :template_invocation, :null => false
t.references :template_input, :null => false
t.string :value, :null => false
t.string :value, :null => false, :limit => 255
end

add_index :template_invocation_input_values, [:template_invocation_id, :template_input_id], :name => 'template_invocation_input_values_ti_ti_ids'
Expand Down
@@ -1,6 +1,6 @@
class AddLastTaskIdToJobInvocation < ActiveRecord::Migration
def change
add_column :job_invocations, :last_task_id, :string
add_column :job_invocations, :last_task_id, :string, :limit => 255
add_index :job_invocations, [:last_task_id], :name => 'job_invocations_last_task_id'
end
end
Expand Up @@ -3,7 +3,7 @@ def change
create_table :target_remote_execution_proxies do |t|
t.integer :remote_execution_proxy_id
t.integer :target_id
t.string :target_type
t.string :target_type, :limit => 255

t.timestamps
end
Expand Down
@@ -1,5 +1,5 @@
class AddEffectiveUserToTemplateInvocation < ActiveRecord::Migration
def change
add_column :template_invocations, :effective_user, :string
add_column :template_invocations, :effective_user, :string, :limit => 255
end
end
Expand Up @@ -2,7 +2,7 @@ class CreateJobTemplateEffectiveUsers < ActiveRecord::Migration
def change
create_table :job_template_effective_users do |t|
t.integer :job_template_id
t.string :value
t.string :value, :limit => 255
t.boolean :overridable
t.boolean :current_user
end
Expand Down
@@ -1,7 +1,7 @@
class AddDescriptionToJobInvocation < ActiveRecord::Migration
def up
add_column :job_invocations, :description, :string
add_column :templates, :description_format, :string
add_column :job_invocations, :description, :string, :limit => 255
add_column :templates, :description_format, :string, :limit => 255
end

def down
Expand Down
@@ -1,9 +1,9 @@
class MakeJobNameDefaultToSomething < ActiveRecord::Migration
def up
change_column :templates, :job_name, :string, :default => 'Miscellaneous'
change_column :templates, :job_name, :string, :default => 'Miscellaneous', :limit => 255
end

def down
change_column :templates, :job_name, :string, :default => nil
change_column :templates, :job_name, :string, :default => nil, :limit => 255
end
end
@@ -1,6 +1,6 @@
class AddRunHostJobTaskIdToTemplateInvocation < ActiveRecord::Migration
def change
add_column :template_invocations, :run_host_job_task_id, :string
add_column :template_invocations, :run_host_job_task_id, :string, :limit => 255
add_index :template_invocations, [:run_host_job_task_id], :name => 'template_invocations_run_host_job_task_id'
end
end
10 changes: 4 additions & 6 deletions db/migrate/20160118124600_create_remote_execution_features.rb
@@ -1,14 +1,12 @@
class CreateRemoteExecutionFeatures < ActiveRecord::Migration
def change
create_table :remote_execution_features do |t|
t.string :label, :index => true, :null => false
t.string :name, :null => false
t.string :description
t.string :label, :index => true, :null => false, :limit => 255
t.string :name, :null => false, :limit => 255
t.string :description, :limit => 255
t.text :provided_inputs
t.integer :job_template_id
t.integer :job_template_id, :index => true
end
add_index :remote_execution_features, :label
add_index :remote_execution_features, :job_template_id
add_foreign_key :remote_execution_features, :templates, :column => :job_template_id
end
end
9 changes: 2 additions & 7 deletions lib/tasks/foreman_remote_execution_tasks.rake
Expand Up @@ -36,14 +36,9 @@ namespace :foreman_remote_execution do
end
end

Rake::Task[:test].enhance do
Rake::Task['test:foreman_remote_execution'].invoke
end
Rake::Task[:test].enhance ['test:foreman_remote_execution']

load 'tasks/jenkins.rake'
if Rake::Task.task_defined?(:'jenkins:unit')
Rake::Task['jenkins:unit'].enhance do
Rake::Task['test:foreman_remote_execution'].invoke
Rake::Task['foreman_remote_execution:rubocop'].invoke
end
Rake::Task['jenkins:unit'].enhance ['test:foreman_remote_execution', 'foreman_remote_execution:rubocop']
end
3 changes: 2 additions & 1 deletion test/factories/foreman_remote_execution_factories.rb
Expand Up @@ -66,6 +66,7 @@
factory :smart_proxy do
trait :ssh do
features { [FactoryGirl.build(:feature, :ssh)] }
pubkey 'ssh-rsa AAAAB3N...'
end
end

Expand All @@ -88,7 +89,7 @@
overrides[:organizations] = [organization] unless organization.nil?

FactoryGirl.create(
:subnet,
:subnet_ipv4,
overrides
)
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_plugin_helper.rb
@@ -1,6 +1,6 @@
# This calls the main test_helper in Foreman-core
require 'test_helper'

require 'database_cleaner'
require 'dynflow/testing'

# Add plugin to FactoryGirl's paths
Expand Down
6 changes: 3 additions & 3 deletions test/unit/execution_task_status_mapper_test.rb
Expand Up @@ -3,7 +3,7 @@
describe HostStatus::ExecutionStatus::ExecutionTaskStatusMapper do

describe '.sql_conditions_for(status)' do
subject { HostStatus::ExecutionStatus::ExecutionTaskStatusMapper }
let(:subject) { HostStatus::ExecutionStatus::ExecutionTaskStatusMapper }

it 'accepts status number as well as string representation' do
subject.sql_conditions_for(HostStatus::ExecutionStatus::ERROR).must_equal subject.sql_conditions_for('failed')
Expand All @@ -18,7 +18,7 @@
let(:mapper) { HostStatus::ExecutionStatus::ExecutionTaskStatusMapper.new(task) }

describe '#status' do
subject { mapper }
let(:subject) { mapper }

describe 'is queued' do
context 'when there is no task' do
Expand Down Expand Up @@ -65,7 +65,7 @@
end

describe '#status_label' do
subject { mapper.status_label }
let(:subject) { mapper.status_label }

context 'status is OK' do
before do
Expand Down