Created
March 30, 2012 07:11
-
-
Save arion/2248380 to your computer and use it in GitHub Desktop.
spec seconds_left bug
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
it "should calculate with real tarif" do | |
time = Time.local(2011, 5, 6, 13, 00, 0) | |
Timecop.freeze(time) do | |
real_tarif_settings = YAML.load(File.read(File.join(RACK_ROOT, 'spec', 'support', 'unit_tarif.yml'))) | |
real_calc_module = CalculationModule.create!(:slug => 'real_tariff', :settings => real_tarif_settings) | |
real_tarif = Tarif.create!(:name => 'real_tariff', :starts_at => 1.year.ago) | |
CalculationRule.make!(:calculation_module => real_calc_module, :service => Service.find(ServerConfig.service_autorun_id), :tarif => real_tarif) | |
computer = Computer.make!(:computer_class => ComputerClass.find('b12d1111-50c0-11e1-95f6-0023df7d4b7e')) | |
# свой сервис | |
service = Service.make! | |
mememe_path = "C:\\Omega\\Software\\Mine\\mememe.exe" | |
application = Application.make!(:service => service, :path => mememe_path) | |
CalculationRule.make!(:calculation_module => real_calc_module, :service => service, :tarif => real_tarif) | |
CalculationRulesCache.instance.reload! | |
real_tarif_group = TarifGroup.make! | |
real_tarif_group.tarifs << real_tarif | |
login = Login.make!(:login => '1111111', :password => '1234', :password_confirmation => '1234', :tarif_group => real_tarif_group) | |
Account.find(ServerConfig.src_account_id).transfer 2, :to => login.account, :author_id => ServerConfig.ft_author_id | |
login.reload.balance.should == 2 | |
client = TestClient.new('1111111', '1234') | |
# AUHT | |
auth = client.auth(computer.number) | |
Session.find(auth.sessionId).authenticated?.should == true | |
# START | |
start = client.start(real_tarif.id) | |
Session.find(auth.sessionId).running?.should == true | |
# SERVICE START | |
service_start = client.service_start(mememe_path) | |
session = Session.find(service_start.sessionId) | |
session.application_sessions.count.should == 2 | |
login.reload.balance.should == 2 | |
session.reload.seconds_left.should == 3599 | |
session.reload.create_activities(30) | |
UnprocessedActivity.all.each(&:processed!) | |
login.reload.balance.should == 1 | |
session.reload.seconds_left.should == 1 | |
Timecop.travel(6.hours.from_now) | |
session.reload.pipe! | |
login.reload.balance.should == 1 | |
session.reload.seconds_left.should == 1 | |
Timecop.travel(6.hours.from_now) | |
session.reload.pipe! | |
login.reload.balance.should == 1 | |
session.reload.seconds_left.should == 1 | |
session.reload.create_activities(30) | |
UnprocessedActivity.all.each(&:processed!) | |
login.reload.balance.should == 0 | |
session.reload.seconds_left.should == 1 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment