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
String calculateStatus () { | |
// TODO Should we look at using a State pattern here? -Mark 11/10/09 | |
def result = null | |
if (this.isCancelled()) { | |
return 'CANCELLED' | |
} |
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
package models | |
import javax.persistence.* | |
import lib.ConversionUtils as CU | |
import lib.BigDecimalUtils as BDU | |
@Entity | |
@DiscriminatorValue("PO") | |
class PoLotJpaImpl extends LotJpaImpl { |
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
void testCalculateDestinationTransportOrderDateOfArrivalScheduledShouldReturnTheTODateOfArrivalWhenThereIsATO () { | |
def lot = mockLot() | |
def to = new TransportOrderJpaImpl () | |
def now = new Date () | |
to.dateOfArrivalScheduled = now | |
lot.activeDestinationTransportOrders.returns([ to ]) | |
lot.activeDestinationTransportOrders.returns([ to ]) | |
play { | |
assertEquals(now, lot.calculateDestinationTransportOrderDateOfArrivalScheduled()) | |
} |
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
def result = this.invoiceLineItems.collect { it.quantityNet }.inject(0.0G) { sum, ili -> | |
sum + ili | |
} | |
This code throws: | |
java.lang.ClassCastException: java.lang.Integer cannot be cast to groovy.lang.Closure | |
at org.codehaus.groovy.runtime.ConvertedMap.invokeCustom(ConvertedMap.java:42) | |
at org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:77) | |
at $Proxy1.getQuantityNet(Unknown Source) |
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
class Member < ActiveRecord::Base | |
class << self | |
def new (attributes = nil, &block) | |
if self == Member | |
klass = Object.const_get("#{(ENV['MORI_ENV'] ? ENV['MORI_ENV'] : "").camelize}Member".to_sym) | |
if klass != Member | |
return klass.new(attributes, &block) | |
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
class Foo | |
# This way of calling define_method works. | |
define_method(:bar) do | |
puts self | |
end | |
# This fails saying define_method is a private method. | |
# Why, when self is obviously the object receiving the define_method message...? | |
self.define_method(:foo) do | |
puts self | |
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
class Post < ActiveRecord::Base | |
end | |
class RatingEvent < ActiveRecord::Base | |
end | |
class PostRatingObserver < ActiveRecord::Base | |
observer :post | |
def after_save |
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
2009-10-06 15:02:58.980::WARN: Error for /quadran/ | |
java.lang.NoClassDefFoundError: org/jruby/RubyTempfile | |
at java.lang.Class.getDeclaredMethods0(Native Method) | |
at java.lang.Class.privateGetDeclaredMethods(Class.java:2395) | |
at java.lang.Class.getDeclaredMethods(Class.java:1763) | |
at org.jruby.RubyModule$MethodClumper.clump(RubyModule.java:574) | |
at org.jruby.anno.TypePopulator$DefaultTypePopulator.populate(TypePopulator.java:47) | |
at org.jruby.RubyModule.defineAnnotatedMethodsIndividually(RubyModule.java:660) | |
at org.jruby.RubyModule.defineAnnotatedMethods(RubyModule.java:562) | |
at org.jruby.rack.input.RackBaseInput.getClass(RackBaseInput.java:36) |
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
World do | |
session = Webrat::MechanizeSession.new | |
session.extend(Webrat::Matchers) | |
session.extend(Webrat::HaveTagMatcher) | |
session | |
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
Feature: Login # features/login.feature | |
In order to secure access to the application. | |
I want all users to have to login. | |
Scenario: Present login page to unauthenticated users. # features/login.feature:5 | |
Given I have an account for "test" # features/step_definitions/global_steps.rb:3 | |
And I go to "account root" # features/step_definitions/webrat_steps.rb:6 | |
Then I should see "Login" # features/step_definitions/webrat_steps.rb:94 | |
expected: /Login/m, | |
got: "<html><body>You are being <a href=\"http://test.localhost/session/new\">redirected</a>.</body></html>" (using =~) | |
Diff: |