marley 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. data/README.rdoc +3 -8
  2. data/lib/marley.rb +27 -131
  3. data/lib/marley/controllers.rb +12 -7
  4. data/lib/marley/core_ext.rb +8 -0
  5. data/lib/marley/errors.rb +51 -0
  6. data/lib/marley/joint.rb +14 -19
  7. data/lib/marley/joints/forum.rb +88 -0
  8. data/lib/marley/joints/messages.rb +86 -0
  9. data/lib/marley/joints/section.rb +63 -0
  10. data/lib/marley/joints/tags.rb +99 -0
  11. data/lib/marley/joints/user.rb +120 -0
  12. data/lib/marley/plugin.rb +39 -0
  13. data/lib/marley/plugins/orm_rest_convenience.rb +92 -0
  14. data/lib/marley/plugins/rest_convenience.rb +28 -0
  15. data/lib/marley/reggae.rb +5 -2
  16. data/lib/marley/resources.rb +10 -0
  17. data/lib/marley/router.rb +61 -0
  18. data/lib/marley/test_helpers.rb +12 -1
  19. data/lib/marley/utils.rb +57 -25
  20. data/rdoc/example_joint.rb +33 -0
  21. data/rdoc/example_plugin.rb +20 -0
  22. data/rdoc/forum_joint.rb +50 -0
  23. data/rdoc/forum_joint.rdoc +19 -0
  24. data/rdoc/hello.rb +14 -0
  25. data/rdoc/hello.rdoc +14 -0
  26. data/rdoc/joints.rdoc +69 -0
  27. data/rdoc/messages_joint.rb +34 -0
  28. data/rdoc/messages_joint.rdoc +18 -0
  29. data/rdoc/messages_joint/private_messages.rdoc +59 -0
  30. data/rdoc/messages_joint/public_messages.rdoc +65 -0
  31. data/rdoc/orm_rest_convenience_plugin.rb +28 -0
  32. data/rdoc/orm_rest_convenience_plugin.rdoc +99 -0
  33. data/rdoc/plugins.rdoc +35 -0
  34. data/rdoc/reggae.rb +3 -0
  35. data/rdoc/reggae.rdoc +11 -0
  36. data/rdoc/reggae/generate.rdoc +13 -0
  37. data/rdoc/reggae/parse.rdoc +44 -0
  38. data/rdoc/section_joint.rb +13 -0
  39. data/rdoc/section_joint.rdoc +19 -0
  40. data/rdoc/tags_joint.rb +16 -0
  41. data/rdoc/tags_joint.rdoc +22 -0
  42. data/rdoc/tags_joint/announcements.rdoc +64 -0
  43. data/rdoc/tags_joint/secrets.rdoc +65 -0
  44. data/rdoc/user_joint.rb +62 -0
  45. data/rdoc/user_joint.rdoc +13 -0
  46. data/rdoc/user_joint/exiting_users.rdoc +120 -0
  47. data/rdoc/user_joint/no_auth_provided.rdoc +34 -0
  48. data/reggae.ebnf +1 -1
  49. metadata +45 -37
  50. data/Favicon.ico +0 -0
  51. data/Rakefile +0 -14
  52. data/TODO +0 -19
  53. data/examples/blog.rb +0 -26
  54. data/examples/empty.sqlite3 +0 -0
  55. data/examples/forum.css +0 -3
  56. data/examples/forum.js +0 -23
  57. data/examples/forum.rb +0 -20
  58. data/examples/forum.sql +0 -42
  59. data/examples/forum.sqlite3 +0 -0
  60. data/examples/forum_test.sqlite3 +0 -0
  61. data/examples/run.sh +0 -14
  62. data/lib/client/jamaica.css +0 -270
  63. data/lib/client/jamaica.js +0 -353
  64. data/lib/client/jamaica.rb +0 -38
  65. data/lib/client/jquery-1.6.2.js +0 -8981
  66. data/lib/client/jquery.form.js +0 -814
  67. data/lib/joints/basic_menu_system.rb +0 -41
  68. data/lib/joints/basic_messaging.rb +0 -88
  69. data/lib/joints/basic_user.rb +0 -51
  70. data/lib/joints/tagged_messaging.rb +0 -122
  71. data/lib/joints/tagging.rb +0 -56
  72. data/lib/sequel/plugins/rest_auth.rb +0 -53
  73. data/lib/sequel/plugins/rest_convenience.rb +0 -87
  74. data/marley-0.4.0.gem +0 -0
  75. data/marley.gemspec +0 -17
  76. data/test/empty.sqlite3 +0 -0
  77. data/test/menu_tests.rb +0 -9
  78. data/test/tagged_messaging_tests.rb +0 -289
  79. data/test/test.sqlite3 +0 -0
  80. data/test/test_include.rb +0 -16
  81. data/test/user_tests.rb +0 -72
