roar 0.11.5 → 0.11.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ ## 0.11.6
2
+
3
+ * "Fixing" a bug where `links_definition_option` was missing when no link was set in a representer. Note that this is a quick and horrible bugfix and will soon be cleaned up.
4
+
1
5
  ## 0.11.5
2
6
 
3
7
  * Introducing HAL::links method to map arrays of link objects in the HAL format. This completes the HAL/JSON specification.
@@ -52,9 +52,6 @@ module Roar
52
52
  end
53
53
  end
54
54
  include LinksDefinitionMethods
55
- def links_definition_options # FIXME: make this unnecessary.
56
- self.class.links_definition_options
57
- end
58
55
 
59
56
  def before_serialize(options={})
60
57
  prepare_links!(options) unless options[:links] == false # DISCUSS: doesn't work when links are already setup (e.g. from #deserialize).
@@ -49,6 +49,10 @@ module Roar
49
49
  end
50
50
  end
51
51
 
52
+ def links_definition_options # FIXME: remove me ASAP!
53
+ [:links_array, {:from => :links, :class => Feature::Hypermedia::Hyperlink, :extend => HyperlinkRepresenter, :collection => true}]
54
+ end
55
+
52
56
  require "representable/json/hash"
53
57
  # Represents a hyperlink in standard roar+json hash representation.
54
58
  module HyperlinkRepresenter
@@ -86,7 +86,7 @@ module Roar::Representer
86
86
  def self.included(base)
87
87
  base.class_eval do
88
88
  include Roar::Representer::Feature::Hypermedia
89
- include InstanceMethods
89
+ include InstanceMethods
90
90
  extend Links::ClassMethods
91
91
  end
92
92
  end
@@ -47,6 +47,10 @@ module Roar
47
47
  end
48
48
  end
49
49
 
50
+ def links_definition_options # FIXME: remove me ASAP!
51
+ [:links_array, {:from => :link, :class => Feature::Hypermedia::Hyperlink, :collection => true, :extend => XML::HyperlinkRepresenter}]
52
+ end
53
+
50
54
 
51
55
  require 'representable/xml/hash'
52
56
  module HyperlinkRepresenter
@@ -1,3 +1,3 @@
1
1
  module Roar
2
- VERSION = "0.11.5"
2
+ VERSION = "0.11.6"
3
3
  end
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
  require 'roar/representer/feature/hypermedia'
3
3
  require 'roar/representer/json'
4
4
 
5
- class HypermediaTest
5
+ class HypermediaTest < MiniTest::Spec
6
6
  describe "Hypermedia Feature" do
7
7
 
8
8
 
@@ -135,35 +135,6 @@ class LinkCollectionTest < MiniTest::Spec
135
135
  end
136
136
  end
137
137
 
138
- class HyperlinkTest < MiniTest::Spec
139
- Hyperlink = Roar::Representer::Feature::Hypermedia::Hyperlink
140
- describe "Hyperlink" do
141
- subject { Hyperlink.new(:rel => "self", "href" => "http://self", "data-whatever" => "Hey, @myabc") }
142
-
143
- it "accepts string keys in constructor" do
144
- assert_equal "Hey, @myabc", subject.send("data-whatever")
145
- end
146
-
147
- it "responds to #rel" do
148
- assert_equal "self", subject.rel
149
- end
150
-
151
- it "responds to #href" do
152
- assert_equal "http://self", subject.href
153
- end
154
-
155
- it "responds to #replace with string keys" do
156
- subject.replace("rel" => "next")
157
- assert_equal nil, subject.href
158
- assert_equal "next", subject.rel
159
- end
160
-
161
- it "responds to #each and implements Enumerable" do
162
- assert_equal ["rel:self", "href:http://self", "data-whatever:Hey, @myabc"], subject.collect { |k,v| "#{k}:#{v}" }
163
- end
164
- end
165
- end
166
-
167
138
  class HyperlinkInheritanceTest < MiniTest::Spec
168
139
  describe "when the base representer has a link" do
169
140
  before do
@@ -54,6 +54,14 @@ class HypermediaTest < MiniTest::Spec
54
54
  subject.to_json.must_equal "{\"links\":[{\"rel\":\"self\",\"href\":\"//self\",\"type\":\"image/jpg\"}]}"
55
55
  end
56
56
  end
57
+
58
+ describe "not calling #link" do
59
+ representer_for {}
60
+
61
+ it "still allows rendering" do
62
+ subject.to_json.must_equal "{\"links\":[]}"
63
+ end
64
+ end
57
65
  end
58
66
 
59
67
  # private tests:
@@ -97,4 +105,32 @@ class LinksDefinitionTest < MiniTest::Spec
97
105
  assert subject.clone.rel2block.object_id != subject.rel2block.object_id
98
106
  end
99
107
  end
100
- end
108
+ end
109
+
110
+ class HyperlinkTest < MiniTest::Spec
111
+ describe "Hyperlink" do
112
+ subject { link(:rel => "self", "href" => "http://self", "data-whatever" => "Hey, @myabc") }
113
+
114
+ it "accepts string keys in constructor" do
115
+ assert_equal "Hey, @myabc", subject.send("data-whatever")
116
+ end
117
+
118
+ it "responds to #rel" do
119
+ assert_equal "self", subject.rel
120
+ end
121
+
122
+ it "responds to #href" do
123
+ assert_equal "http://self", subject.href
124
+ end
125
+
126
+ it "responds to #replace with string keys" do
127
+ subject.replace("rel" => "next")
128
+ assert_equal nil, subject.href
129
+ assert_equal "next", subject.rel
130
+ end
131
+
132
+ it "responds to #each and implements Enumerable" do
133
+ assert_equal ["rel:self", "href:http://self", "data-whatever:Hey, @myabc"], subject.collect { |k,v| "#{k}:#{v}" }
134
+ end
135
+ end
136
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.5
4
+ version: 0.11.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-04 00:00:00.000000000 Z
12
+ date: 2013-01-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: representable