spec/resources/credit_note_spec.rb in sk-api-1.0.6 vs spec/resources/credit_note_spec.rb in sk-api-1.1.0
- old
+ new
@@ -1,6 +1,6 @@
-require "#{File.dirname(__FILE__)}/../spec_helper"
+require 'spec/spec_helper'
describe SKApi::Resources::CreditNote, "in general" do
before :all do
#setup test doc to work with
@@ -23,15 +23,16 @@
lambda {
client = SKApi::Resources::Client.find(@client.id)
}.should raise_error(ActiveResource::ResourceNotFound)
end
- it "should create a doc" do
+ it "should create a doc and use default before after text" do
@doc.errors.should be_empty
+ @doc.notes_before.should_not be_empty
@doc.new?.should be_false
end
-
+
it "should fail create a doc" do
doc = SKApi::Resources::CreditNote.new()
doc.save.should == false
doc.errors.count.should == 1
doc.errors.on(:client_id).should == "can't be blank"
@@ -42,15 +43,14 @@
doc.title.should == @doc.title
end
it "should validate raw json object with schema" do
doc = SKApi::Resources::CreditNote.find(@doc.id)
-# doc.number.should=='23'
# convert to json and read raw without activeresource assigning classes
json = doc.to_json
- obj = Rufus::Json.decode(json)
+ obj = ActiveSupport::JSON.decode(json)
lambda {
- JSON::Schema.validate(obj, SKApi::Resources::CreditNote.schema)
+ JSON::Schema.validate(obj['credit_note'], SKApi::Resources::CreditNote.schema)
}.should_not raise_error
end
it "should edit a doc" do
# @doc.lock_version.should == 0 # dont work cause doc is saved twice, for recalc of totals
\ No newline at end of file