move-to-go 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +7 -0
  2. data/bin/move-to-go +210 -0
  3. data/lib/move-to-go/can_become_immutable.rb +29 -0
  4. data/lib/move-to-go/csv_helper.rb +47 -0
  5. data/lib/move-to-go/email_helper.rb +14 -0
  6. data/lib/move-to-go/errors.rb +31 -0
  7. data/lib/move-to-go/excel_helper.rb +10 -0
  8. data/lib/move-to-go/global_phone.json +6571 -0
  9. data/lib/move-to-go/model/address.rb +63 -0
  10. data/lib/move-to-go/model/class_settings.rb +50 -0
  11. data/lib/move-to-go/model/clientvisit.rb +10 -0
  12. data/lib/move-to-go/model/comment.rb +10 -0
  13. data/lib/move-to-go/model/coworker.rb +82 -0
  14. data/lib/move-to-go/model/coworker_reference.rb +33 -0
  15. data/lib/move-to-go/model/customfield.rb +87 -0
  16. data/lib/move-to-go/model/deal.rb +216 -0
  17. data/lib/move-to-go/model/deal_class_settings.rb +97 -0
  18. data/lib/move-to-go/model/deal_state.rb +15 -0
  19. data/lib/move-to-go/model/deal_status.rb +23 -0
  20. data/lib/move-to-go/model/deal_status_reference.rb +47 -0
  21. data/lib/move-to-go/model/deal_status_setting.rb +49 -0
  22. data/lib/move-to-go/model/documents.rb +76 -0
  23. data/lib/move-to-go/model/file.rb +193 -0
  24. data/lib/move-to-go/model/history.rb +148 -0
  25. data/lib/move-to-go/model/history_classification.rb +26 -0
  26. data/lib/move-to-go/model/link.rb +82 -0
  27. data/lib/move-to-go/model/organization.rb +250 -0
  28. data/lib/move-to-go/model/person.rb +164 -0
  29. data/lib/move-to-go/model/referencetosource.rb +58 -0
  30. data/lib/move-to-go/model/relation.rb +23 -0
  31. data/lib/move-to-go/model/rootmodel.rb +663 -0
  32. data/lib/move-to-go/model/salescall.rb +10 -0
  33. data/lib/move-to-go/model/settings.rb +61 -0
  34. data/lib/move-to-go/model/tag.rb +35 -0
  35. data/lib/move-to-go/model/talkedto.rb +10 -0
  36. data/lib/move-to-go/model/triedtoreach.rb +10 -0
  37. data/lib/move-to-go/model_helpers.rb +97 -0
  38. data/lib/move-to-go/phone_helper.rb +75 -0
  39. data/lib/move-to-go/roo_helper.rb +82 -0
  40. data/lib/move-to-go/serialize_helper.rb +199 -0
  41. data/lib/move-to-go/shard_helper.rb +96 -0
  42. data/lib/move-to-go/source.rb +108 -0
  43. data/lib/move-to-go/templating.rb +52 -0
  44. data/lib/move-to-go.rb +20 -0
  45. data/sources/VISMA/.gitignore +14 -0
  46. data/sources/VISMA/.move-to-go/readme.txt +1 -0
  47. data/sources/VISMA/.move-to-go/runner.rb +89 -0
  48. data/sources/VISMA/Database/KONTAKT.DBF +0 -0
  49. data/sources/VISMA/Database/KUND.DBF +0 -0
  50. data/sources/VISMA/Gemfile +5 -0
  51. data/sources/VISMA/converter.rb +120 -0
  52. data/sources/base-crm/.move-to-go/runner.rb +235 -0
  53. data/sources/base-crm/Gemfile +5 -0
  54. data/sources/base-crm/README.md +9 -0
  55. data/sources/base-crm/converter.rb +56 -0
  56. data/sources/base-crm/data/contacts.csv +13 -0
  57. data/sources/base-crm/data/coworkers.csv +3 -0
  58. data/sources/base-crm/data/deals.csv +5 -0
  59. data/sources/base-crm/data/histories.csv +6 -0
  60. data/sources/base-crm/data/leads.csv +4 -0
  61. data/sources/base-crm/data/tasks.csv +5 -0
  62. data/sources/csv/.gitignore +14 -0
  63. data/sources/csv/.move-to-go/readme.txt +1 -0
  64. data/sources/csv/.move-to-go/runner.rb +65 -0
  65. data/sources/csv/Gemfile +5 -0
  66. data/sources/csv/converter.rb +218 -0
  67. data/sources/csv/data/coworkers.csv +2 -0
  68. data/sources/csv/data/deals.csv +2 -0
  69. data/sources/csv/data/organizations.csv +2 -0
  70. data/sources/csv/data/persons.csv +2 -0
  71. data/sources/custom/.gitignore +14 -0
  72. data/sources/custom/.move-to-go/readme.txt +1 -0
  73. data/sources/custom/.move-to-go/runner.rb +30 -0
  74. data/sources/custom/Gemfile +4 -0
  75. data/sources/custom/converter.rb +45 -0
  76. data/sources/excel/.gitignore +14 -0
  77. data/sources/excel/.move-to-go/readme.txt +3 -0
  78. data/sources/excel/.move-to-go/runner.rb +140 -0
  79. data/sources/excel/Gemfile +7 -0
  80. data/sources/excel/converter.rb +188 -0
  81. data/sources/excel/files/avtal.docx +0 -0
  82. data/sources/excel/files/more/avtal.docx +0 -0
  83. data/sources/excel/files/more/offert-2.pdf +0 -0
  84. data/sources/excel/files/offert-2.docx +0 -0
  85. data/sources/excel/files/offert.docx +0 -0
  86. data/sources/excel/sample-data.xlsx +0 -0
  87. data/sources/excel-basic/.gitignore +14 -0
  88. data/sources/excel-basic/.move-to-go/readme.txt +3 -0
  89. data/sources/excel-basic/.move-to-go/runner.rb +139 -0
  90. data/sources/excel-basic/Exempelfil.xlsx +0 -0
  91. data/sources/excel-basic/Gemfile +6 -0
  92. data/sources/excel-basic/converter.rb +175 -0
  93. data/sources/excel-basic/files/avtal.docx +0 -0
  94. data/sources/excel-basic/files/more/avtal.docx +0 -0
  95. data/sources/excel-basic/files/more/offert-2.pdf +0 -0
  96. data/sources/excel-basic/files/offert-2.docx +0 -0
  97. data/sources/excel-basic/files/offert.docx +0 -0
  98. data/sources/lime-crm-basic/.gitignore +14 -0
  99. data/sources/lime-crm-basic/.move-to-go/readme.txt +1 -0
  100. data/sources/lime-crm-basic/.move-to-go/runner.rb +524 -0
  101. data/sources/lime-crm-basic/Gemfile +6 -0
  102. data/sources/lime-crm-basic/converter.rb +396 -0
  103. data/sources/lime-easy/.gitignore +14 -0
  104. data/sources/lime-easy/.move-to-go/readme.txt +1 -0
  105. data/sources/lime-easy/.move-to-go/runner.rb +348 -0
  106. data/sources/lime-easy/Export/readme.txt +6 -0
  107. data/sources/lime-easy/Gemfile +5 -0
  108. data/sources/lime-easy/converter.rb +362 -0
  109. data/sources/salesforce/.gitignore +14 -0
  110. data/sources/salesforce/.move-to-go/readme.txt +1 -0
  111. data/sources/salesforce/.move-to-go/runner.rb +404 -0
  112. data/sources/salesforce/Gemfile +6 -0
  113. data/sources/salesforce/Gemfile.lock +48 -0
  114. data/sources/salesforce/converter.rb +113 -0
  115. data/sources/salesforce/export/readme.txt +3 -0
  116. data/spec/address_spec.rb +49 -0
  117. data/spec/class_settings_spec.rb +37 -0
  118. data/spec/coworker_spec.rb +94 -0
  119. data/spec/custom_field_spec.rb +22 -0
  120. data/spec/deal_class_settings_spec.rb +116 -0
  121. data/spec/deal_spec.rb +232 -0
  122. data/spec/deal_status_reference_spec.rb +17 -0
  123. data/spec/documents_spec.rb +64 -0
  124. data/spec/file_spec.rb +178 -0
  125. data/spec/helpers/csv_helper_spec.rb +45 -0
  126. data/spec/helpers/email_helper_spec.rb +37 -0
  127. data/spec/helpers/phone_helper_spec.rb +119 -0
  128. data/spec/helpers/roo_helper_spec.rb +10 -0
  129. data/spec/helpers/serialize_helper_spec.rb +253 -0
  130. data/spec/helpers/shard_helper_spec.rb +141 -0
  131. data/spec/helpers/xsd_validate_spec.rb +57 -0
  132. data/spec/history_spec.rb +150 -0
  133. data/spec/link_spec.rb +107 -0
  134. data/spec/organization_spec.rb +221 -0
  135. data/spec/person_spec.rb +129 -0
  136. data/spec/rootmodel_spec.rb +993 -0
  137. data/spec/spec_helper.rb +30 -0
  138. metadata +362 -0
