diff --git a/spec/models/pricelist_spec.rb b/spec/models/pricelist_spec.rb deleted file mode 100644 index 4b680312a..000000000 --- a/spec/models/pricelist_spec.rb +++ /dev/null @@ -1,185 +0,0 @@ -require 'rails_helper' - -describe Pricelist do - before :all do - end - - context 'about class' do - end - - context 'with invalid attribute' do - before :all do - @pricelist = Pricelist.new - end - - it 'should not be valid' do - @pricelist.valid? - @pricelist.errors.full_messages.should match_array([ - "Category is missing", - "Duration is missing", - "Operation category is missing" - ]) - end - - it 'should not have creator' do - @pricelist.creator.should == nil - end - - it 'should not have updater' do - @pricelist.updator.should == nil - end - - it 'should not have any versions' do - @pricelist.versions.should == [] - end - - it 'should not have name' do - @pricelist.name.should == ' ' - end - end - - context 'with valid attributes' do - before :all do - @pricelist = Fabricate(:pricelist) - end - - it 'should be valid' do - @pricelist.valid? - @pricelist.errors.full_messages.should match_array([]) - end - - it 'should be valid twice' do - @pricelist = Fabricate(:pricelist) - @pricelist.valid? - @pricelist.errors.full_messages.should match_array([]) - end - - it 'should have name' do - @pricelist.name.should == 'create ee' - end - - it 'should have one version' do - with_versioning do - @pricelist.versions.reload.should == [] - @pricelist.price = 11 - @pricelist.save - @pricelist.errors.full_messages.should match_array([]) - @pricelist.versions.size.should == 1 - end - end - end - - it 'should return correct price' do - Pricelist.pricelist_for('ee', 'create', '1year').should == nil - - Fabricate(:pricelist, { - category: 'ee', - operation_category: 'create', - duration: '1year', - price: 1.50, - valid_from: Time.zone.parse('2198-01-01'), - valid_to: Time.zone.parse('2199-01-01') - }) - - Pricelist.pricelist_for('ee', 'create', '1year').should == nil - - Fabricate(:pricelist, { - category: 'ee', - operation_category: 'create', - duration: '1year', - price: 1.50, - valid_from: Time.zone.parse('2015-01-01'), - valid_to: nil - }) - - Pricelist.pricelist_for('ee', 'create', '1year').price.amount.should == 1.50 - - Fabricate(:pricelist, { - category: 'ee', - operation_category: 'create', - duration: '1year', - price: 1.30, - valid_from: Time.zone.parse('2015-01-01'), - valid_to: Time.zone.parse('2999-01-01') - }) - - Pricelist.pricelist_for('ee', 'create', '1year').price.amount.should == 1.30 - - Fabricate.create(:pricelist, { - category: 'ee', - operation_category: 'create', - duration: '1year', - price: 1.20, - valid_from: Time.zone.parse('2015-06-01'), - valid_to: Time.zone.parse('2999-01-01') - }) - - Pricelist.pricelist_for('ee', 'create', '1year').price.amount.should == 1.20 - - Fabricate.create(:pricelist, { - category: 'ee', - operation_category: 'create', - duration: '1year', - price: 1.10, - valid_from: Time.zone.parse('2014-01-01'), - valid_to: Time.zone.parse('2999-01-01') - }) - - Pricelist.pricelist_for('ee', 'create', '1year').price.amount.should == 1.20 - - Fabricate.create(:pricelist, { - category: 'ee', - operation_category: 'create', - duration: '1year', - price: 1.10, - valid_from: Time.zone.parse('2999-02-01'), - valid_to: Time.zone.parse('2999-01-01') - }) - - Pricelist.pricelist_for('ee', 'create', '1year').price.amount.should == 1.20 - - Fabricate.create(:pricelist, { - category: 'ee', - operation_category: 'create', - duration: '1year', - price: 1.10, - valid_from: Time.zone.parse('2015-06-02'), - valid_to: nil - }) - - Pricelist.pricelist_for('ee', 'create', '1year').price.amount.should == 1.20 - - Fabricate.create(:pricelist, { - category: 'ee', - operation_category: 'create', - duration: '1year', - price: 1.10, - valid_from: Time.zone.parse('2015-07-01'), - valid_to: Time.zone.parse('2999-01-01') - }) - - Pricelist.pricelist_for('ee', 'create', '1year').price.amount.should == 1.10 - - Fabricate.create(:pricelist, { - category: 'ee', - operation_category: 'create', - duration: '1year', - price: 2.10, - valid_from: Time.zone.now.to_date, - valid_to: Time.zone.now.to_date - }) - - Pricelist.pricelist_for('ee', 'create', '1year').price.amount.should == 2.10 - - Fabricate.create(:pricelist, { - category: 'ee', - operation_category: 'create', - duration: '2years', - price: 1.20, - valid_from: Time.zone.parse('2015-07-01'), - valid_to: Time.zone.parse('2999-01-01') - }) - - Pricelist.pricelist_for('ee', 'create', '2years').price.amount.should == 1.20 - end -end diff --git a/spec/models/zonefile_setting_spec.rb b/spec/models/zonefile_setting_spec.rb deleted file mode 100644 index 9b58f89dc..000000000 --- a/spec/models/zonefile_setting_spec.rb +++ /dev/null @@ -1,108 +0,0 @@ -require 'rails_helper' - -describe ZonefileSetting do - it 'generates the zonefile' do - Fabricate(:zonefile_setting) - Fabricate(:zonefile_setting, origin: 'pri.ee') - - d = Fabricate(:domain_with_dnskeys, name: 'testpri.ee') - d.nameservers << Nameserver.new({ - hostname: "ns.#{d.name}", - ipv4: '123.123.123.123', - ipv6: 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329' - }) - - @zonefile = ActiveRecord::Base.connection.execute( - "select generate_zonefile('ee')" - )[0]['generate_zonefile'] - - @zonefile.should_not be_blank - - # origin ns - @zonefile.scan(/ee. IN NS ns.ut.ee.\nee. IN NS ns.tld.ee./).count.should == 1 - # origin a - @zonefile.scan(/ns.ut.ee. IN A 193.40.5.99\nns.tld.ee. IN A 195.43.87.10/).count.should == 1 - # origin aaaa - @zonefile.scan(/ee.aso.ee. IN AAAA 2a02:88:0:21::2\nb.tld.ee. IN AAAA 2001:67c:1010:28::53/).count.should == 1 - - @zonefile.scan(/^#{d.name}/).count.should == 5 - @zonefile.scan('FE80:0000:0000:0000:0202:B3FF:FE1E:8329').count.should == 1 - - @zonefile = ActiveRecord::Base.connection.execute( - "select generate_zonefile('pri.ee')" - )[0]['generate_zonefile'] - - @zonefile.should_not be_blank - - @zonefile.scan(/^#{d.name}/).count.should == 0 - end - - it 'should not place serverHold nor clientHold domains into zonefile' do - Fabricate(:zonefile_setting) - d = Fabricate(:domain_with_dnskeys, - name: 'testzone.ee', - statuses: ['serverHold', 'serverDeleteProhibited', 'clientHold']) - d.nameservers << Nameserver.new({ - hostname: "ns.#{d.name}", - ipv4: '123.123.123.123', - ipv6: 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329' - }) - - @zonefile = ActiveRecord::Base.connection.execute( - "select generate_zonefile('ee')" - )[0]['generate_zonefile'] - - @zonefile.should_not be_blank - @zonefile.scan(/^#{d.name}/).count.should == 0 - @zonefile.scan(/ns.#{d.name}/).count.should == 0 - @zonefile.scan('123.123.123.123').count.should == 0 - @zonefile.scan('FE80:0000:0000:0000:0202:B3FF:FE1E:8329').count.should == 0 - - d.statuses = ['clientHold', 'serverDeleteProhibited'] - d.save - - @zonefile = ActiveRecord::Base.connection.execute( - "select generate_zonefile('ee')" - )[0]['generate_zonefile'] - - @zonefile.should_not be_blank - @zonefile.scan(/^#{d.name}/).count.should == 0 - @zonefile.scan(/ns.#{d.name}/).count.should == 0 - @zonefile.scan('123.123.123.123').count.should == 0 - @zonefile.scan('FE80:0000:0000:0000:0202:B3FF:FE1E:8329').count.should == 0 - - d.statuses = ['serverDeleteProhibited'] - d.save - - @zonefile = ActiveRecord::Base.connection.execute( - "select generate_zonefile('ee')" - )[0]['generate_zonefile'] - - @zonefile.should_not be_blank - @zonefile.scan('123.123.123.123').count.should == 1 - @zonefile.scan('FE80:0000:0000:0000:0202:B3FF:FE1E:8329').count.should == 1 - end - - it 'does not create duplicate zones' do - Fabricate(:zonefile_setting) - zs = Fabricate.build(:zonefile_setting) - zs.save.should == false - zs.errors.full_messages.should match_array(["Origin has already been taken"]) - end - - it 'does not allow deleting zone when it has existing domains' do - zs = Fabricate(:zonefile_setting) - - d = Fabricate(:domain) - - zs.destroy.should == false - - zs.errors.full_messages.should match_array(["There are 1 domains in this zone"]) - ZonefileSetting.count.should == 1 - - d.destroy - zs.destroy - - ZonefileSetting.count.should == 0 - end -end