|
24 | 24 | end |
25 | 25 | end |
26 | 26 |
|
27 | | - context "when the source is a class that modifies the sti_name" do |
| 27 | + context "when the source is a class that modifies the sti_name or polymorphic_name" do |
28 | 28 | it "properly sets the source_type to the modified class name" do |
29 | 29 | link = Link.new(source: Namespaced::Animal.new) |
30 | 30 | expect(link.source_type).to eql "Animal" |
31 | 31 | end |
| 32 | + |
| 33 | + it "can read dirty attributes from an associated object" do |
| 34 | + animal = Namespaced::Animal.create!(name: "Oldie") |
| 35 | + animal.name = "Newton" |
| 36 | + link = Link.create!(source: animal) |
| 37 | + |
| 38 | + expect(link.source.name).to eq("Newton") |
| 39 | + end |
32 | 40 | end |
33 | 41 |
|
34 | 42 | context "when querying the associations" do |
|
109 | 117 |
|
110 | 118 | end |
111 | 119 |
|
112 | | - context "When using a relation to the links with eagar loading" do |
| 120 | + context "When using a relation to the links with eager loading" do |
113 | 121 | let!(:links){ |
114 | 122 | [Link.create(source: source, target: kibble), |
115 | 123 | Link.create(source: source, target: water)] |
|
124 | 132 |
|
125 | 133 | end |
126 | 134 |
|
127 | | - context "When using a through relation to the links with eagar loading" do |
| 135 | + context "When using a through relation to the links with eager loading" do |
128 | 136 | let!(:links){ |
129 | 137 | [Link.create(source: source, target: kibble), |
130 | 138 | Link.create(source: source, target: water)] |
|
139 | 147 |
|
140 | 148 | end |
141 | 149 |
|
142 | | - context "When eagar loading the polymorphic association" do |
| 150 | + context "When eager loading the polymorphic association" do |
143 | 151 | let(:link) { Link.create(source_id: source.id, source_type: source.class.to_s) } |
144 | 152 | let(:source) { cat } |
145 | 153 |
|
|
160 | 168 | end |
161 | 169 |
|
162 | 170 |
|
| 171 | + |
163 | 172 | end |
164 | 173 |
|
165 | 174 | context "when the association is an STI table" do |
|
0 commit comments