synchronisable 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.rspec +3 -0
- data/.ruby-version +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +9 -0
- data/Guardfile +14 -0
- data/LICENSE.txt +22 -0
- data/README.md +22 -0
- data/Rakefile +7 -0
- data/TODO.md +20 -0
- data/bin/autospec +16 -0
- data/bin/rake +16 -0
- data/bin/rspec +16 -0
- data/lib/generators/synchronizable/USAGE +2 -0
- data/lib/generators/synchronizable/install_generator.rb +24 -0
- data/lib/generators/synchronizable/templates/create_imports_migration.rb +21 -0
- data/lib/generators/synchronizable/templates/initializer.rb +14 -0
- data/lib/synchronizable.rb +92 -0
- data/lib/synchronizable/context.rb +25 -0
- data/lib/synchronizable/dsl/associations.rb +57 -0
- data/lib/synchronizable/dsl/associations/association.rb +59 -0
- data/lib/synchronizable/dsl/associations/has_many.rb +12 -0
- data/lib/synchronizable/dsl/associations/has_one.rb +13 -0
- data/lib/synchronizable/dsl/macro.rb +100 -0
- data/lib/synchronizable/dsl/macro/attribute.rb +41 -0
- data/lib/synchronizable/dsl/macro/expression.rb +51 -0
- data/lib/synchronizable/dsl/macro/method.rb +15 -0
- data/lib/synchronizable/error_handler.rb +50 -0
- data/lib/synchronizable/exceptions.rb +8 -0
- data/lib/synchronizable/locale/en.yml +17 -0
- data/lib/synchronizable/locale/ru.yml +17 -0
- data/lib/synchronizable/model.rb +54 -0
- data/lib/synchronizable/model/methods.rb +55 -0
- data/lib/synchronizable/models/import.rb +24 -0
- data/lib/synchronizable/source.rb +72 -0
- data/lib/synchronizable/synchronizer.rb +177 -0
- data/lib/synchronizable/synchronizers/synchronizer_default.rb +10 -0
- data/lib/synchronizable/version.rb +10 -0
- data/lib/synchronizable/worker.rb +191 -0
- data/spec/dummy/.gitignore +16 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +16 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/gateways/gateway_base.rb +19 -0
- data/spec/dummy/app/gateways/match_gateway.rb +15 -0
- data/spec/dummy/app/gateways/player_gateway.rb +26 -0
- data/spec/dummy/app/gateways/stage_gateway.rb +18 -0
- data/spec/dummy/app/gateways/team_gateway.rb +18 -0
- data/spec/dummy/app/gateways/tournament_gateway.rb +15 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/match.rb +10 -0
- data/spec/dummy/app/models/match_player.rb +15 -0
- data/spec/dummy/app/models/player.rb +5 -0
- data/spec/dummy/app/models/stadium.rb +7 -0
- data/spec/dummy/app/models/stage.rb +6 -0
- data/spec/dummy/app/models/team.rb +5 -0
- data/spec/dummy/app/models/tournament.rb +7 -0
- data/spec/dummy/app/synchronizers/break_convention_team_synchronizer.rb +14 -0
- data/spec/dummy/app/synchronizers/match_synchronizer.rb +71 -0
- data/spec/dummy/app/synchronizers/player_synchronizer.rb +19 -0
- data/spec/dummy/app/synchronizers/stage_synchronizer.rb +20 -0
- data/spec/dummy/app/synchronizers/tournament_synchronizer.rb +20 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +26 -0
- data/spec/dummy/config/boot.rb +6 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +33 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +20 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/synchronizable.rb +2 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +56 -0
- data/spec/dummy/db/migrate/20140422132431_create_teams.rb +11 -0
- data/spec/dummy/db/migrate/20140422132544_create_matches.rb +12 -0
- data/spec/dummy/db/migrate/20140422132708_create_players.rb +15 -0
- data/spec/dummy/db/migrate/20140422133122_create_match_players.rb +12 -0
- data/spec/dummy/db/migrate/20140422135244_create_imports.rb +21 -0
- data/spec/dummy/db/migrate/20140422140817_create_stadiums.rb +10 -0
- data/spec/dummy/db/migrate/20140507135800_create_tournaments.rb +13 -0
- data/spec/dummy/db/migrate/20140507135837_create_stages.rb +13 -0
- data/spec/dummy/db/migrate/20140507140039_add_stage_id_to_matches.rb +6 -0
- data/spec/dummy/db/schema.rb +103 -0
- data/spec/dummy/db/seeds.rb +7 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/lib/tasks/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/robots.txt +5 -0
- data/spec/dummy/vendor/assets/javascripts/.keep +0 -0
- data/spec/dummy/vendor/assets/stylesheets/.keep +0 -0
- data/spec/factories/import.rb +5 -0
- data/spec/factories/match.rb +9 -0
- data/spec/factories/match_player.rb +9 -0
- data/spec/factories/player.rb +10 -0
- data/spec/factories/remote/match.rb +21 -0
- data/spec/factories/remote/player.rb +18 -0
- data/spec/factories/remote/stage.rb +26 -0
- data/spec/factories/remote/team.rb +21 -0
- data/spec/factories/remote/tournament.rb +18 -0
- data/spec/factories/stadium.rb +7 -0
- data/spec/factories/team.rb +16 -0
- data/spec/models/match_spec.rb +41 -0
- data/spec/models/team_spec.rb +85 -0
- data/spec/spec_helper.rb +64 -0
- data/spec/synchronizable/dsl/macro_spec.rb +59 -0
- data/spec/synchronizable/models/import_spec.rb +10 -0
- data/spec/synchronizable/support/has_macro.rb +12 -0
- data/spec/synchronizable/support/has_macro_subclass.rb +9 -0
- data/spec/synchronizable/synchronizable_spec.rb +60 -0
- data/synchronizable.gemspec +39 -0
- metadata +506 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :remote_player, class: Hash do
|
3
|
+
player_id { generate :player_id }
|
4
|
+
team { generate :team_id }
|
5
|
+
|
6
|
+
eman_tsrif { generate :first_name }
|
7
|
+
eman_tsal { generate :last_name }
|
8
|
+
yadhtrib { generate :date }
|
9
|
+
pihsnezitic { generate :string }
|
10
|
+
thgieh { generate :integer }
|
11
|
+
thgiew { generate :integer }
|
12
|
+
|
13
|
+
ignored_1 { generate :string }
|
14
|
+
ignored_2 { generate :integer }
|
15
|
+
|
16
|
+
initialize_with { attributes }
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :remote_stage, class: Hash do
|
3
|
+
stage_id { generate :stage_id }
|
4
|
+
tour_id { generate :tournament_id }
|
5
|
+
|
6
|
+
eman { generate :string }
|
7
|
+
rebmun { generate :integer }
|
8
|
+
gninnigeb { generate :timestamp }
|
9
|
+
gnidge { generate :date }
|
10
|
+
|
11
|
+
ignored_1 { generate :date }
|
12
|
+
ignored_2 { generate :timestamp }
|
13
|
+
|
14
|
+
initialize_with { attributes }
|
15
|
+
|
16
|
+
trait :with_matches do
|
17
|
+
after(:build) do
|
18
|
+
match = build(:remote_match,
|
19
|
+
:home_team => 'team_0',
|
20
|
+
:away_team => 'team_1'
|
21
|
+
)
|
22
|
+
object[:matches_ids] = [match[:match_id]]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :remote_team, class: Hash do
|
3
|
+
maet_id { generate :team_id }
|
4
|
+
|
5
|
+
eman { generate :name }
|
6
|
+
yrtnuoc { generate :string }
|
7
|
+
ytic { generate :string }
|
8
|
+
|
9
|
+
ignored_1 { generate :string }
|
10
|
+
ignored_2 { generate :timestamp }
|
11
|
+
|
12
|
+
initialize_with { attributes }
|
13
|
+
|
14
|
+
trait :with_players do
|
15
|
+
after(:build) do |object, evaluator|
|
16
|
+
players = build_list(:remote_player, 4, team: object[:maet_id])
|
17
|
+
object[:players_ids] = players.map { |h| h[:player_id] }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :remote_tournament, class: Hash do
|
3
|
+
tour_id { generate :tournament_id }
|
4
|
+
eman { generate :string }
|
5
|
+
eman_trohs { generate :string }
|
6
|
+
gninnigeb { generate :date }
|
7
|
+
gnidge { generate :date }
|
8
|
+
|
9
|
+
initialize_with { attributes }
|
10
|
+
|
11
|
+
trait :with_stages do
|
12
|
+
after(:build) do |object, evaluator|
|
13
|
+
stages = build_list(:remote_stage, 2, tour_id: object[:tour_id])
|
14
|
+
object[:stages_ids] = stages.map { |h| h[:stage_id] }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :team do
|
3
|
+
name { generate :string }
|
4
|
+
|
5
|
+
trait :with_stadium do
|
6
|
+
association :stadium
|
7
|
+
end
|
8
|
+
|
9
|
+
trait :with_players do
|
10
|
+
after(:build) do |object, evaluator|
|
11
|
+
create_list(:player, 11, :team => object)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Match do
|
4
|
+
describe 'synchronization' do
|
5
|
+
context 'when has associations defined in Synchronizer' do
|
6
|
+
subject do
|
7
|
+
-> { Match.sync }
|
8
|
+
end
|
9
|
+
|
10
|
+
it { should change { Match.count }.by(1) }
|
11
|
+
it { should change { Team.count }.by(2) }
|
12
|
+
it { should change { Player.count }.by(4) }
|
13
|
+
it { should change { MatchPlayer.count }.by(4) }
|
14
|
+
|
15
|
+
it { should change { Synchronizable::Import.count }.by(11) }
|
16
|
+
end
|
17
|
+
|
18
|
+
# TODO: Left here until :include option is implemented
|
19
|
+
#
|
20
|
+
# context 'when associations specified with :include option' do
|
21
|
+
# subject do
|
22
|
+
# -> { sync_match }
|
23
|
+
# end
|
24
|
+
|
25
|
+
# def sync_match
|
26
|
+
# Match.sync(:include => {
|
27
|
+
# :match => {
|
28
|
+
# :team => :players
|
29
|
+
# }
|
30
|
+
# })
|
31
|
+
# end
|
32
|
+
|
33
|
+
# it { should change { Match.count }.by(1) }
|
34
|
+
# it { should change { Team.count }.by(2) }
|
35
|
+
# it { should change { Player.count }.by(22) }
|
36
|
+
# it { should change { MatchPlayer.count }.by(22) }
|
37
|
+
|
38
|
+
# it { should change { Synchronizable::Import.count }.by(47) }
|
39
|
+
# end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Team do
|
4
|
+
describe 'synchronization' do
|
5
|
+
let!(:remote_attrs) do
|
6
|
+
[
|
7
|
+
{
|
8
|
+
:maet_id => 'team1',
|
9
|
+
:eman => 'y',
|
10
|
+
:yrtnuoc => 'USA',
|
11
|
+
:ytic => 'Washington',
|
12
|
+
:ignored_1 => 'ignored',
|
13
|
+
:ignored_2 => 'ignored'
|
14
|
+
},
|
15
|
+
{
|
16
|
+
:maet_id => 'team2',
|
17
|
+
:eman => 'z',
|
18
|
+
:yrtnuoc => 'France',
|
19
|
+
:ytic => 'Paris',
|
20
|
+
:ignored_2 => 'ignored'
|
21
|
+
},
|
22
|
+
{
|
23
|
+
:eman => 'a',
|
24
|
+
:yrtnuoc => 'blah',
|
25
|
+
:ytic => 'blah'
|
26
|
+
}
|
27
|
+
]
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'sync with no data specified' do
|
31
|
+
subject do
|
32
|
+
-> { Team.sync }
|
33
|
+
end
|
34
|
+
|
35
|
+
it { should change { Team.count }.by(2) }
|
36
|
+
it { should change { Player.count }.by(4) }
|
37
|
+
|
38
|
+
it { should change { Synchronizable::Import.count }.by(6) }
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'when remote id is not specified' do
|
42
|
+
subject { Team.sync([remote_attrs.last]) }
|
43
|
+
|
44
|
+
its(:errors) { should have(1).items }
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'when local record does not exist' do
|
48
|
+
subject do
|
49
|
+
-> { Team.sync(remote_attrs.take(2)) }
|
50
|
+
end
|
51
|
+
|
52
|
+
it { should change { Team.count }.by(2) }
|
53
|
+
it { should change { Synchronizable::Import.count }.by(2) }
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when local and import records exists' do
|
57
|
+
let!(:import) do
|
58
|
+
create(:import,
|
59
|
+
:remote_id => 'team1',
|
60
|
+
:synchronizable => create(:team,
|
61
|
+
:name => 'x',
|
62
|
+
:country => 'Russia',
|
63
|
+
:city => 'Moscow',
|
64
|
+
)
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
68
|
+
let!(:team) { import.synchronizable }
|
69
|
+
|
70
|
+
subject do
|
71
|
+
-> {
|
72
|
+
Team.sync(remote_attrs.take(2))
|
73
|
+
team.reload
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
it { should change { Team.count }.by(1) }
|
78
|
+
it { should change { Synchronizable::Import.count }.by(1) }
|
79
|
+
|
80
|
+
it { should change { team.name }.from('x').to('y') }
|
81
|
+
it { should change { team.country }.from('Russia').to('USA') }
|
82
|
+
it { should change { team.city }.from('Moscow').to('Washington') }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
2
|
+
|
3
|
+
require 'database_cleaner'
|
4
|
+
require 'factory_girl'
|
5
|
+
require 'factory_girl_sequences'
|
6
|
+
require 'spork'
|
7
|
+
require 'simplecov'
|
8
|
+
|
9
|
+
SimpleCov.start
|
10
|
+
|
11
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
12
|
+
|
13
|
+
require 'synchronizable'
|
14
|
+
|
15
|
+
require File.expand_path('../dummy/config/environment', __FILE__)
|
16
|
+
require 'rspec/rails'
|
17
|
+
|
18
|
+
support_pattern = File.join(File.dirname(__FILE__), 'synchronizable', 'support', '**', '*.rb')
|
19
|
+
factories_pattern = File.join(File.dirname(__FILE__), 'factories', '**', '*.rb')
|
20
|
+
|
21
|
+
Dir[factories_pattern].each { |file| require file }
|
22
|
+
Dir[support_pattern].each { |file| require file }
|
23
|
+
|
24
|
+
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
|
25
|
+
|
26
|
+
Spork.prefork do
|
27
|
+
RSpec.configure do |config|
|
28
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
29
|
+
config.run_all_when_everything_filtered = true
|
30
|
+
config.filter_run focus: true
|
31
|
+
config.order = 'random'
|
32
|
+
config.include FactoryGirl::Syntax::Methods
|
33
|
+
|
34
|
+
config.before(:suite) do
|
35
|
+
begin
|
36
|
+
FactoryGirl.lint
|
37
|
+
ensure
|
38
|
+
DatabaseCleaner.clean_with(:truncation)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
config.before(:each) { DatabaseCleaner.strategy = :transaction }
|
43
|
+
|
44
|
+
config.before(:each, js: true) do
|
45
|
+
DatabaseCleaner.strategy = :truncation
|
46
|
+
end
|
47
|
+
|
48
|
+
config.before(:each) { DatabaseCleaner.start }
|
49
|
+
config.after(:each) { DatabaseCleaner.clean }
|
50
|
+
|
51
|
+
if ENV['RUN_SLOW_TESTS'] != 'true'
|
52
|
+
config.filter_run_excluding slow: true
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
FactoryGirl.define do
|
57
|
+
%w(match team player match_player stage tournament).each do |model|
|
58
|
+
sequence(:"#{model}_id") { |n| "#{model}_#{n}" }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
Spork.each_run do
|
64
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Synchronizable::DSL::Macro do
|
4
|
+
describe 'commom attributes' do
|
5
|
+
subject { HasMacro }
|
6
|
+
|
7
|
+
before do
|
8
|
+
subject.xyz 7
|
9
|
+
subject.arr 1, 2, 3
|
10
|
+
end
|
11
|
+
|
12
|
+
it { respond_to? :foo }
|
13
|
+
it { respond_to? :bar }
|
14
|
+
it { respond_to? :baz }
|
15
|
+
it { respond_to? :xxx }
|
16
|
+
it { respond_to? :arr }
|
17
|
+
|
18
|
+
its(:foo) { should be nil }
|
19
|
+
its(:bar) { should eq(1) }
|
20
|
+
its(:baz) { should eq(2) }
|
21
|
+
its(:xyz) { should eq('7') }
|
22
|
+
its(:arr) { should eq([1, 2, 3]) }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'attribute with default value lambda that raises an error' do
|
26
|
+
it 'raises error' do
|
27
|
+
expect { HasMacro.carefull }.to raise_error(NotImplementedError)
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when overriden in subclass not to raise an error' do
|
31
|
+
subject { HasMacroSubclass }
|
32
|
+
|
33
|
+
it { respond_to? :foo }
|
34
|
+
it { respond_to? :bar }
|
35
|
+
|
36
|
+
its(:foo) { should be nil }
|
37
|
+
its(:bar) { should eq(1) }
|
38
|
+
|
39
|
+
it 'not raises error' do
|
40
|
+
expect { HasMacroSubclass.carefull }.to_not raise_error
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'equals to the new default value' do
|
44
|
+
expect(HasMacroSubclass.carefull).to eq(0)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe 'methods' do
|
50
|
+
subject { HasMacroSubclass }
|
51
|
+
|
52
|
+
it { respond_to? :sqr }
|
53
|
+
its(:sqr) { respond_to? :call }
|
54
|
+
|
55
|
+
it "sqr method definition returns square of two numbers" do
|
56
|
+
expect(subject.sqr.(2)).to eq(4)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Synchronizable::Import do
|
4
|
+
let!(:team) { create :team }
|
5
|
+
subject { create(:import, synchronizable: team) }
|
6
|
+
|
7
|
+
it 'destroys itself with synchronizable record' do
|
8
|
+
expect { subject.destroy_with_synchronizable }.to change(Team, :count).by(-1)
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class HasMacro
|
2
|
+
include Synchronizable::DSL::Macro
|
3
|
+
|
4
|
+
attribute :bar, default: 1
|
5
|
+
attribute :foo
|
6
|
+
attribute :baz, default: -> { bar + 1 }
|
7
|
+
attribute :carefull, default: -> { raise NotImplementedError }
|
8
|
+
attribute :xyz, converter: ->(x) { x.to_s }
|
9
|
+
attribute :arr
|
10
|
+
|
11
|
+
method :sqr
|
12
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Synchronizable do
|
4
|
+
describe 'synchronization' do
|
5
|
+
subject do
|
6
|
+
-> { Synchronizable.sync }
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'models specified in configuration' do
|
10
|
+
context 'only Team and Match' do
|
11
|
+
before :all do
|
12
|
+
Synchronizable.models = %w(Match Team)
|
13
|
+
end
|
14
|
+
|
15
|
+
it { should change { Match.count }.by(1) }
|
16
|
+
it { should change { Team.count }.by(2) }
|
17
|
+
it { should change { Player.count }.by(4) }
|
18
|
+
it { should change { MatchPlayer.count }.by(4) }
|
19
|
+
|
20
|
+
it { should change { Synchronizable::Import.count }.by(11) }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'all' do
|
24
|
+
before :all do
|
25
|
+
Synchronizable.models = %w(
|
26
|
+
Stage Tournament Team
|
27
|
+
Match MatchPlayer Player
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
it { should change { Tournament.count }.by(1) }
|
32
|
+
it { should change { Stage.count }.by(2) }
|
33
|
+
it { should change { Match.count }.by(1) }
|
34
|
+
it { should change { Team.count }.by(2) }
|
35
|
+
it { should change { MatchPlayer.count }.by(4) }
|
36
|
+
it { should change { Player.count }.by(4) }
|
37
|
+
|
38
|
+
it { should change { Synchronizable::Import.count }.by(14) }
|
39
|
+
end
|
40
|
+
|
41
|
+
# TODO: Left here until :include option is implemented
|
42
|
+
#
|
43
|
+
# context 'when models setting is overriden in method call' do
|
44
|
+
# before :all do
|
45
|
+
# Synchronizable.models = %w(Team Match)
|
46
|
+
# end
|
47
|
+
|
48
|
+
# subject do
|
49
|
+
# -> { Synchronizable.sync(Match, Player) }
|
50
|
+
# end
|
51
|
+
|
52
|
+
# it { should change { Match.count }.by(1) }
|
53
|
+
# it { should change { Player.count }.by(22) }
|
54
|
+
# it { should_not change { Team.count }.by(2) }
|
55
|
+
|
56
|
+
# it { should change { Synchronizable::Import.count }.by(5) }
|
57
|
+
# end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|