-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fixed bug: An error message is shown when entering the LDAP integra…
…tion admin interface for the first time. Refactoring: - Added documentation and tests to ImportJob. - Added documentation and tests to Import::Ldap. - Introduced Import::Base. - Migrated existing Import::Test modules in tests to new class structure.
- Loading branch information
1 parent
9c07cec
commit 057ecce
Showing
11 changed files
with
361 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ | ||
|
||
module Import | ||
class Base | ||
|
||
# Checks if the able to get queued by the scheduler. | ||
# | ||
# @example | ||
# Import::ExampleBackend.queueable? | ||
# #=> true | ||
# | ||
# return [Boolean] | ||
def self.queueable? | ||
true | ||
end | ||
|
||
# Initializes a new instance with a stored reference to the import job. | ||
# | ||
# @example | ||
# instance = Import::ExampleBackend.new(import_job) | ||
# | ||
# return [Import::ExampleBackend] | ||
def initialize(import_job) | ||
@import_job = import_job | ||
end | ||
|
||
# Starts the life or dry run import of the backend. | ||
# | ||
# @example | ||
# instance = Import::ExampleBackend.new(import_job) | ||
# | ||
# @raise [RuntimeError] Raised if the implementation of this mandatory method is missing | ||
# | ||
# return [nil] | ||
def start | ||
raise "Missing implementation if the 'start' method." | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FactoryGirl.define do | ||
factory :import_job do | ||
name 'Import::Test' | ||
payload {} | ||
dry_run false | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require 'rails_helper' | ||
require 'lib/import/import_job_backend_examples' | ||
|
||
RSpec.describe Import::Base do | ||
it_behaves_like 'ImportJob backend' | ||
|
||
describe '#queueable?' do | ||
|
||
it 'returns true by default' do | ||
expect(described_class.queueable?).to be true | ||
end | ||
end | ||
|
||
describe '.start' do | ||
|
||
it 'raises an error if called and not overwritten' do | ||
|
||
import_job = create(:import_job) | ||
instance = described_class.new(import_job) | ||
|
||
expect do | ||
instance.start | ||
end.to raise_error(RuntimeError) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
RSpec.shared_examples 'ImportJob backend' do | ||
|
||
it 'responds to #queueable?' do | ||
expect(described_class).to respond_to(:queueable?) | ||
end | ||
|
||
it 'requires an import job instance as parameter' do | ||
|
||
expect do | ||
described_class.new | ||
end.to raise_error(ArgumentError) | ||
|
||
import_job = create(:import_job) | ||
expect do | ||
described_class.new(import_job) | ||
end.not_to raise_error | ||
end | ||
|
||
it 'responds to .start' do | ||
import_job = create(:import_job) | ||
expect(described_class.new(import_job)).to respond_to(:start) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'rails_helper' | ||
require 'lib/import/import_job_backend_examples' | ||
|
||
RSpec.describe Import::Ldap do | ||
it_behaves_like 'ImportJob backend' | ||
|
||
describe '#queueable?' do | ||
|
||
it 'is queueable if ldap integration is activated' do | ||
expect(Setting).to receive(:get).with('ldap_integration').and_return(true) | ||
expect(described_class.queueable?).to be true | ||
end | ||
|
||
it "isn't queueable if ldap integration is deactivated" do | ||
expect(Setting).to receive(:get).with('ldap_integration').and_return(false) | ||
expect(described_class.queueable?).to be false | ||
end | ||
end | ||
|
||
describe '.start' do | ||
|
||
it 'starts LDAP import resource factories' do | ||
|
||
import_job = create(:import_job) | ||
instance = described_class.new(import_job) | ||
|
||
expect(Setting).to receive(:get).with('ldap_integration').and_return(true) | ||
expect(Import::Ldap::UserFactory).to receive(:import) | ||
|
||
instance.start | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.