marley 0.1.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.
- data/Favicon.ico +0 -0
- data/README.rdoc +51 -0
- data/TODO +17 -0
- data/examples/empty.sqlite3 +0 -0
- data/examples/forum.css +3 -0
- data/examples/forum.js +23 -0
- data/examples/forum.rb +20 -0
- data/examples/forum.sql +42 -0
- data/examples/forum.sqlite3 +0 -0
- data/examples/forum_test.sqlite3 +0 -0
- data/examples/run.sh +14 -0
- data/lib/client/jamaica.css +270 -0
- data/lib/client/jamaica.js +353 -0
- data/lib/client/jamaica.rb +38 -0
- data/lib/client/jquery-1.6.2.js +8981 -0
- data/lib/client/jquery.form.js +814 -0
- data/lib/controllers.rb +69 -0
- data/lib/joint.rb +27 -0
- data/lib/joints/basic_menu_system.rb +54 -0
- data/lib/joints/basic_messaging.rb +88 -0
- data/lib/joints/basic_user.rb +51 -0
- data/lib/joints/tagged_messaging.rb +122 -0
- data/lib/joints/tagging.rb +60 -0
- data/lib/joints/user_based_navigation.rb +39 -0
- data/lib/marley.rb +148 -0
- data/lib/reggae.rb +110 -0
- data/lib/sequel_plugins.rb +141 -0
- data/lib/test_helpers.rb +52 -0
- data/marley-0.1.gem +0 -0
- data/marley.gemspec +16 -0
- data/reggae.ebnf +60 -0
- data/test/forum_tests.rb +356 -0
- metadata +116 -0
data/marley-0.1.gem
ADDED
Binary file
|
data/marley.gemspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{marley}
|
5
|
+
s.version = "0.1.0"
|
6
|
+
s.summary = %q{Irie default restful routes for your models and other objects}
|
7
|
+
s.description = %q{Marley implements a web services microframework 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.files = Dir.glob(["*","lib/**/*","examples/**/*","test/**/*"])
|
16
|
+
end
|
data/reggae.ebnf
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
|
2
|
+
reggae ::= '[' resource (',' resource)* ']'
|
3
|
+
|
4
|
+
resource ::= '[' resource_type ',' '{' properties '}' (',' resource)* ']'
|
5
|
+
|
6
|
+
resource_type ::= 'section' | 'link' | 'instance' |'instance_list' | 'msg' | 'error'
|
7
|
+
|
8
|
+
properties ::= '{' property ':' value (',' property ':' value)* '}'
|
9
|
+
|
10
|
+
property ::= section_property | link_property | instance_property |instance_list_property | msg_property | error_property
|
11
|
+
|
12
|
+
value ::= title_value | description_value | navigation_value | name_value | new_rec_value | search_value | schema_value | get_actions_value | delete_action_value | items_value | col_value | error_type_value | error_details_value |
|
13
|
+
|
14
|
+
section_property ::= 'title' | 'description' | 'navigation'
|
15
|
+
|
16
|
+
link_property ::= 'title' | 'description' | 'url'
|
17
|
+
|
18
|
+
instance_property ::= 'name' | 'url' | 'new_rec' | 'search' | 'schema' | 'get_actions' | 'delete_action'
|
19
|
+
|
20
|
+
instance_list_property ::='title' | 'description' | 'schema' | 'get_actions' | 'delete_action' | 'items'
|
21
|
+
|
22
|
+
msg_property ::= 'title' | 'description'
|
23
|
+
|
24
|
+
error_property ::= 'error_type' | 'description' | 'error_details'
|
25
|
+
|
26
|
+
title_value ::= string_literal
|
27
|
+
|
28
|
+
description_value ::= string_literal
|
29
|
+
|
30
|
+
navigation_value ::= '[' (resource)? (',' resource)* ']'
|
31
|
+
|
32
|
+
name_value ::= string_literal
|
33
|
+
|
34
|
+
new_rec_value ::= boolean_value
|
35
|
+
|
36
|
+
search_value ::= boolean_value
|
37
|
+
|
38
|
+
schema_value ::= '[' col_spec (',' colspec)? ']'
|
39
|
+
|
40
|
+
items_value ::= '[' '[' col_value (',' col_value)* ']' (',' '[' col_value (',' col_value)* ']')* ']'
|
41
|
+
|
42
|
+
get_actions_value ::= '[' action (',' action)*']'
|
43
|
+
|
44
|
+
action ::= string_value
|
45
|
+
|
46
|
+
delete_action_value ::= 'remove_parent' | 'deactivate' | 'delete'
|
47
|
+
|
48
|
+
col_spec ::= '[' col_type ',' col_name ',' col_restrictions (',' col_value)? ']'
|
49
|
+
|
50
|
+
col_type ::= 'text' | 'clob' | 'integer' | 'decimal' | 'image'
|
51
|
+
|
52
|
+
col_name ::= string_literal
|
53
|
+
|
54
|
+
col_restrictions ::= [1-7]
|
55
|
+
|
56
|
+
col_value ::= string_literal
|
57
|
+
|
58
|
+
error_type_value ::= 'validation'
|
59
|
+
|
60
|
+
error_details_value ::= '{' col_name ':' msg '}'
|
data/test/forum_tests.rb
ADDED
@@ -0,0 +1,356 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'shoulda'
|
4
|
+
EXAMPLES_DIR=File.dirname(__FILE__) + '/../examples'
|
5
|
+
|
6
|
+
ENV['MARLEY_TESTING']='true'
|
7
|
+
`cp #{EXAMPLES_DIR}/empty.sqlite3 #{EXAMPLES_DIR}/forum_test.sqlite3`
|
8
|
+
require "#{EXAMPLES_DIR}/forum.rb"
|
9
|
+
require "#{EXAMPLES_DIR}/../lib/test_helpers"
|
10
|
+
|
11
|
+
class UserTests < Test::Unit::TestCase
|
12
|
+
def setup
|
13
|
+
Marley::Resources::User.delete
|
14
|
+
@client=Marley::TestClient.new(:resource_name => 'user',:code => 400)
|
15
|
+
end
|
16
|
+
should "return login form with no params" do
|
17
|
+
assert @client.read({},{:resource_name => '',:code => 200})
|
18
|
+
end
|
19
|
+
should "not allow access to menus, private messages, or posts" do
|
20
|
+
assert @client.read({:resource_name =>'pm_menu'},{:code => 401})
|
21
|
+
assert @client.read({:resource_name =>'post_menu'},{:code => 401})
|
22
|
+
assert @client.read({:resource_name =>'private_message'},{:code => 401})
|
23
|
+
assert @client.read({:resource_name =>'post'},{:code => 401})
|
24
|
+
end
|
25
|
+
should "validate new user properly" do
|
26
|
+
assert resp=@client.create
|
27
|
+
assert_equal "error", resp.resource_type
|
28
|
+
assert_equal "validation", resp.error_type
|
29
|
+
assert_equal ["is required"], resp.error_details[:name]
|
30
|
+
resp=@client.create({:'user[name]' => 'asdf'})
|
31
|
+
assert_equal "error", resp.resource_type
|
32
|
+
assert_equal "validation", resp.error_type
|
33
|
+
resp=@client.create({:'user[name]' => 'asdf',:'user[password]' => 'asdfaf'})
|
34
|
+
assert_equal "error", resp.resource_type
|
35
|
+
assert_equal "validation", resp.error_type
|
36
|
+
assert_equal ["Password must contain at least 8 characters"], resp.error_details[:password]
|
37
|
+
resp=@client.create(:'user[name]' => 'asdf',:'user[password]' => 'asdfasdf')
|
38
|
+
assert_equal "error", resp.resource_type
|
39
|
+
assert_equal "validation", resp.error_type
|
40
|
+
assert_equal ["Passwords do not match"], resp.error_details[:confirm_password]
|
41
|
+
end
|
42
|
+
should "allow creation of a new user and disallow user with the same name" do
|
43
|
+
@client.code=200
|
44
|
+
@client.create(:'user[name]' => 'asdf',:'user[password]' => 'asdfasdf',:'user[confirm_password]' => 'asdfasdf')
|
45
|
+
assert @client.create({:'user[name]' => 'asdf',:'user[password]' => 'asdfasdf',:'user[confirm_password]' => 'asdfasdf'},{:code => 400})
|
46
|
+
end
|
47
|
+
context "existing user logged in" do
|
48
|
+
setup do
|
49
|
+
@client.code=201
|
50
|
+
assert @client.create(:'user[name]' => 'user1',:'user[password]' => 'asdfasdf',:'user[confirm_password]' => 'asdfasdf')
|
51
|
+
assert @client.create(:'user[name]' => 'user2',:'user[password]' => 'asdfasdf',:'user[confirm_password]' => 'asdfasdf')
|
52
|
+
@client.code=200
|
53
|
+
@client.auth=['user1','asdfasdf']
|
54
|
+
end
|
55
|
+
should "show menus" do
|
56
|
+
menu= @client.read({},:resource_name => '')
|
57
|
+
assert_same_elements ["User Info", "Private Messages", "Public Posts"], menu.navigation.map{|n| n.title}
|
58
|
+
assert @client.read({},:resource_name => 'private_message/section')
|
59
|
+
assert @client.read({},:resource_name => 'post/section')
|
60
|
+
end
|
61
|
+
should "allow viewing and changing of user columns with proper validation" do
|
62
|
+
@client.instance_id=1
|
63
|
+
assert user=@client.read({})
|
64
|
+
params=user.to_params
|
65
|
+
assert @client.update(params,{:code => 204})
|
66
|
+
assert err=@client.update(params.update('user[password]' => 'zxcvzxcv'),{:code => 400})
|
67
|
+
assert_equal "error", err.resource_type
|
68
|
+
assert_equal "validation", err.error_type
|
69
|
+
assert @client.update(params.update('user[password]' => 'zxcvzxcv','user[confirm_password]' => 'zxcvzxcv', 'user[old_password]' => 'asdfasdf'),:code => 204)
|
70
|
+
assert @client.read({},:code => 401)
|
71
|
+
@client.auth=['user1','zxcvzxcv']
|
72
|
+
assert @client.read({})
|
73
|
+
@client.instance_id=2
|
74
|
+
assert @client.update(params.update('user[password]' => 'zxcvzxcv','user[confirm_password]' => 'zxcvzxcv', 'user[old_password]' => 'asdfasdf'),:code => 403)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
class MessageTests < Test::Unit::TestCase
|
79
|
+
def setup
|
80
|
+
Marley::Resources::User.delete
|
81
|
+
Marley::Resources::Message.delete
|
82
|
+
Marley::Resources::Tag.delete
|
83
|
+
DB[:messages_tags].delete
|
84
|
+
@client=Marley::TestClient.new(:resource_name => 'user')
|
85
|
+
@client.create(:'user[name]' => 'user1',:'user[password]' => 'asdfasdf',:'user[confirm_password]' => 'asdfasdf')
|
86
|
+
@client.create(:'user[name]' => 'user2',:'user[password]' => 'asdfasdf',:'user[confirm_password]' => 'asdfasdf')
|
87
|
+
@client.create(:'user[name]' => 'admin',:'user[password]' => 'asdfasdf',:'user[confirm_password]' => 'asdfasdf')
|
88
|
+
@admin_auth=['admin','asdfasdf']
|
89
|
+
@user1_auth=['user1','asdfasdf']
|
90
|
+
@user2_auth=['user2','asdfasdf']
|
91
|
+
Marley::Resources::User[:name => 'admin'].update(:user_type => 'Admin')
|
92
|
+
end
|
93
|
+
context "Private Messages" do
|
94
|
+
setup do
|
95
|
+
@client.resource_name='private_message'
|
96
|
+
end
|
97
|
+
context "regular user (user1) logged in" do
|
98
|
+
setup do
|
99
|
+
@client.auth=@user1_auth
|
100
|
+
end
|
101
|
+
should "show PM list" do
|
102
|
+
assert @client.read({})
|
103
|
+
end
|
104
|
+
should "validate new user generated PMs properly" do
|
105
|
+
#reject a PM with only recipients
|
106
|
+
resp=@client.create({:'private_message[recipients]' => 'user2'},{:code => 400})
|
107
|
+
assert_equal "error", resp.resource_type
|
108
|
+
assert_equal "validation", resp.error_type
|
109
|
+
assert_equal ["is required"], resp.error_details[:title]
|
110
|
+
assert_equal ["is required"], resp.error_details[:message]
|
111
|
+
#reject a PM to a non-existent user
|
112
|
+
resp=@client.create({:'private_message[recipients]' => 'asdfasdfasdfasdf',:'private_message[title]' => 'asdf',:'private_message[message]' => 'asdf'},{:code => 400})
|
113
|
+
assert_equal "error", resp.resource_type
|
114
|
+
assert_equal "validation", resp.error_type
|
115
|
+
assert resp.error_details[:recipients][0]
|
116
|
+
#reject a PM from user to user
|
117
|
+
resp=@client.create({:'private_message[recipients]' => 'user2',:'private_message[title]' => 'asdf',:'private_message[message]' => 'asdf'},{:code => 400})
|
118
|
+
assert_equal "error", resp.resource_type
|
119
|
+
assert_equal "validation", resp.error_type
|
120
|
+
assert resp.error_details[:recipients][0]
|
121
|
+
end
|
122
|
+
should "accept a PM to admin" do
|
123
|
+
assert @client.create({:'private_message[recipients]' => 'admin',:'private_message[title]' => 'asdf',:'private_message[message]' => 'asdf'})
|
124
|
+
end
|
125
|
+
end
|
126
|
+
context "admin logged in" do
|
127
|
+
setup do
|
128
|
+
@client.auth=@admin_auth
|
129
|
+
end
|
130
|
+
should "validate new admin generated PMs properly" do
|
131
|
+
resp=@client.create({:'private_message[recipients]' => 'user2'},{:code => 400})
|
132
|
+
assert_equal "error", resp.resource_type
|
133
|
+
assert_equal "validation", resp.error_type
|
134
|
+
assert_equal ["is required"], resp.error_details[:title]
|
135
|
+
assert_equal ["is required"], resp.error_details[:message]
|
136
|
+
end
|
137
|
+
should "accept a PM to user1" do
|
138
|
+
assert @client.create({:'private_message[recipients]' => 'user1',:'private_message[title]' => 'asdf',:'private_message[message]' => 'asdf'})
|
139
|
+
end
|
140
|
+
end
|
141
|
+
context "message with no tags" do
|
142
|
+
setup do
|
143
|
+
@client.auth=@admin_auth
|
144
|
+
@client.create({:'private_message[recipients]' => 'user1',:'private_message[title]' => 'asdf',:'private_message[message]' => 'asdf'})
|
145
|
+
end
|
146
|
+
should "show up in PM list of sender and receiver" do
|
147
|
+
resp=@client.read({})
|
148
|
+
assert_equal 1, resp.length
|
149
|
+
resp=@client.read({},{:auth => @user1_auth})
|
150
|
+
assert_equal 1, resp.length
|
151
|
+
end
|
152
|
+
should "have sent tag for sender" do
|
153
|
+
resp=@client.read({})
|
154
|
+
assert_equal 3, resp[0].length
|
155
|
+
assert_equal "sent", resp.find_instances('user_tag')[0].schema[:tag].col_value
|
156
|
+
end
|
157
|
+
should "have inbox tag for receiver" do
|
158
|
+
resp=@client.read({},{:auth => @user1_auth})
|
159
|
+
assert_equal 3, resp[0].length
|
160
|
+
assert_equal "inbox", resp.find_instances('user_tag')[0].schema[:tag].col_value
|
161
|
+
end
|
162
|
+
should "have reply, reply_all and new_tags instance get actions" do
|
163
|
+
resp=@client.read({})
|
164
|
+
assert_same_elements ['reply','reply_all','new_tags'], resp[0].get_actions
|
165
|
+
end
|
166
|
+
context "user1 instance actions" do
|
167
|
+
setup do
|
168
|
+
@client.auth=@user1_auth
|
169
|
+
@msg=@client.read({})[0]
|
170
|
+
@client.instance_id=@msg.schema[:id].col_value
|
171
|
+
@reply=@client.read({},{:method => 'reply'})
|
172
|
+
@new_tags=@client.read({},:method => 'new_tags')
|
173
|
+
end
|
174
|
+
context "reply" do
|
175
|
+
should "have author in to field and default title beginning with 're:'" do
|
176
|
+
assert_equal 'admin', @reply.schema[:recipients].col_value
|
177
|
+
assert_equal 're: ', @reply.schema[:title].col_value[0 .. 3]
|
178
|
+
end
|
179
|
+
should "accept reply" do
|
180
|
+
assert @client.create(@reply.to_params.merge('private_message[message]' => 'asdf'),{:method => nil,:instance_id => nil})
|
181
|
+
end
|
182
|
+
end
|
183
|
+
context "new tags" do
|
184
|
+
should "return tag instance with name tag and same url as original message" do
|
185
|
+
assert_equal 'tags', @new_tags.name
|
186
|
+
assert_equal "#{@msg.url}tags", @new_tags.url
|
187
|
+
end
|
188
|
+
should "accept new tags, which should then show up with the original message" do
|
189
|
+
assert @client.create({'private_message[tags]' => 'added_tag1, added_tag2'},{:method => 'tags'})
|
190
|
+
msg=@client.read({})
|
191
|
+
user_tags=msg.find_instances('user_tag')
|
192
|
+
assert_same_elements ["inbox", "added_tag1", "added_tag2"], user_tags.map{|t| t.schema[:tag].col_value}
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
context "message with 2 tags" do
|
198
|
+
setup do
|
199
|
+
@client.auth=@admin_auth
|
200
|
+
@client.create({:'private_message[recipients]' => 'user1',:'private_message[title]' => 'asdf',:'private_message[message]' => 'asdf', :'private_message[tags]' => 'test,test2'})
|
201
|
+
end
|
202
|
+
context "sender (admin) logged in" do
|
203
|
+
setup do
|
204
|
+
@msg=@client.read[0]
|
205
|
+
@tags=@msg.find_instances('user_tag')
|
206
|
+
end
|
207
|
+
should "have sent tag and both specified tags for sender" do
|
208
|
+
assert_same_elements ["sent", "test", "test2"], @tags.map{|t| t.schema[:tag].col_value}
|
209
|
+
end
|
210
|
+
should "allow sender to remove his own tags'" do
|
211
|
+
assert_equal 'remove_parent', @tags[0].delete_action
|
212
|
+
assert @client.del({},{:url => @tags[0].url+@msg.url})
|
213
|
+
assert_equal 2, @client.read[0].find_instances('user_tag').length
|
214
|
+
end
|
215
|
+
end
|
216
|
+
context "receiver (user1)" do
|
217
|
+
setup do
|
218
|
+
@client.auth=@user1_auth
|
219
|
+
@msg=@client.read[0]
|
220
|
+
@tags=@msg.find_instances('user_tag')
|
221
|
+
end
|
222
|
+
should "have inbox tag and both specified tags" do
|
223
|
+
assert_same_elements ["inbox", "test", "test2"], @tags.map{|t| t.schema[:tag].col_value}
|
224
|
+
end
|
225
|
+
should "have specified tags in reply" do
|
226
|
+
reply=@client.read({},{:instance_id => @msg.schema[:id].col_value,:method => 'reply'})
|
227
|
+
assert_equal 'test,test2', reply.schema[:tags].col_value
|
228
|
+
end
|
229
|
+
should "allow receiver to remove his own tags'" do
|
230
|
+
assert_equal 'remove_parent', @tags[0].delete_action
|
231
|
+
assert @client.del({},{:url => @tags[0].url+@msg.url})
|
232
|
+
assert_equal 2, @client.read[0].find_instances('user_tag').length
|
233
|
+
end
|
234
|
+
end
|
235
|
+
context 'user2' do
|
236
|
+
should "have no messages" do
|
237
|
+
assert resp=@client.read({},{:auth => @user2_auth})
|
238
|
+
assert_equal 0, resp.length
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
context "message with 2 tags and 2 receivers" do
|
243
|
+
setup do
|
244
|
+
@client.create({:'private_message[recipients]' => 'user1,user2',:'private_message[title]' => 'asdf',:'private_message[message]' => 'asdf', :'private_message[tags]' => 'test,test2'},{:auth => @admin_auth})
|
245
|
+
end
|
246
|
+
should "have sent tag and both specified for sender" do
|
247
|
+
resp=@client.read({},{:auth => @admin_auth})
|
248
|
+
user_tags=resp[0].find_instances('user_tag')
|
249
|
+
assert_same_elements ["sent", "test", "test2"], user_tags.map{|t| t.schema[:tag].col_value}
|
250
|
+
end
|
251
|
+
should "have inbox tag and both specified for 1st receiver (user1)" do
|
252
|
+
resp=@client.read({},{:auth => @user1_auth})
|
253
|
+
user_tags=resp[0].find_instances('user_tag')
|
254
|
+
assert_same_elements ["inbox", "test", "test2"], user_tags.map{|t| t.schema[:tag].col_value}
|
255
|
+
end
|
256
|
+
should "have inbox tag and both specified for 2st receiver (user2)" do
|
257
|
+
resp=@client.read({},{:auth => @user2_auth})
|
258
|
+
user_tags=resp[0].find_instances('user_tag')
|
259
|
+
assert_same_elements ["inbox", "test", "test2"], user_tags.map{|t| t.schema[:tag].col_value}
|
260
|
+
end
|
261
|
+
end
|
262
|
+
context "message listing" do
|
263
|
+
setup do
|
264
|
+
#3 messages with tag "test" for user 1
|
265
|
+
@client.create({:'private_message[recipients]' => 'user1',:'private_message[title]' => 'title1',:'private_message[message]' => 'body1', :'private_message[tags]' => 'test'},{:auth => @admin_auth})
|
266
|
+
@client.create({:'private_message[recipients]' => 'user1',:'private_message[title]' => 'title2',:'private_message[message]' => 'body2', :'private_message[tags]' => 'test'},{:auth => @admin_auth})
|
267
|
+
@client.create({:'private_message[recipients]' => 'user1',:'private_message[title]' => 'title3',:'private_message[message]' => 'body3', :'private_message[tags]' => 'test'},{:auth => @admin_auth})
|
268
|
+
#2 messages with tag "test1" for user1 and user2
|
269
|
+
@client.create({:'private_message[recipients]' => 'user2,user1',:'private_message[title]' => 'title1',:'private_message[message]' => 'body1', :'private_message[tags]' => 'test1'},{:auth => @admin_auth})
|
270
|
+
@client.create({:'private_message[recipients]' => 'user2,user1',:'private_message[title]' => 'title2',:'private_message[message]' => 'body2', :'private_message[tags]' => 'test1'},{:auth => @admin_auth})
|
271
|
+
end
|
272
|
+
should "for sender (admin) show 3 messages with 'test' tag,2 messages with 'test1' tag, and 5 messages with 'sent' tag" do
|
273
|
+
@client.auth=@admin_auth
|
274
|
+
assert_equal 3, @client.read({:'private_message[tags]' => 'test'}).length
|
275
|
+
assert_equal 2, @client.read({:'private_message[tags]' => 'test1'}).length
|
276
|
+
assert_equal 5, @client.read({:'private_message[tags]' => 'sent'}).length
|
277
|
+
end
|
278
|
+
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
|
279
|
+
@client.auth=@user1_auth
|
280
|
+
assert_equal 3, @client.read({:'private_message[tags]' => 'test'}).length
|
281
|
+
assert_equal 2, @client.read({:'private_message[tags]' => 'test1'}).length
|
282
|
+
assert_equal 5, @client.read({:'private_message[tags]' => 'inbox'}).length
|
283
|
+
assert_equal 5, @client.read({:'private_message[tags]' => 'test,test1'}).length
|
284
|
+
end
|
285
|
+
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
|
286
|
+
@client.auth=@user2_auth
|
287
|
+
assert_equal 0, @client.read({:'private_message[tags]' => 'test'}).length
|
288
|
+
assert_equal 2, @client.read({:'private_message[tags]' => 'test1'}).length
|
289
|
+
assert_equal 2, @client.read({:'private_message[tags]' => 'inbox'}).length
|
290
|
+
assert_equal 2, @client.read({:'private_message[tags]' => 'test,test1'}).length
|
291
|
+
end
|
292
|
+
end
|
293
|
+
end
|
294
|
+
context "Posts" do
|
295
|
+
setup do
|
296
|
+
@client.resource_name='post'
|
297
|
+
end
|
298
|
+
context 'validation' do
|
299
|
+
should "get a validation error trying to post without a title or message as admin, user1, or user2" do
|
300
|
+
resp=@client.create({},{:code => 400,:auth => @admin_auth})
|
301
|
+
assert_equal "error", resp.resource_type
|
302
|
+
assert_equal "validation", resp.error_type
|
303
|
+
assert_equal ["is required"], resp.error_details[:title]
|
304
|
+
assert_equal ["is required"], resp.error_details[:message]
|
305
|
+
user1_resp=@client.create({},{:code => 400,:auth => @user1_auth})
|
306
|
+
assert_equal user1_resp, resp
|
307
|
+
user2_resp=@client.create({},{:code => 400,:auth => @user2_auth})
|
308
|
+
assert_equal user2_resp, resp
|
309
|
+
end
|
310
|
+
should "be able to post with title and message as admin, user1, or user2" do
|
311
|
+
assert @client.create({'post[title]' => 'test', 'post[message]' => 'asdf'},{:auth => @admin_auth})
|
312
|
+
assert_equal 1, @client.read({},{:auth => @user1_auth}).length
|
313
|
+
assert @client.create({'post[title]' => 'test', 'post[message]' => 'asdf'},{:auth => @user1_auth})
|
314
|
+
assert_equal 2, @client.read({},{:auth => @user2_auth}).length
|
315
|
+
assert @client.create({'post[title]' => 'test', 'post[message]' => 'asdf'},{:auth => @user2_auth})
|
316
|
+
assert_equal 3, @client.read({},{:auth => @admin_auth}).length
|
317
|
+
end
|
318
|
+
end
|
319
|
+
should 'list posts by public tags' do
|
320
|
+
@client.create({'post[title]' => 'test', 'post[message]' => 'asdf','post[tags]' => 'admintag1,admintag2'},{:auth => @admin_auth})
|
321
|
+
@client.create({'post[title]' => 'test', 'post[message]' => 'asdf','post[tags]' => 'admintag1,admintag2,admintag3'},{:auth => @admin_auth})
|
322
|
+
@client.create({'post[title]' => 'test', 'post[message]' => 'asdf','post[tags]' => 'user1tag1'},{:auth => @user1_auth})
|
323
|
+
@client.create({'post[title]' => 'test', 'post[message]' => 'asdf','post[tags]' => 'user1tag1,user1tag2'},{:auth => @user1_auth})
|
324
|
+
@client.create({'post[title]' => 'test', 'post[message]' => 'asdf','post[tags]' => 'user1tag1,user1tag2,user1tag3'},{:auth => @user1_auth})
|
325
|
+
@client.create({'post[title]' => 'test', 'post[message]' => 'asdf','post[tags]' => 'user2tag1,user2tag2,user2tag3'},{:auth => @user2_auth})
|
326
|
+
@client.create({'post[title]' => 'test', 'post[message]' => 'asdf','post[tags]' => 'user2tag1,user2tag2,user2tag3,user2tag4'},{:auth => @user2_auth})
|
327
|
+
assert_equal 7, @client.read({},{:auth => @admin_auth}).length
|
328
|
+
assert_equal 7, @client.read({'post[title]' => 'test'},{:auth => @admin_auth}).length
|
329
|
+
assert_equal 7, @client.read({'post[title]' => 'test'},{:auth => @user1_auth}).length
|
330
|
+
assert_equal 7, @client.read({'post[title]' => 'test'},{:auth => @user2_auth}).length
|
331
|
+
assert_equal 2, @client.read({'post[tags]' => 'admintag1'},{:auth => @admin_auth}).length
|
332
|
+
assert_equal 2, @client.read({'post[tags]' => 'admintag1'},{:auth => @user1_auth}).length
|
333
|
+
assert_equal 1, @client.read({'post[tags]' => 'admintag3'},{:auth => @user2_auth}).length
|
334
|
+
assert_equal 1, @client.read({'post[tags]' => 'admintag3'},{:auth => @admin_auth}).length
|
335
|
+
assert_equal 2, @client.read({'post[tags]' => 'user1tag2'},{:auth => @admin_auth}).length
|
336
|
+
assert_equal 3, @client.read({'post[tags]' => 'user1tag1'},{:auth => @admin_auth}).length
|
337
|
+
assert_equal 3, @client.read({'post[tags]' => 'user1tag1'},{:auth => @user2_auth}).length
|
338
|
+
end
|
339
|
+
should 'have usable reply, new_tags, and new_user_tags instance actions' do
|
340
|
+
@client.create({'post[title]' => 'test', 'post[message]' => 'asdf','post[tags]' => 'admintag1,admintag2'},{:auth => @admin_auth})
|
341
|
+
@client.auth=@user2_auth
|
342
|
+
posts=@client.read({})
|
343
|
+
assert_same_elements ['reply','new_tags','new_user_tags'], posts[0].get_actions
|
344
|
+
reply=@client.read({},{:instance_id => posts[0].schema[:id].col_value,:method => 'reply'})
|
345
|
+
tags=@client.read({},{:instance_id => posts[0].schema[:id].col_value,:method => 'new_tags'})
|
346
|
+
user_tags=@client.read({},{:instance_id => posts[0].schema[:id].col_value,:method => 'new_user_tags'})
|
347
|
+
assert_equal 're: test', reply.schema[:title].col_value
|
348
|
+
assert @client.create(reply.to_params.merge('post[message]' => 'asdf'),{:method => nil,:instance_id => nil})
|
349
|
+
assert @client.create(tags.to_params.merge('post[tags]' => '1,2,3'),{:url => tags.url})
|
350
|
+
assert_same_elements ['1','2','3','admintag1','admintag2'], @client.read[0].find_instances('public_tag').map{|t| t.schema[:tag].col_value}
|
351
|
+
assert @client.create(user_tags.to_params.merge('post[user_tags]' => '4,5,6'),{:url => user_tags.url})
|
352
|
+
assert_same_elements ['4','5','6'], @client.read[0].find_instances('user_tag').map{|t| t.schema[:tag].col_value}
|
353
|
+
assert_equal [], @client.read({},{:auth => @user1_auth})[0].find_instances('user_tag').map{|t| t.schema[:tag].col_value}
|
354
|
+
end
|
355
|
+
end
|
356
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: marley
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Herb Daily
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2011-11-09 00:00:00 -03:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: sequel
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "3.27"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rack
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.2.2
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: json
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.1.7
|
44
|
+
version:
|
45
|
+
description: Marley implements a web services microframework on top of Rack and Sequel on the server side and Jquery on the client side.
|
46
|
+
email: herb.daily@safe-mail.net
|
47
|
+
executables: []
|
48
|
+
|
49
|
+
extensions: []
|
50
|
+
|
51
|
+
extra_rdoc_files: []
|
52
|
+
|
53
|
+
files:
|
54
|
+
- marley-0.1.gem
|
55
|
+
- marley.gemspec
|
56
|
+
- Favicon.ico
|
57
|
+
- README.rdoc
|
58
|
+
- marley-0.1.0.gem
|
59
|
+
- TODO
|
60
|
+
- reggae.ebnf
|
61
|
+
- lib/marley.rb
|
62
|
+
- lib/test_helpers.rb
|
63
|
+
- lib/sequel_plugins.rb
|
64
|
+
- lib/client/jamaica.css
|
65
|
+
- lib/client/jquery-1.6.2.js
|
66
|
+
- lib/client/jamaica.rb
|
67
|
+
- lib/client/jamaica.js
|
68
|
+
- lib/client/jquery.form.js
|
69
|
+
- lib/joints/basic_messaging.rb
|
70
|
+
- lib/joints/basic_user.rb
|
71
|
+
- lib/joints/tagging.rb
|
72
|
+
- lib/joints/user_based_navigation.rb
|
73
|
+
- lib/joints/basic_menu_system.rb
|
74
|
+
- lib/joints/tagged_messaging.rb
|
75
|
+
- lib/joint.rb
|
76
|
+
- lib/controllers.rb
|
77
|
+
- lib/reggae.rb
|
78
|
+
- examples/forum.js
|
79
|
+
- examples/forum.sql
|
80
|
+
- examples/forum.rb
|
81
|
+
- examples/forum.sqlite3
|
82
|
+
- examples/forum_test.sqlite3
|
83
|
+
- examples/empty.sqlite3
|
84
|
+
- examples/forum.css
|
85
|
+
- examples/run.sh
|
86
|
+
- test/forum_tests.rb
|
87
|
+
has_rdoc: true
|
88
|
+
homepage: http://github.com/herbdaily/marley
|
89
|
+
licenses: []
|
90
|
+
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: "0"
|
101
|
+
version:
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 1.0.0
|
107
|
+
version:
|
108
|
+
requirements: []
|
109
|
+
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 1.3.5
|
112
|
+
signing_key:
|
113
|
+
specification_version: 3
|
114
|
+
summary: Irie default restful routes for your models and other objects
|
115
|
+
test_files: []
|
116
|
+
|