@@ -0,0 +1,94 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+ require 'move-to-go'
4
+
5
+ describe "Coworker" do
6
+ let(:coworker) {
7
+ MoveToGo::Coworker.new
8
+ }
9
+
10
+ describe "parse_name_to_firstname_lastname_se" do
11
+ it "can parse 'Kalle Nilsson' into firstname 'Kalle' and lastname 'Nilsson'" do
12
+ coworker.parse_name_to_firstname_lastname_se 'Kalle Nilsson'
13
+
14
+ coworker.first_name.should eq 'Kalle'
15
+ coworker.last_name.should eq 'Nilsson'
16
+
17
+ end
18
+
19
+ it "can parse 'Kalle Svensson Nilsson' into firstname 'Kalle' and lastname 'Svensson Nilsson'" do
20
+ coworker.parse_name_to_firstname_lastname_se 'Kalle Svensson Nilsson'
21
+
22
+ coworker.first_name.should eq 'Kalle'
23
+ coworker.last_name.should eq 'Svensson Nilsson'
24
+ end
25
+
26
+ it "sets default name when name is empty" do
27
+ coworker.parse_name_to_firstname_lastname_se '', 'a default'
28
+
29
+ coworker.first_name.should eq 'a default'
30
+ end
31
+
32
+ it "sets default name when name is nil" do
33
+ coworker.parse_name_to_firstname_lastname_se nil, 'a default'
34
+
35
+ coworker.first_name.should eq 'a default'
36
+ end
37
+ end
38
+
39
+ describe "guess_email" do
40
+ it "guesses kalle.nilsson@x.com for coworker with firstname 'Kalle', lastname 'Nilsson' and domain set to 'x.com" do
41
+ coworker.first_name = 'Kalle'
42
+ coworker.last_name = 'Nilsson'
43
+
44
+ guessed = coworker.guess_email 'x.com'
45
+
46
+ guessed.should eq 'kalle.nilsson@x.com'
47
+ end
48
+
49
+ it "guesses '' when lastname is missing" do
50
+ coworker.first_name = 'Kalle'
51
+ coworker.last_name = ''
52
+
53
+ guessed = coworker.guess_email 'x.com'
54
+
55
+ guessed.should eq ''
56
+ end
57
+
58
+ it "guesses '' when firstname is missing" do
59
+ coworker.first_name = nil
60
+ coworker.last_name = 'Nilsson'
61
+
62
+ guessed = coworker.guess_email 'x.com'
63
+
64
+ guessed.should eq ''
65
+ end
66
+
67
+ it "guesses åäöèé to be aaoee" do
68
+ coworker.first_name = 'åäöèé'
69
+ coworker.last_name = 'Nilsson'
70
+
71
+ guessed = coworker.guess_email 'x.com'
72
+
73
+ guessed.should eq 'aaoee.nilsson@x.com'
74
+ end
75
+
76
+ it "guesses 'sven-erik.nilsson@x.com' when firstname has two names with ' ' between them" do
77
+ coworker.first_name = 'Sven Erik'
78
+ coworker.last_name = 'Nilsson'
79
+
80
+ guessed = coworker.guess_email 'x.com'
81
+
82
+ guessed.should eq 'sven-erik.nilsson@x.com'
83
+ end
84
+
85
+ it "guesses 'sven.nilsson-svensson@x.com' when lastnames has two names with ' ' between them" do
86
+ coworker.first_name = 'Sven'
87
+ coworker.last_name = 'Nilsson Svensson'
88
+
89
+ guessed = coworker.guess_email 'x.com'
90
+
91
+ guessed.should eq 'sven.nilsson-svensson@x.com'
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,22 @@
1
+ require "spec_helper"
2
+ require 'move-to-go'
3
+
4
+ describe "CustomField" do
5
+ before (:all) do
6
+ @custom_field = MoveToGo::CustomField.new({:id => 'the id',
7
+ :integration_id=>'the key',
8
+ :value=> 'the value'})
9
+ end
10
+
11
+ it "is the same as a custom field with the same integration_id" do
12
+ @custom_field.same_as?(MoveToGo::CustomField.new({:integration_id=>'the key',
13
+ :value=> 'the value 2'})).should eq true
14
+ end
15
+
16
+ it "is the same as a custom field with the same id" do
17
+ @custom_field.same_as?(MoveToGo::CustomField.new({:id=>'the id',
18
+ :value=> 'the value 2'})).should eq true
19
+ end
20
+
21
+ end
22
+
@@ -0,0 +1,116 @@
1
+ require "spec_helper"
2
+ require "move-to-go"
3
+
4
+ describe "DealClassSettings" do
5
+ let(:deal_class_settings) {
6
+ MoveToGo::DealClassSettings.new
7
+ }
8
+
9
+ it "should not allow new deal status without a label" do
10
+ # given, when
11
+ begin
12
+ deal_class_settings.add_status({:integration_id => "123"})
13
+ rescue MoveToGo::InvalidDealStatusError
14
+ end
15
+
16
+ # then
17
+ deal_class_settings.statuses.length.should eq 0
18
+ end
19
+
20
+ it "should set assessment to NotAnEndState as default" do
21
+ # given, when
22
+ status = deal_class_settings.add_status({:label => "1. Kvalificering"})
23
+
24
+ # then
25
+ status.assessment.should eq MoveToGo::DealState::NotAnEndState
26
+ end
27
+
28
+ it "should set assessment if specified" do
29
+ # given, when
30
+ status = deal_class_settings.add_status({
31
+ :label => "4. Won deal",
32
+ :assessment => MoveToGo::DealState::PositiveEndState
33
+ })
34
+
35
+ # then
36
+ status.assessment.should eq MoveToGo::DealState::PositiveEndState
37
+ end
38
+
39
+ it "should find a status by case insensitive label" do
40
+ # given
41
+ deal_class_settings.add_status({:label => "1. Kvalificering"})
42
+ deal_class_settings.add_status({:label => "2. Skickat offert"})
43
+
44
+ # when
45
+ status = deal_class_settings.find_status_by_label("2. skICkat OfFert")
46
+
47
+ # then
48
+ status.label.should eq "2. Skickat offert"
49
+ end
50
+
51
+ it "should find a status by integration id" do
52
+ # given
53
+ deal_class_settings.add_status({:label => "1. Kvalificering", :integration_id => "qualify"})
54
+ deal_class_settings.add_status({:label => "2. Skickat offert", :integration_id => "tender sent"})
55
+
56
+ # when
57
+ status = deal_class_settings.find_status_by_integration_id("tender SeNT")
58
+
59
+ # then
60
+ status.label.should eq "2. Skickat offert"
61
+ end
62
+
63
+ it "should find nil by label if no statuses are defined" do
64
+ # given, when
65
+ status = deal_class_settings.find_status_by_label("3. Won")
66
+
67
+ # then
68
+ status.should eq nil
69
+ end
70
+
71
+ it "should find nil by label if label is nil" do
72
+ # given
73
+ deal_class_settings.add_status({:label => "1. Kvalificering", :integration_id => "qualify"})
74
+ deal_class_settings.add_status({:label => "2. Skickat offert", :integration_id => "tender sent"})
75
+
76
+ # when
77
+ status = deal_class_settings.find_status_by_label(nil)
78
+
79
+ # then
80
+ status.should eq nil
81
+ end
82
+
83
+ it "should find nil by integration id if no statuses are defined" do
84
+ # given, when
85
+ status = deal_class_settings.find_status_by_integration_id("3. Won")
86
+
87
+ # then
88
+ status.should eq nil
89
+ end
90
+
91
+ it "should find nil by integration id if integration id is nil" do
92
+ # given
93
+ deal_class_settings.add_status({:label => "1. Kvalificering", :integration_id => "qualify"})
94
+ deal_class_settings.add_status({:label => "2. Skickat offert", :integration_id => "tender sent"})
95
+
96
+ # when
97
+ status = deal_class_settings.find_status_by_integration_id(nil)
98
+
99
+ # then
100
+ status.should eq nil
101
+ end
102
+
103
+ it "default status must be a deal status reference" do
104
+ # given
105
+ deal_class_settings.add_status({:label => '1. Kvalificering', :integration_id => 'qualify'})
106
+ deal_class_settings.add_status({:label => "2. Skickat offert", :integration_id => "tender sent"})
107
+
108
+ # when
109
+ deal_class_settings.default_status = '1. Kvalificering'
110
+
111
+ # then
112
+ deal_class_settings.default_status.is_a?(MoveToGo::DealStatusReference)
113
+ end
114
+ end
115
+
116
+
data/spec/deal_spec.rb ADDED
@@ -0,0 +1,232 @@
1
+ require "spec_helper"
2
+ require 'move-to-go'
3
+
4
+ describe "Deal" do
5
+ let(:deal){
6
+ MoveToGo::Deal.new
7
+ }
8
+
9
+ it "should have import tag as default" do
10
+ # given, when, then
11
+ deal.tags.count.should eq 1
12
+ deal.tags[0].value.should eq 'Import'
13
+ end
14
+
15
+ it "will set customer ref when customer is assigned" do
16
+ # given
17
+ org = MoveToGo::Organization.new({:integration_id => "123", :name => "Lundalogik"})
18
+
19
+ # when
20
+ deal.customer = org
21
+
22
+ # then
23
+ deal.customer.is_a?(MoveToGo::Organization).should eq true
24
+ deal.instance_variable_get(:@customer_reference).is_a?(MoveToGo::OrganizationReference).should eq true
25
+ end
26
+
27
+ it "will set coworker ref when coworker is assigned" do
28
+ # given
29
+ coworker = MoveToGo::Coworker.new({:integration_id => "456", :first_name => "Billy", :last_name => "Bob"})
30
+
31
+ # when
32
+ deal.responsible_coworker = coworker
33
+
34
+ # then
35
+ deal.responsible_coworker.is_a?(MoveToGo::Coworker).should eq true
36
+ deal.instance_variable_get(:@responsible_coworker_reference).is_a?(MoveToGo::CoworkerReference).should eq true
37
+ end
38
+
39
+ it "will set person ref when person is assigned" do
40
+ # given
41
+ person = MoveToGo::Person.new({:integration_id => "123"})
42
+
43
+ # when
44
+ deal.customer_contact = person
45
+
46
+ # then
47
+ deal.customer_contact.is_a?(MoveToGo::Person).should eq true
48
+ deal.instance_variable_get(:@customer_contact_reference).is_a?(MoveToGo::PersonReference).should eq true
49
+ end
50
+
51
+ it "will fail on validation if name is empty" do
52
+ # given
53
+ deal.name = ""
54
+ deal.status = "required status"
55
+
56
+ # when, then
57
+ deal.validate.length.should be > 0
58
+ end
59
+
60
+ it "will fail on validation if name is nil" do
61
+ # given
62
+ deal.name = nil
63
+ deal.status = "required status"
64
+
65
+ # when, then
66
+ deal.validate.length.should be > 0
67
+ end
68
+
69
+ it "will fail on validation if status dont have a status reference" do
70
+ # given
71
+ deal.name = "Deal must have a name"
72
+ # this will create a status with a status_reference
73
+ deal.status = "Driv"
74
+
75
+ # when
76
+ # and this will set the reference to nil (this will probably
77
+ # never happen in the real world).
78
+ deal.status.status_reference = nil
79
+
80
+ # then
81
+ deal.validate.length.should be > 0
82
+ end
83
+
84
+ it "will fail on validation if status has an invalid status reference" do
85
+ # given
86
+ deal.name = "Deal must have a name"
87
+ deal.status = ""
88
+
89
+ # when, then
90
+ deal.validate.length.should be > 0
91
+ end
92
+
93
+ it "should convert value strings that looks like number to number" do
94
+ # given
95
+ deal.name = "The deal with a strange value"
96
+
97
+ # when
98
+ deal.value = "357 000"
99
+
100
+ # then
101
+ deal.value.should eq "357000"
102
+ end
103
+
104
+ it "should set empty string to 0 value" do
105
+ # given
106
+ deal.name = "The deal with no value"
107
+
108
+ # when
109
+ deal.value = ""
110
+
111
+ # then
112
+ deal.value.should eq "0"
113
+ end
114
+
115
+ it "should set value to 0 if assigned a string with spaces" do
116
+ # given
117
+ deal.name = "The deal with no value"
118
+
119
+ # when
120
+ deal.value = " "
121
+
122
+ # then
123
+ deal.value.should eq "0"
124
+ end
125
+
126
+ it "should raise invalidvalueerror if value is not a number" do
127
+ # given
128
+ deal.name = "The deal with an invalid value"
129
+
130
+ # when, then
131
+ expect {
132
+ deal.value = "Im not a number"
133
+ }.to raise_error(MoveToGo::InvalidValueError)
134
+ end
135
+
136
+ it "should set value if value is an integer" do
137
+ # given
138
+ deal.name = "The new deal"
139
+
140
+ # when
141
+ deal.value = "100"
142
+
143
+ # then
144
+ deal.value.should eq "100"
145
+ end
146
+
147
+ it "should treat . as thousand separator and remove it from the value" do
148
+ # given
149
+ deal.name = "Deal with . as thousand separator"
150
+
151
+ # when
152
+ deal.value = "100.10"
153
+
154
+ # then
155
+ deal.value.should eq "10010"
156
+ end
157
+
158
+ it "should tread , as thousand separator and remove it from the value" do
159
+ # given
160
+ deal.name = "Deal with , as thousand separator"
161
+
162
+ # when
163
+ deal.value = "100,10"
164
+
165
+ # then
166
+ deal.value = "10010"
167
+ end
168
+
169
+ it "should set value to 0 if value is nil" do
170
+ # given
171
+ deal.name = "The new deal"
172
+
173
+ # when
174
+ deal.value = nil
175
+
176
+ # then
177
+ deal.value.should eq "0"
178
+ end
179
+
180
+ it "should set status_reference from status_setting" do
181
+ # This case should be used when the status is defined in the rootmodel
182
+
183
+ # given
184
+ deal.name = "Deal with status from deal_status_setting"
185
+ deal_status_setting = MoveToGo::DealStatusSetting.new({:integration_id => "123", :label => "Driv"})
186
+
187
+ # when
188
+ deal.status = deal_status_setting
189
+
190
+ # then
191
+ deal.status.is_a?(MoveToGo::DealStatus).should eq true
192
+ deal.status.status_reference.is_a?(MoveToGo::DealStatusReference).should eq true
193
+ deal.status.status_reference.label.should eq "Driv"
194
+ deal.status.status_reference.integration_id.should eq "123"
195
+ end
196
+
197
+ it "should set status_reference from label and integrationid if status is a string" do
198
+ # This case should be used when the status is already defined
199
+ # in the appliation and is referenced by label
200
+
201
+ # given
202
+ deal.name = "Deal with status from label"
203
+
204
+ # when
205
+ deal.status = "Driv"
206
+
207
+ # then
208
+ deal.status.is_a?(MoveToGo::DealStatus).should eq true
209
+ deal.status.status_reference.is_a?(MoveToGo::DealStatusReference).should eq true
210
+ deal.status.status_reference.label.should eq "Driv"
211
+ deal.status.status_reference.integration_id.should eq "Driv"
212
+ end
213
+
214
+ it "should raise error if status reference cant be created" do
215
+ # given
216
+ deal.name = "Deal with failed status"
217
+
218
+ # when, then
219
+ expect {
220
+ deal.status = MoveToGo::DealStatus.new({:id => 123})
221
+ }.to raise_error(MoveToGo::InvalidDealStatusError)
222
+ end
223
+
224
+ it "will warn on validation if status is unknown" do
225
+ # given
226
+ deal.name = "Deal"
227
+ deal.status = "required status"
228
+
229
+ # when, then
230
+ deal.validate[1].length.should be > 0
231
+ end
232
+ end
@@ -0,0 +1,17 @@
1
+ require "spec_helper"
2
+ require 'move-to-go'
3
+
4
+ describe "DealStatusReference" do
5
+ let(:deal_status_reference){
6
+ MoveToGo::DealStatusReference.new
7
+ }
8
+
9
+ it "should fail on validation if name, id and integration_id is nil" do
10
+ # given
11
+ #deal_status_reference
12
+
13
+ # when, then
14
+ deal_status_reference.validate.length.should be > 0
15
+ end
16
+ end
17
+
@@ -0,0 +1,64 @@
1
+ require "spec_helper"
2
+ require 'move-to-go'
3
+
4
+ describe "Documents" do
5
+ let(:documents) {
6
+ MoveToGo::Documents.new
7
+ }
8
+
9
+ it "can add a new link" do
10
+ # given
11
+ link = MoveToGo::Link.new
12
+ link.integration_id = "123key"
13
+ link.url = "http://dropbox.com/files/readme.txt"
14
+
15
+ # when
16
+ documents.add_link link
17
+
18
+ # then
19
+ documents.find_link_by_integration_id("123key").url.should eq "http://dropbox.com/files/readme.txt"
20
+ documents.links.length.should eq 1
21
+ end
22
+
23
+ it "will not add a new link when a link with the same integration_id already exists" do
24
+ # given
25
+ documents.add_link({ :integration_id => "123", :url => "http://dropbox.com" })
26
+ documents.links.length.should eq 1
27
+
28
+ # when, then
29
+ expect {
30
+ documents.add_link({ :integration_id => "123", :url => "http://drive.google.com" })
31
+ }.to raise_error(MoveToGo::AlreadyAddedError)
32
+ documents.links.length.should eq 1
33
+ documents.find_link_by_integration_id("123").url.should eq "http://dropbox.com"
34
+ end
35
+
36
+ it "can add a new file" do
37
+ # given
38
+ file = MoveToGo::File.new
39
+ file.integration_id = "123key"
40
+ file.path = "k:\kontakt\databas\dokument"
41
+
42
+ # when
43
+ documents.add_file file
44
+
45
+ # then
46
+ documents.find_file_by_integration_id("123key").path.should eq "k:\kontakt\databas\dokument"
47
+ documents.files.length.should eq 1
48
+ end
49
+
50
+ it "will not add a new file with a file with the same integration_id already exists" do
51
+ # given
52
+ documents.add_file({ :integration_id => "123", :path => "c:\file-1.doc"})
53
+ documents.files.length.should eq 1
54
+
55
+ # when, then
56
+ expect {
57
+ documents.add_file({ :integration_id => "123", :path => "c:\file-2.doc"})
58
+ }.to raise_error(MoveToGo::AlreadyAddedError)
59
+ documents.files.length.should eq 1
60
+ documents.find_file_by_integration_id("123").path.should eq "c:\file-1.doc"
61
+ end
62
+
63
+ end
64
+