Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 120
- Log:
Hub integration. RForum Users are lazy-created when Hub users, logged in,
visit RForum for the first time. RForum navigation links to log in and
out or change settings all point at Hub. Webmaster and adminstrator roles
in Hub map to administrator permissions in RForum; in addition to the
RForum permission management system, though, added Hub permissions hashes
to various controllers to include Hub authorisation too. Two layers can't
hurt and it means sensible return-to'd redirections to Hub for some
action types.Corrected grammar on deletion confirmation messages and tidied up a few
templates here and there, too.
- Author:
- adh
- Date:
- Sat Oct 28 23:53:03 +0100 2006
- Size:
- 2871 Bytes
- Properties:
- Property svn:executable is set
1 | #!/bin/env ruby |
2 | |
3 | require File.dirname(__FILE__) + '/../test_helper' |
4 | require 'post_menu' |
5 | |
6 | class PostMenuTest < Test::Unit::TestCase |
7 | |
8 | item = RForum::PostMenu::Item |
9 | |
10 | EXPECTED_ITEMS = { |
11 | :reply_to => item.new('Reply with quote', |
12 | {:controller => 'topic', :action => 'show', :id => 1, :anchor => 'postform', |
13 | :params => {'reply_to' => 1}}), |
14 | :delete_post => item.new('Delete', {:controller => 'topic', :action => 'delete_post', |
15 | :id => 2}, 'Are you sure you want to delete this post?'), |
16 | :delete_topic => item.new('Delete topic', {:controller => 'topic', :action => 'delete_post', |
17 | :id => 1}, 'Are you sure you want to delete this topic?') |
18 | } |
19 | |
20 | def setup |
21 | setup_forum_fixture |
22 | end |
23 | |
24 | def test_post_menu_anonymous |
25 | menu = RForum::PostMenu.new(Post.find(2), user = Guest.new) |
26 | assert_nil menu.delete |
27 | assert_equal reply_to_item(1, 2), menu.reply_to |
28 | end |
29 | |
30 | def test_post_menu_admin_somebody_elses_post |
31 | menu = RForum::PostMenu.new(Post.find(2), User.find(1)) |
32 | assert_equal delete_post_item(2), menu.delete |
33 | assert_equal reply_to_item(1, 2), menu.reply_to |
34 | end |
35 | |
36 | def test_post_menu_admin_root_post |
37 | menu = RForum::PostMenu.new(Post.find(1), User.find(1)) |
38 | assert_equal EXPECTED_ITEMS[:delete_topic], menu.delete |
39 | assert_equal reply_to_item(1, 1), menu.reply_to |
40 | end |
41 | |
42 | def test_post_menu_user_own_post_without_children |
43 | menu = RForum::PostMenu.new(Post.find(21), User.find(2)) |
44 | assert_equal delete_post_item(21), menu.delete |
45 | assert_equal reply_to_item(3, 21), menu.reply_to |
46 | end |
47 | |
48 | def test_post_menu_user_own_post_with_children |
49 | menu = RForum::PostMenu.new(Post.find(2), User.find(2)) |
50 | assert_nil menu.delete |
51 | assert_equal reply_to_item(1, 2), menu.reply_to |
52 | end |
53 | |
54 | def test_post_menu_user_own_post_root_of_topic_with_children |
55 | menu = RForum::PostMenu.new(Post.find(101), User.find(2)) |
56 | assert_nil menu.delete |
57 | assert_equal reply_to_item(2, 101), menu.reply_to |
58 | end |
59 | |
60 | def test_post_menu_user_own_post_root_of_topic_without_childreb |
61 | Post.find(102).destroy |
62 | menu = RForum::PostMenu.new(Post.find(101), User.find(2)) |
63 | assert_equal delete_topic_item(101), menu.delete |
64 | assert_equal reply_to_item(2, 101), menu.reply_to |
65 | end |
66 | |
67 | # HELPERS |
68 | |
69 | def delete_post_item(post_id) |
70 | delete_post = EXPECTED_ITEMS[:delete_post].dup |
71 | delete_post.target[:id] = post_id |
72 | delete_post |
73 | end |
74 | |
75 | def delete_topic_item(post_id) |
76 | delete_topic = EXPECTED_ITEMS[:delete_topic].dup |
77 | delete_topic.target[:id] = post_id |
78 | delete_topic |
79 | end |
80 | |
81 | def reply_to_item(topic_id, post_id) |
82 | reply_to = EXPECTED_ITEMS[:reply_to].dup |
83 | reply_to.target[:id] = topic_id |
84 | reply_to.target[:params]['reply_to'] = post_id |
85 | reply_to |
86 | end |
87 | |
88 | end |