aboutsummaryrefslogtreecommitdiffstats
path: root/spec/lib/model_attribute_spec.rb
diff options
context:
space:
mode:
authorTeddy Wing2017-09-19 16:59:45 +0200
committerTeddy Wing2017-09-19 17:00:30 +0200
commite1547b52a372942b34cda3b3fee4ab76e9f1b65e (patch)
tree166d3bb167ad1b213a2fae98ec5daf22f3ea90ae /spec/lib/model_attribute_spec.rb
parent30fc0d3f1a9a158a0d45bbaf2f78e176f74ac943 (diff)
downloadchouette-core-e1547b52a372942b34cda3b3fee4ab76e9f1b65e.tar.bz2
ModelAttribute: Add `#code` method
A method that returns a string representation of the attribute, in the form `:class#:name". This will be used to store a reference to the attribute in the database. For example, a validation will reference a `ModelAttribute` in a database column using this `#code` string. Refs #4401
Diffstat (limited to 'spec/lib/model_attribute_spec.rb')
-rw-r--r--spec/lib/model_attribute_spec.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/lib/model_attribute_spec.rb b/spec/lib/model_attribute_spec.rb
index da767cfed..ad1dd863f 100644
--- a/spec/lib/model_attribute_spec.rb
+++ b/spec/lib/model_attribute_spec.rb
@@ -13,4 +13,12 @@ RSpec.describe ModelAttribute do
expect(model_attr.data_type).to eq(:string)
end
end
+
+ describe "#code" do
+ it "returns a string representation of the attribute" do
+ model_attr = ModelAttribute.new(:route, :name, :string)
+
+ expect(model_attr.code).to eq('route#name')
+ end
+ end
end