data/marley-0.4.0.gem DELETED
Binary file
data/marley.gemspec DELETED
@@ -1,17 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = %q{marley}
5
- s.version = "0.5.0"
6
- s.summary = %q{Irie default restful routes for your models and other objects}
7
- s.description = %q{Marley implements a web services framework on top of Rack and Sequel on the server side and Jquery on the client side. }
8
- s.authors = ["Herb Daily"]
9
- s.email = 'herb.daily@safe-mail.net'
10
- s.homepage = 'http://github.com/herbdaily/marley'
11
- s.required_rubygems_version = Gem::Requirement.new(">= 1.0.0") if s.respond_to? :required_rubygems_version=
12
- s.add_runtime_dependency 'sequel', '~>3.27'
13
- s.add_runtime_dependency 'rack', '~>1.2.2'
14
- s.add_runtime_dependency 'json', '~>1.1.7'
15
- s.add_development_dependency 'tdoc', '~>0.12.1'
16
- s.files = Dir.glob(["*","lib/**/*","examples/**/*","test/**/*"])
17
- end
data/test/empty.sqlite3 DELETED
Binary file
data/test/menu_tests.rb DELETED
@@ -1,9 +0,0 @@
1
-
2
-
3
- class MenuTests < Test::Unit::TestCase
4
- def setup
5
- end
6
- should 'work' do
7
- assert true
8
- end
9
- end
@@ -1,289 +0,0 @@
1
-
2
- class MessageTests < Test::Unit::TestCase
3
- def initialize(*args)
4
- super
5
- MR::User.delete
6
- @client=Marley::TestClient.new(:resource_name => 'user')
7
- ['user1','user2','admin'].each do |un|
8
- MR::User.new(:name => un,:password => 'asdfasdf', :confirm_password => 'asdfasdf').save
9
- end
10
- MR::User[:name => 'admin'].update(:user_type => 'Admin')
11
- @admin_auth=['admin','asdfasdf']
12
- @user1_auth=['user1','asdfasdf']
13
- @user2_auth=['user2','asdfasdf']
14
- end
15
- def setup
16
- MR::Message.delete
17
- MR::Tag.delete
18
- DB[:messages_tags].delete
19
- end
20
- context "Private Messages" do
21
- setup do
22
- @client.resource_name='private_message'
23
- @pm=MR::PrivateMessage.new.to_a
24
- end
25
- context "regular user (user1) logged in" do
26
- setup do
27
- @client.auth=@user1_auth
28
- end
29
- should "show PM list and new PM form" do
30
- assert @client.read({})
31
- assert @client.read({}, :method => 'new')
32
- end
33
- should "validate new user generated PMs properly" do
34
- #reject a PM with only recipients
35
- @pm.col_value(:recipients, 'user2')
36
- resp=@client.create(@pm,{:code => 400})
37
- assert_equal :error, resp.resource_type
38
- assert_equal "validation", resp.error_type
39
- assert_equal ["is required"], resp.error_details[:title]
40
- assert_equal ["is required"], resp.error_details[:message]
41
- #reject a PM from user to user
42
- @pm.set_values({:title => 'asdf', :message => 'asdf'})
43
- resp=@client.create(@pm,{:code => 400})
44
- assert_equal :error, resp.resource_type
45
- assert_equal "validation", resp.error_type
46
- assert resp.error_details[:recipients][0]
47
- #reject a PM to a non-existent user
48
- @pm.col_value(:recipients, 'asdfasdfasdf')
49
- resp=@client.create(@pm,{:code => 400})
50
- assert_equal :error, resp.resource_type
51
- assert_equal "validation", resp.error_type
52
- assert resp.error_details[:recipients][0]
53
- #accept a PM to admin
54
- @pm.col_value(:recipients, 'admin')
55
- assert @client.create({:'private_message[recipients]' => 'admin',:'private_message[title]' => 'asdf',:'private_message[message]' => 'asdf'})
56
- end
57
- end
58
- context "admin logged in" do
59
- setup do
60
- @client.auth=@admin_auth
61
- end
62
- should "validate new admin generated PMs properly" do
63
- resp=@client.create(@pm.set_values(:recipients => 'user2'),{:code => 400})
64
- assert_equal :error, resp.resource_type
65
- assert_equal "validation", resp.error_type
66
- assert_equal ["is required"], resp.error_details[:title]
67
- assert_equal ["is required"], resp.error_details[:message]
68
- end
69
- should "accept a PM to user1" do
70
- assert @client.create(@pm.set_values(:'recipients' => 'user1',:'title' => 'asdf',:'message' => 'asdf'))
71
- end
72
- end
73
- context "message with no tags" do
74
- setup do
75
- @client.auth=@admin_auth
76
- @client.create(@pm.set_values({:'recipients' => 'user1',:'title' => 'asdf',:'message' => 'asdf'}))
77
- end
78
- should "show up in PM list of sender and receiver" do
79
- resp=@client.read({})
80
- assert_equal 1, resp.length
81
- resp=@client.read({},{:auth => @user1_auth})
82
- assert_equal 1, resp.length
83
- end
84
- should "have sent tag for sender" do
85
- resp=@client.read({})
86
- assert_equal 3, resp[0].length
87
- assert_equal "sent", resp.find_instances('user_tag')[0].schema[:tag].col_value
88
- end
89
- should "have inbox tag for receiver" do
90
- resp=@client.read({},{:auth => @user1_auth})
91
- assert_equal 3, resp[0].length
92
- assert_equal "inbox", resp.find_instances('user_tag')[0].schema[:tag].col_value
93
- end
94
- should "have reply, reply_all and new_tags instance get actions" do
95
- resp=@client.read({})
96
- assert_same_elements ['reply','reply_all','new_tags'], resp[0].actions[:get]
97
- end
98
- context "user1 instance actions" do
99
- setup do
100
- @client.auth=@user1_auth
101
- @msg=@client.read({})[0]
102
- @client.instance_id=@msg.schema[:id].col_value
103
- @reply=@client.read({},{:method => 'reply'})
104
- @new_tags=@client.read({},:method => 'new_tags')
105
- end
106
- context "reply" do
107
- should "have author in to field and default title beginning with 're:'" do
108
- assert_equal 'admin', @reply.schema[:recipients].col_value
109
- assert_equal 're: ', @reply.schema[:title].col_value[0 .. 3]
110
- end
111
- should "accept reply" do
112
- assert @client.create(@reply.set_values('message' => 'asdf'),{:method => nil,:instance_id => nil})
113
- end
114
- end
115
- context "new tags" do
116
- should "return tag instance with name tag and same url as original message" do
117
- assert_equal 'tags', @new_tags.name
118
- assert_equal "#{@msg.url}tags", @new_tags.url
119
- end
120
- should "accept new tags, which should then show up with the original message" do
121
- assert @client.create({'private_message[tags]' => 'added_tag1, added_tag2'},{:method => 'tags'})
122
- msg=@client.read({})
123
- user_tags=msg.find_instances('user_tag')
124
- assert_same_elements ["inbox", "added_tag1", "added_tag2"], user_tags.map{|t| t.schema[:tag].col_value}
125
- end
126
- end
127
- end
128
- end
129
- context "message with 2 tags" do
130
- setup do
131
- @client.auth=@admin_auth
132
- @client.create(@pm.set_values(:recipients => 'user1', :title => 'asdf', :message => 'asdf', :tags => 'test,test2'))
133
- end
134
- context "sender (admin) logged in" do
135
- setup do
136
- @msg=@client.read[0]
137
- @tags=@msg.find_instances('user_tag')
138
- end
139
- should "have sent tag and both specified tags for sender" do
140
- assert_same_elements ["sent", "test", "test2"], @tags.map{|t| t.schema[:tag].col_value}
141
- end
142
- should "allow sender to remove his own tags'" do
143
- assert_equal 'remove_parent', @tags[0].actions[:delete]
144
- assert @client.del({},{:url => @tags[0].url+@msg.url})
145
- assert_equal 2, @client.read[0].find_instances('user_tag').length
146
- end
147
- end
148
- context "receiver (user1)" do
149
- setup do
150
- @client.auth=@user1_auth
151
- @msg=@client.read[0]
152
- @tags=@msg.find_instances('user_tag')
153
- end
154
- should "have inbox tag and both specified tags" do
155
- assert_same_elements ["inbox", "test", "test2"], @tags.map{|t| t.schema[:tag].col_value}
156
- end
157
- should "have specified tags in reply" do
158
- reply=@client.read({},{:instance_id => @msg.schema[:id].col_value,:method => 'reply'})
159
- assert_equal 'test,test2', reply.schema[:tags].col_value
160
- end
161
- should "allow receiver to remove his own tags'" do
162
- assert_equal 'remove_parent', @tags[0].actions[:delete]
163
- assert @client.del({},{:url => @tags[0].url+@msg.url})
164
- assert_equal 2, @client.read[0].find_instances('user_tag').length
165
- end
166
- end
167
- context 'user2' do
168
- should "have no messages" do
169
- assert resp=@client.read({},{:auth => @user2_auth})
170
- assert_equal 0, resp.length
171
- end
172
- end
173
- end
174
- context "message with 2 tags and 2 receivers" do
175
- setup do
176
- @client.create(@pm.set_values(:recipients => 'user1,user2',:title => 'asdf',:message => 'asdf', :tags => 'test,test2'),{:auth => @admin_auth})
177
- end
178
- should "have sent tag and both specified for sender" do
179
- resp=@client.read({},{:auth => @admin_auth})
180
- user_tags=resp[0].find_instances('user_tag')
181
- assert_same_elements ["sent", "test", "test2"], user_tags.map{|t| t.schema[:tag].col_value}
182
- end
183
- should "have inbox tag and both specified for 1st receiver (user1)" do
184
- resp=@client.read({},{:auth => @user1_auth})
185
- user_tags=resp[0].find_instances('user_tag')
186
- assert_same_elements ["inbox", "test", "test2"], user_tags.map{|t| t.schema[:tag].col_value}
187
- end
188
- should "have inbox tag and both specified for 2st receiver (user2)" do
189
- resp=@client.read({},{:auth => @user2_auth})
190
- user_tags=resp[0].find_instances('user_tag')
191
- assert_same_elements ["inbox", "test", "test2"], user_tags.map{|t| t.schema[:tag].col_value}
192
- end
193
- end
194
- context "message listing" do
195
- setup do
196
- #3 messages with tag "test" for user 1
197
- @client.create(@pm.set_values(:'recipients' => 'user1',:'title' => 'title1',:'message' => 'body1', :'tags' => 'test'),{:auth => @admin_auth})
198
- @client.create(@pm.set_values(:'recipients' => 'user1',:'title' => 'title2',:'message' => 'body2', :'tags' => 'test'),{:auth => @admin_auth})
199
- @client.create(@pm.set_values(:'recipients' => 'user1',:'title' => 'title3',:'message' => 'body3', :'tags' => 'test'),{:auth => @admin_auth})
200
- #2 messages with tag "test1" for user1 and user2
201
- @client.create(@pm.set_values(:'recipients' => 'user2,user1',:'title' => 'title1',:'message' => 'body1', :'tags' => 'test1'),{:auth => @admin_auth})
202
- @client.create(@pm.set_values(:'recipients' => 'user2,user1',:'title' => 'title2',:'message' => 'body2', :'tags' => 'test1'),{:auth => @admin_auth})
203
- end
204
- should "for sender (admin) show 3 messages with 'test' tag,2 messages with 'test1' tag, and 5 messages with 'sent' tag" do
205
- @client.auth=@admin_auth
206
- assert_equal 3, @client.read({:'private_message[tags]' => 'test'}).length
207
- assert_equal 2, @client.read({:'private_message[tags]' => 'test1'}).length
208
- assert_equal 5, @client.read({:'private_message[tags]' => 'sent'}).length
209
- end
210
- should "for user1 show 3 messages with 'test' tag, 2 messages with 'test1' tag, 5 messages with 'inbox' tag, and 5 messages with 'test' or 'test1' tags" do
211
- @client.auth=@user1_auth
212
- assert_equal 3, @client.read({:'private_message[tags]' => 'test'}).length
213
- assert_equal 2, @client.read({:'private_message[tags]' => 'test1'}).length
214
- assert_equal 5, @client.read({:'private_message[tags]' => 'inbox'}).length
215
- assert_equal 5, @client.read({:'private_message[tags]' => 'test,test1'}).length
216
- end
217
- should "for user2 show 0 messages with 'test' tag, 2 messages with 'test1' tag, 2 messages with 'inbox' tag and 2 messages with 'test' or 'test1' tags" do
218
- @client.auth=@user2_auth
219
- assert_equal 0, @client.read({:'private_message[tags]' => 'test'}).length
220
- assert_equal 2, @client.read({:'private_message[tags]' => 'test1'}).length
221
- assert_equal 2, @client.read({:'private_message[tags]' => 'inbox'}).length
222
- assert_equal 2, @client.read({:'private_message[tags]' => 'test,test1'}).length
223
- end
224
- end
225
- end
226
- context "Posts" do
227
- setup do
228
- @client.resource_name='post'
229
- @post=MR::Post.new.to_a
230
- end
231
- context 'validation' do
232
- should "get a validation error trying to post without a title or message as admin, user1, or user2" do
233
- resp=@client.create({},{:code => 400,:auth => @admin_auth})
234
- assert_equal :error, resp.resource_type
235
- assert_equal "validation", resp.error_type
236
- assert_equal ["is required"], resp.error_details[:title]
237
- assert_equal ["is required"], resp.error_details[:message]
238
- user1_resp=@client.create({},{:code => 400,:auth => @user1_auth})
239
- assert_equal user1_resp, resp
240
- user2_resp=@client.create({},{:code => 400,:auth => @user2_auth})
241
- assert_equal user2_resp, resp
242
- end
243
- should "be able to post with title and message as admin, user1, or user2" do
244
- assert @client.create(@post.set_values('title' => 'test', 'message' => 'asdf'),{:auth => @admin_auth})
245
- assert_equal 1, @client.read({},{:auth => @user1_auth}).length
246
- assert @client.create(@post.set_values('title' => 'test', 'message' => 'asdf'),{:auth => @user1_auth})
247
- assert_equal 2, @client.read({},{:auth => @user2_auth}).length
248
- assert @client.create(@post.set_values('title' => 'test', 'message' => 'asdf'),{:auth => @user2_auth})
249
- assert_equal 3, @client.read({},{:auth => @admin_auth}).length
250
- end
251
- end
252
- should 'list posts by public tags' do
253
- @client.create(@post.set_values('title' => 'test', 'message' => 'asdf','tags' => 'admintag1,admintag2'),{:auth => @admin_auth})
254
- @client.create(@post.set_values('title' => 'test', 'message' => 'asdf','tags' => 'admintag1,admintag2,admintag3'),{:auth => @admin_auth})
255
- @client.create(@post.set_values('title' => 'test', 'message' => 'asdf','tags' => 'user1tag1'),{:auth => @user1_auth})
256
- @client.create(@post.set_values('title' => 'test', 'message' => 'asdf','tags' => 'user1tag1,user1tag2'),{:auth => @user1_auth})
257
- @client.create(@post.set_values('title' => 'test', 'message' => 'asdf','tags' => 'user1tag1,user1tag2,user1tag3'),{:auth => @user1_auth})
258
- @client.create(@post.set_values('title' => 'test', 'message' => 'asdf','tags' => 'user2tag1,user2tag2,user2tag3'),{:auth => @user2_auth})
259
- @client.create(@post.set_values('title' => 'test', 'message' => 'asdf','tags' => 'user2tag1,user2tag2,user2tag3,user2tag4'),{:auth => @user2_auth})
260
- assert_equal 7, @client.read({},{:auth => @admin_auth}).length
261
- assert_equal 7, @client.read({'post[title]' => 'test'},{:auth => @admin_auth}).length
262
- assert_equal 7, @client.read({'post[title]' => 'test'},{:auth => @user1_auth}).length
263
- assert_equal 7, @client.read({'post[title]' => 'test'},{:auth => @user2_auth}).length
264
- assert_equal 2, @client.read({'post[tags]' => 'admintag1'},{:auth => @admin_auth}).length
265
- assert_equal 2, @client.read({'post[tags]' => 'admintag1'},{:auth => @user1_auth}).length
266
- assert_equal 1, @client.read({'post[tags]' => 'admintag3'},{:auth => @user2_auth}).length
267
- assert_equal 1, @client.read({'post[tags]' => 'admintag3'},{:auth => @admin_auth}).length
268
- assert_equal 2, @client.read({'post[tags]' => 'user1tag2'},{:auth => @admin_auth}).length
269
- assert_equal 3, @client.read({'post[tags]' => 'user1tag1'},{:auth => @admin_auth}).length
270
- assert_equal 3, @client.read({'post[tags]' => 'user1tag1'},{:auth => @user2_auth}).length
271
- end
272
- should 'have usable reply, new_tags, and new_user_tags instance actions' do
273
- @client.create(@post.set_values('title' => 'test', 'message' => 'asdf','tags' => 'admintag1,admintag2'),{:auth => @admin_auth})
274
- @client.auth=@user2_auth
275
- posts=@client.read({})
276
- assert_same_elements ['reply','new_tags','new_user_tags'], posts[0].actions[:get]
277
- reply=@client.read({},{:instance_id => posts[0].schema[:id].col_value,:method => 'reply'})
278
- tags=@client.read({},{:instance_id => posts[0].schema[:id].col_value,:method => 'new_tags'})
279
- user_tags=@client.read({},{:instance_id => posts[0].schema[:id].col_value,:method => 'new_user_tags'})
280
- assert_equal 're: test', reply.schema[:title].col_value
281
- assert @client.create(reply.set_values('message' => 'asdf'),{:method => nil,:instance_id => nil})
282
- assert @client.create(tags.to_params.merge('post[tags]' => '1,2,3'),{:url => tags.url})
283
- assert_same_elements ['1','2','3','admintag1','admintag2'], @client.read[0].find_instances('public_tag').map{|t| t.schema[:tag].col_value}
284
- assert @client.create(user_tags.to_params.merge('post[user_tags]' => '4,5,6'),{:url => user_tags.url})
285
- assert_same_elements ['4','5','6'], @client.read[0].find_instances('user_tag').map{|t| t.schema[:tag].col_value}
286
- assert_equal [], @client.read({},{:auth => @user1_auth})[0].find_instances('user_tag').map{|t| t.schema[:tag].col_value}
287
- end
288
- end
289
- end
data/test/test.sqlite3 DELETED
Binary file
data/test/test_include.rb DELETED
@@ -1,16 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
- require 'sequel'
5
- require 'marley'
6
- require 'marley/test_helpers'
7
-
8
- `cp test/empty.sqlite3 test/test.sqlite3`
9
- DB=Sequel.sqlite("test/test.sqlite3")
10
-
11
- RESERVED_PM_TAGS=['inbox','sent']
12
- RESERVED_POST_TAGS=['announcement']
13
-
14
- Marley.joint 'tagged_messaging'
15
- Marley.joint 'basic_menu_system'
16
-
data/test/user_tests.rb DELETED
@@ -1,72 +0,0 @@
1
-
2
- class UserTests < Test::Unit::TestCase
3
- def setup
4
- MR::User.delete
5
- @client=Marley::TestClient.new(:resource_name => 'user',:code => 200)
6
- @user=@client.read({},:resource_name => '',:code => 200).navigation[1]
7
- end
8
- should "return login form with no params" do
9
- assert @client.read({},{:resource_name => ''})
10
- end
11
- should "not allow access to menus, private messages, or posts" do
12
- @client.code=401
13
- assert @client.read({:resource_name =>'pm_menu'})
14
- assert @client.read({:resource_name =>'post_menu'})
15
- assert @client.read({:resource_name =>'private_message'})
16
- assert @client.read({:resource_name =>'post'})
17
- end
18
- should "validate new user properly" do
19
- @client.code=400
20
- resp=@client.create(@user)
21
- assert_equal :error, resp.resource_type
22
- assert_equal "validation", resp.error_type
23
- assert_equal ["is required"], resp.error_details[:name]
24
- @user.col_value(:name,'asdf')
25
- resp=@client.create(@user)
26
- assert_equal :error, resp.resource_type
27
- assert_equal "validation", resp.error_type
28
- @user.col_value(:password,'asdfaf')
29
- resp=@client.create(@user)
30
- assert_equal :error, resp.resource_type
31
- assert_equal "validation", resp.error_type
32
- assert_equal ["Password must contain at least 8 characters"], resp.error_details[:password]
33
- @user.col_value(:password,'asdfaasdf')
34
- resp=@client.create(@user)
35
- assert_equal :error, resp.resource_type
36
- assert_equal "validation", resp.error_type
37
- assert_equal ["Passwords do not match"], resp.error_details[:confirm_password]
38
- @user.col_value(:confirm_password,'asdfaasdf')
39
- assert @client.create(@user,{:code => 201})
40
- assert @client.create(@user)
41
- end
42
- context "existing user logged in" do
43
- setup do
44
- @client.code=201
45
- assert @client.create({:'user[name]' => 'user1',:'user[password]' => 'asdfasdf',:'user[confirm_password]' => 'asdfasdf'})
46
- assert @client.create(:'user[name]' => 'user2',:'user[password]' => 'asdfasdf',:'user[confirm_password]' => 'asdfasdf')
47
- @client.code=200
48
- @client.auth=['user1','asdfasdf']
49
- end
50
- should "show correct menu items" do
51
- menu= @client.read({},:resource_name => '')
52
- assert_same_elements ["User Info","Private Messages","Public Posts"], menu.navigation.map{|n| n.title}
53
- end
54
- should "allow viewing and changing of user columns with proper validation" do
55
- @client.instance_id=1
56
- assert user=@client.read({})
57
- assert @client.update(user,{:code => 204})
58
- user.col_value(:password, 'zxcvzxcv')
59
- assert err=@client.update(user,{:code => 400})
60
- assert_equal :error, err.resource_type
61
- assert_equal "validation", err.error_type
62
- user.col_value(:confirm_password, 'zxcvzxcv')
63
- user.col_value(:old_password, 'asdfasdf')
64
- assert @client.update(user,:code => 204)
65
- assert @client.read({},:code => 401)
66
- @client.auth=['user1','zxcvzxcv']
67
- assert @client.read({})
68
- @client.instance_id=2
69
- assert @client.update(user,:code => 403)
70
- end
71
- end
72
- end