cornerstone 0.0.1 → 0.0.5

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 (177) hide show
  1. data/.gitignore +6 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +23 -0
  4. data/Gemfile.lock +168 -0
  5. data/Guardfile +22 -0
  6. data/README.rdoc +4 -1
  7. data/Rakefile +11 -1
  8. data/TODO +11 -0
  9. data/VERSION +1 -0
  10. data/app/assets/images/.gitkeep +0 -0
  11. data/app/assets/javascripts/.gitkeep +0 -0
  12. data/app/assets/javascripts/cornerstone.js +11 -0
  13. data/app/assets/javascripts/cornerstone/discussions.js +2 -0
  14. data/app/assets/javascripts/cornerstone/help.js +2 -0
  15. data/app/assets/stylesheets/.gitkeep +0 -0
  16. data/app/assets/stylesheets/cornerstone.css +8 -0
  17. data/app/assets/stylesheets/cornerstone/discussions.css +4 -0
  18. data/app/assets/stylesheets/cornerstone/help.css +4 -0
  19. data/app/controllers/.gitkeep +0 -0
  20. data/app/controllers/cornerstone/admin/application_controller.rb +7 -0
  21. data/app/controllers/cornerstone/admin/articles_controller.rb +61 -0
  22. data/app/controllers/cornerstone/admin/categories_controller.rb +46 -0
  23. data/app/controllers/cornerstone/admin/discussions_controller.rb +32 -0
  24. data/app/controllers/cornerstone/application_controller.rb +6 -0
  25. data/app/controllers/cornerstone/discussions_controller.rb +58 -0
  26. data/app/controllers/cornerstone/help_controller.rb +11 -0
  27. data/app/controllers/cornerstone/posts_controller.rb +66 -0
  28. data/app/helpers/.gitkeep +0 -0
  29. data/app/helpers/cornerstone/application_helper.rb +5 -0
  30. data/app/helpers/cornerstone/discussions_helper.rb +16 -0
  31. data/app/helpers/cornerstone/help_helper.rb +4 -0
  32. data/app/mailers/cornerstone/cornerstone_mailer.rb +31 -0
  33. data/app/models/.gitkeep +0 -0
  34. data/app/models/cornerstone/article.rb +20 -0
  35. data/app/models/cornerstone/category.rb +45 -0
  36. data/app/models/cornerstone/discussion.rb +90 -0
  37. data/app/models/cornerstone/post.rb +103 -0
  38. data/app/models/cornerstone/post_observer.rb +23 -0
  39. data/app/views/.gitkeep +0 -0
  40. data/app/views/cornerstone/admin/articles/_article.html.erb +9 -0
  41. data/app/views/cornerstone/admin/articles/_form.html.erb +22 -0
  42. data/app/views/cornerstone/admin/articles/edit.html.erb +7 -0
  43. data/app/views/cornerstone/admin/articles/index.html.erb +25 -0
  44. data/app/views/cornerstone/admin/articles/new.html.erb +6 -0
  45. data/app/views/cornerstone/admin/articles/show.html.erb +4 -0
  46. data/app/views/cornerstone/admin/categories/_category.html.erb +12 -0
  47. data/app/views/cornerstone/admin/categories/_form.html.erb +17 -0
  48. data/app/views/cornerstone/admin/categories/edit.html.erb +6 -0
  49. data/app/views/cornerstone/admin/categories/index.html.erb +11 -0
  50. data/app/views/cornerstone/admin/categories/new.html.erb +6 -0
  51. data/app/views/cornerstone/admin/discussions/edit.html.erb +7 -0
  52. data/app/views/cornerstone/cornerstone_mailer/new_discussion.html.erb +14 -0
  53. data/app/views/cornerstone/cornerstone_mailer/new_discussion.text.erb +5 -0
  54. data/app/views/cornerstone/cornerstone_mailer/new_discussion_user.html.erb +7 -0
  55. data/app/views/cornerstone/cornerstone_mailer/new_post.html.erb +7 -0
  56. data/app/views/cornerstone/cornerstone_mailer/new_post.text.erb +8 -0
  57. data/app/views/cornerstone/discussions/_discussion.html.erb +12 -0
  58. data/app/views/cornerstone/discussions/_discussion_category.html.erb +14 -0
  59. data/app/views/cornerstone/discussions/_form.html.erb +33 -0
  60. data/app/views/cornerstone/discussions/_latest_discussion.html.erb +4 -0
  61. data/app/views/cornerstone/discussions/categorical_index.html.erb +27 -0
  62. data/app/views/cornerstone/discussions/index.html.erb +25 -0
  63. data/app/views/cornerstone/discussions/new.html.erb +6 -0
  64. data/app/views/cornerstone/discussions/show.html.erb +19 -0
  65. data/app/views/cornerstone/help/index.html.erb +7 -0
  66. data/app/views/cornerstone/posts/_fields.html.erb +44 -0
  67. data/app/views/cornerstone/posts/_form.html.erb +19 -0
  68. data/app/views/cornerstone/posts/_post.html.erb +17 -0
  69. data/app/views/cornerstone/posts/edit.html.erb +9 -0
  70. data/app/views/cornerstone/shared/_errors.html.erb +11 -0
  71. data/app/views/cornerstone/shared/_flash_messages.html.erb +15 -0
  72. data/app/views/layouts/cornerstone/application.html.erb +16 -0
  73. data/config/cucumber.yml +8 -0
  74. data/config/locales/cornerstone.action_mailer.en.yml +9 -0
  75. data/config/routes.rb +24 -0
  76. data/cornerstone-0.0.1.gem +0 -0
  77. data/cornerstone.gemspec +33 -0
  78. data/db/migrate/20110723004024_create_cornerstone_discussions.rb +17 -0
  79. data/db/migrate/20110804190853_create_cornerstone_categories.rb +15 -0
  80. data/db/migrate/20110809233551_create_cornerstone_posts.rb +13 -0
  81. data/db/migrate/20111006172857_create_cornerstone_articles.rb +12 -0
  82. data/lib/cornerstone.rb +6 -0
  83. data/lib/cornerstone/acts_as_cornerstone_user.rb +79 -0
  84. data/lib/cornerstone/config.rb +33 -0
  85. data/lib/cornerstone/controller_additions.rb +25 -0
  86. data/lib/cornerstone/engine.rb +8 -1
  87. data/lib/cornerstone/exceptions.rb +16 -0
  88. data/lib/cornerstone/helpers.rb +35 -0
  89. data/lib/tasks/cucumber.rake +65 -0
  90. data/lib/templates/cornerstone_config.rb +31 -0
  91. data/script/cucumber +10 -0
  92. data/script/rails +7 -0
  93. data/spec/controllers/cornerstone/admin/articles_controller_spec.rb +250 -0
  94. data/spec/controllers/cornerstone/admin/categories_controller_spec.rb +205 -0
  95. data/spec/controllers/cornerstone/admin/discussions_controller_spec.rb +95 -0
  96. data/spec/controllers/cornerstone/application_controller_spec.rb +34 -0
  97. data/spec/controllers/cornerstone/discussions_controller_spec.rb +157 -0
  98. data/spec/controllers/cornerstone/help_controller_spec.rb +20 -0
  99. data/spec/controllers/cornerstone/posts_controller_spec.rb +212 -0
  100. data/spec/dummy/Rakefile +7 -0
  101. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  102. data/spec/dummy/app/assets/javascripts/tester.js +2 -0
  103. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  104. data/spec/dummy/app/assets/stylesheets/tester.css +4 -0
  105. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  106. data/spec/dummy/app/controllers/tester_controller.rb +7 -0
  107. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  108. data/spec/dummy/app/helpers/tester_helper.rb +6 -0
  109. data/spec/dummy/app/mailers/.gitkeep +0 -0
  110. data/spec/dummy/app/models/.gitkeep +0 -0
  111. data/spec/dummy/app/models/user.rb +23 -0
  112. data/spec/dummy/app/views/devise/confirmations/new.html.erb +12 -0
  113. data/spec/dummy/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  114. data/spec/dummy/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  115. data/spec/dummy/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  116. data/spec/dummy/app/views/devise/passwords/edit.html.erb +16 -0
  117. data/spec/dummy/app/views/devise/passwords/new.html.erb +12 -0
  118. data/spec/dummy/app/views/devise/registrations/edit.html.erb +29 -0
  119. data/spec/dummy/app/views/devise/registrations/new.html.erb +22 -0
  120. data/spec/dummy/app/views/devise/sessions/new.html.erb +19 -0
  121. data/spec/dummy/app/views/devise/shared/_links.erb +25 -0
  122. data/spec/dummy/app/views/devise/unlocks/new.html.erb +12 -0
  123. data/spec/dummy/app/views/layouts/application.html.erb +15 -0
  124. data/spec/dummy/app/views/tester/index.html.erb +14 -0
  125. data/spec/dummy/config.ru +4 -0
  126. data/spec/dummy/config/application.rb +42 -0
  127. data/spec/dummy/config/boot.rb +10 -0
  128. data/spec/dummy/config/database.yml +28 -0
  129. data/spec/dummy/config/environment.rb +5 -0
  130. data/spec/dummy/config/environments/development.rb +31 -0
  131. data/spec/dummy/config/environments/production.rb +54 -0
  132. data/spec/dummy/config/environments/test.rb +39 -0
  133. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  134. data/spec/dummy/config/initializers/cornerstone_config.rb +30 -0
  135. data/spec/dummy/config/initializers/devise.rb +204 -0
  136. data/spec/dummy/config/initializers/inflections.rb +10 -0
  137. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  138. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  139. data/spec/dummy/config/initializers/session_store.rb +8 -0
  140. data/spec/dummy/config/initializers/wrap_parameters.rb +12 -0
  141. data/spec/dummy/config/locales/devise.en.yml +53 -0
  142. data/spec/dummy/config/locales/en.yml +5 -0
  143. data/spec/dummy/config/routes.rb +65 -0
  144. data/spec/dummy/db/migrate/20110724011421_create_user.rb +11 -0
  145. data/spec/dummy/db/migrate/20110724194307_devise_create_users.rb +41 -0
  146. data/spec/dummy/db/migrate/20110804174004_add_name_to_user.rb +5 -0
  147. data/spec/dummy/db/schema.rb +76 -0
  148. data/spec/dummy/log/.gitkeep +0 -0
  149. data/spec/dummy/public/404.html +26 -0
  150. data/spec/dummy/public/422.html +26 -0
  151. data/spec/dummy/public/500.html +26 -0
  152. data/spec/dummy/public/favicon.ico +0 -0
  153. data/spec/dummy/script/rails +6 -0
  154. data/spec/dummy/test/functional/tester_controller_test.rb +9 -0
  155. data/spec/dummy/test/unit/helpers/tester_helper_test.rb +4 -0
  156. data/spec/fixtures/cornerstone/cornerstone_mailer/new_discussion +3 -0
  157. data/spec/lib/cornerstone/acts_as_cornerstone_user_spec.rb +56 -0
  158. data/spec/lib/cornerstone/helpers_spec.rb +32 -0
  159. data/spec/mailers/cornerstone/cornerstone_mailer_spec.rb +55 -0
  160. data/spec/models/cornerstone/article_spec.rb +25 -0
  161. data/spec/models/cornerstone/category_spec.rb +97 -0
  162. data/spec/models/cornerstone/discussion_spec.rb +243 -0
  163. data/spec/models/cornerstone/post_observer_spec.rb +65 -0
  164. data/spec/models/cornerstone/post_spec.rb +210 -0
  165. data/spec/requests/emails_spec.rb +51 -0
  166. data/spec/requests/interact_discussions_spec.rb +103 -0
  167. data/spec/requests/manage_articles_spec.rb +59 -0
  168. data/spec/requests/manage_categories_spec.rb +64 -0
  169. data/spec/requests/view_home_spec.rb +26 -0
  170. data/spec/spec_helper.rb +40 -0
  171. data/spec/support/devise.rb +4 -0
  172. data/spec/support/factories.rb +62 -0
  173. data/spec/support/general_helper_methods.rb +20 -0
  174. data/spec/support/mailer_macros.rb +15 -0
  175. data/spec/support/mass_assignment.rb +46 -0
  176. data/tmp/log/development.log +0 -0
  177. metadata +301 -20
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ feature "Cornerstone emails" do
4
+
5
+ background do
6
+ end
7
+
8
+ scenario "Sent to administrators when a discussion is created" do
9
+ category = Factory(:category, :name => "General Help",
10
+ :category_type => "Discussion")
11
+ visit discussions_path
12
+ click_link("New Discussion")
13
+
14
+ select category.name, :from => "discussion_category_id"
15
+ fill_in "Subject", :with => "I need help!"
16
+ fill_in "Name", :with => "Waffles"
17
+ fill_in "Email", :with => "w@ihop.com"
18
+ fill_in "post_body", :with => "Please help me out. k thx."
19
+ click_button "Create"
20
+
21
+ d = Cornerstone::Discussion.find_by_subject("I need help!")
22
+ current_path.should match category_discussion_path(category, d)
23
+
24
+ emails.size.should == 2
25
+ emails.first.to.should == ["admins@cornerstone.com"]
26
+ emails.second.to.should == ["w@ihop.com"]
27
+ end
28
+
29
+ scenario "Sent to other participants when reply is created" do
30
+ user = Factory(:user, :name => "New guy")
31
+ sign_in_user(user)
32
+ discussion = Factory(:discussion_w_user, :user => user)
33
+ reply1 = Factory(:post, :discussion => discussion,
34
+ :name => "Reply Author",
35
+ :email => "email@email.com")
36
+ reply2 = Factory(:post, :discussion => discussion,
37
+ :name => "Reply2 Author",
38
+ :email => "email2@email.com")
39
+ emails.clear
40
+
41
+ visit category_discussion_path(discussion.category, discussion)
42
+ fill_in "post_body", :with => "Final reply."
43
+ click_button "Comment"
44
+ current_path.should match category_discussion_path(discussion.category, discussion)
45
+
46
+ emails.size.should == 2
47
+ emails.first.to.should == ["email@email.com"]
48
+ emails.last.to.should == ["email2@email.com"]
49
+ end
50
+
51
+ end
@@ -0,0 +1,103 @@
1
+ require 'spec_helper'
2
+
3
+ feature "Interact with Discussions" do
4
+
5
+ background do
6
+ @c1 = Factory(:category, :name => "General Help",
7
+ :category_type => "Discussion")
8
+ @c2 = Factory(:category, :name => "FAQ's",
9
+ :category_type => "Article")
10
+ @c3 = Factory(:category, :name => "Refunds",
11
+ :category_type => "Discussion")
12
+ end
13
+
14
+ scenario "See what people are takling about" do
15
+ visit discussions_path
16
+ page.should have_content(@c1.name)
17
+ page.should_not have_content(@c2.name)
18
+ page.should have_content(@c3.name)
19
+ page.should have_link("New Discussion")
20
+ end
21
+
22
+ scenario "Select a category and then a discussion" do
23
+ d = Factory(:discussion_w_user, :subject => "I have a problem",
24
+ :privte => false,
25
+ :category => @c1)
26
+ visit discussions_path
27
+ page.should have_content(@c1.name)
28
+ click_link(@c1.name)
29
+ current_path.should match discussions_category_path(@c1)
30
+
31
+ page.should have_content(d.subject)
32
+ click_link(d.subject)
33
+ current_path.should match category_discussion_path(@c1, d)
34
+ end
35
+
36
+ scenario "Create a new discussion when not logged in" do
37
+ visit discussions_path
38
+ click_link("New Discussion")
39
+
40
+ select @c1.name, :from => "discussion_category_id"
41
+ fill_in "Subject", :with => "I need help!"
42
+ fill_in "Name", :with => "Waffles"
43
+ fill_in "Email", :with => "w@ihop.com"
44
+ fill_in "post_body", :with => "Please help me out. k thx."
45
+ click_button "Create"
46
+
47
+ d = Cornerstone::Discussion.find_by_subject("I need help!")
48
+ current_path.should match category_discussion_path(@c1, d)
49
+ end
50
+
51
+ scenario "Create a new discussion when logged in" do
52
+ sign_in_user
53
+ visit discussions_path
54
+ click_link("New Discussion")
55
+
56
+ select @c1.name, :from => "discussion_category_id"
57
+ fill_in "Subject", :with => "I need help!"
58
+ fill_in "post_body", :with => "Please help me out. k thx."
59
+ click_button "Create"
60
+
61
+ d = Cornerstone::Discussion.find_by_subject("I need help!")
62
+ current_path.should match category_discussion_path(@c1, d)
63
+ page.should have_content(@user.name)
64
+ end
65
+
66
+ scenario "New discussion from within category view should have category pre-selected" do
67
+ visit discussions_category_path(@c1)
68
+ click_link ("New Discussion")
69
+ current_path.should match new_discussion_path
70
+ page.find("#discussion_category_id").value.should == @c1.id.to_s
71
+ end
72
+
73
+ scenario "Reply to an existing discussion when logged in" do
74
+ sign_in_user
75
+ discussion = Factory(:discussion_w_user, :user => @user)
76
+ reply1 = Factory(:post, :discussion => discussion,
77
+ :name => "Reply Author",
78
+ :email => "email@email.com")
79
+
80
+
81
+ visit category_discussion_path(discussion.category, discussion)
82
+ fill_in "post_body", :with => "Please help me out. k thx."
83
+ click_button "Comment"
84
+ current_path.should match category_discussion_path(discussion.category, discussion)
85
+ page.should have_content "Comment was successfully created."
86
+ end
87
+
88
+ scenario "Reply to an existing discussion when not logged in" do
89
+ discussion = Factory(:discussion_w_user)
90
+ reply1 = Factory(:post, :discussion => discussion,
91
+ :name => "Reply Author",
92
+ :email => "email@email.com")
93
+
94
+
95
+ visit category_discussion_path(discussion.category, discussion)
96
+ fill_in "Name", :with => "Anonymous"
97
+ fill_in "Email", :with => "anonymous@whatever.com"
98
+ fill_in "post_body", :with => "Please help me out. k thx."
99
+ click_button "Comment"
100
+ current_path.should match category_discussion_path(discussion.category, discussion)
101
+ page.should have_content "Comment was successfully created."
102
+ end
103
+ end
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ feature "Manage Articles" do
4
+
5
+ background do
6
+ sign_in_admin
7
+ end
8
+
9
+ scenario "Articles are listed with action buttons" do
10
+ Factory(:article, :title => "General Help")
11
+ Factory(:article, :title => "How to ask for help")
12
+ visit admin_articles_path
13
+ page.should have_content("General Help")
14
+ page.should have_content("How to ask for help")
15
+ page.should have_link("Edit")
16
+ page.should have_link("Destroy")
17
+ page.should have_link("New Article", :href => new_admin_article_path)
18
+ end
19
+
20
+ scenario "Create a new article successfully" do
21
+ Factory(:category, :name => "FAQs",
22
+ :category_type => "Article")
23
+ visit new_admin_article_path
24
+
25
+ fill_in "Title", :with => "name 1"
26
+ select "FAQs", :from => "article_category_id"
27
+ fill_in "Body", :with => "some article body"
28
+ click_button "Create"
29
+
30
+ page.should have_content("name 1")
31
+ page.should have_content("some article body")
32
+ # TODO: flash in admin namespace
33
+ # page.should have_content("Article created successfully.")
34
+ end
35
+
36
+ scenario "Update an article successfully" do
37
+ article = Factory(:article, :title => "whatever")
38
+ visit admin_articles_path
39
+ click_link "Edit"
40
+ current_path.should match edit_admin_article_path(article)
41
+ fill_in "Title", :with => "Different Title"
42
+ click_button "Update"
43
+
44
+ page.should have_content("Different Title")
45
+ end
46
+
47
+ scenario "Delete an Article" do
48
+ Factory(:article, :title => "One")
49
+ Factory(:article, :title => "Two")
50
+ Factory(:article, :title => "Three")
51
+ visit admin_articles_path
52
+ within("table#articles tr:last-child") do
53
+ click_link "Destroy"
54
+ end
55
+ current_path.should match admin_articles_path
56
+ page.should_not have_content("Three")
57
+ end
58
+
59
+ end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ feature "Manage Categories" do
4
+
5
+ background do
6
+ sign_in_admin
7
+ end
8
+
9
+ scenario "Categories are listed with action buttons" do
10
+ Factory(:category, :name => "General Help",
11
+ :category_type => "Discussion")
12
+ Factory(:category, :name => "FAQs",
13
+ :category_type => "Article")
14
+ visit admin_categories_path
15
+ page.should have_content("General Help")
16
+ page.should have_content("FAQs")
17
+ page.should have_link("Edit")
18
+ page.should have_link("Destroy")
19
+ page.should have_link("New Category", :href => new_admin_category_path)
20
+ end
21
+
22
+ scenario "Create a new category successfully" do
23
+ visit new_admin_category_path
24
+
25
+ fill_in "Name", :with => "name 1"
26
+ select "Discussion", :from => "category_type"
27
+ fill_in "Description", :with => "some description"
28
+ click_button "Create"
29
+
30
+ current_path.should match admin_categories_path
31
+ page.should have_content("name 1")
32
+ # TODO: flash in admin namespace
33
+ # page.should have_content("Category created successfully.")
34
+ end
35
+
36
+ scenario "Update a category successfully" do
37
+ category = Factory(:category, :name => "FAQs",
38
+ :category_type => "Article")
39
+ visit admin_categories_path
40
+ click_link "Edit"
41
+ current_path.should match edit_admin_category_path(category)
42
+ fill_in "Name", :with => "Different Name"
43
+ click_button "Update"
44
+
45
+ current_path.should match admin_categories_path
46
+ page.should have_content("Different Name")
47
+ end
48
+
49
+ scenario "Delete a category" do
50
+ Factory(:category, :name => "General Help",
51
+ :category_type => "Discussion")
52
+ Factory(:category, :name => "Other Help",
53
+ :category_type => "Discussion")
54
+ Factory(:category, :name => "FAQs",
55
+ :category_type => "Article")
56
+ visit admin_categories_path
57
+ within("table#discussion_categories tr:last-child") do
58
+ click_link "Destroy"
59
+ end
60
+ current_path.should match admin_categories_path
61
+ page.should_not have_content("Other Help")
62
+ end
63
+
64
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ feature "Manage Articles" do
4
+
5
+ before do
6
+ visit root_url
7
+ end
8
+
9
+ scenario "Visit the home page" do
10
+ page.should have_content("Browse Discussions")
11
+ # page.should have_content("Browse Knowledge Base")
12
+ end
13
+
14
+ scenario "Browse discussions" do
15
+ click_link "Browse Discussions"
16
+ current_path.should match discussions_path
17
+ end
18
+
19
+ scenario "Browse knowledge base" do
20
+ pending
21
+ # click_link "Browse Knowledge Base"
22
+ # current_path.should match knowledge_base_path
23
+ end
24
+
25
+
26
+ end
@@ -0,0 +1,40 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+ require File.expand_path("../dummy/config/environment", __FILE__)
4
+ require 'rspec/rails'
5
+ require 'factory_girl_rails'
6
+ require 'capybara/rails'
7
+
8
+ ENGINE_RAILS_ROOT = File.join(File.dirname(__FILE__), '../')
9
+
10
+ # Requires supporting ruby files with custom matchers and macros, etc,
11
+ # in spec/support/ and its subdirectories.
12
+ #Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
13
+ Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
14
+
15
+ include Warden::Test::Helpers
16
+
17
+ RSpec.configure do |config|
18
+ # == Mock Framework
19
+ #
20
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
21
+ #
22
+ # config.mock_with :mocha
23
+ # config.mock_with :flexmock
24
+ # config.mock_with :rr
25
+ config.mock_with :rspec
26
+
27
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
28
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
29
+
30
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
31
+ # examples within a transaction, remove the following line or assign false
32
+ # instead of true.
33
+ config.use_transactional_fixtures = true
34
+
35
+ config.include Cornerstone::Engine.routes.url_helpers
36
+
37
+
38
+ config.include(MailerMacros)
39
+ config.before(:each) { reset_email }
40
+ end
@@ -0,0 +1,4 @@
1
+ RSpec.configure do |config|
2
+ config.include Devise::TestHelpers, :type => :controller
3
+ end
4
+
@@ -0,0 +1,62 @@
1
+ Factory.sequence :email do |n|
2
+ "email#{n}@example.com"
3
+ end
4
+
5
+ Factory.sequence :category_name do |n|
6
+ "Category - #{n}"
7
+ end
8
+
9
+ FactoryGirl.define do
10
+
11
+ factory :discussion, :class => Cornerstone::Discussion do
12
+ subject "Help please"
13
+ status Cornerstone::Discussion::STATUS.first
14
+ category
15
+ end
16
+
17
+ factory :discussion_no_user, :parent => :discussion do |discussion|
18
+ discussion.after_build { |d| Factory(:post_no_user, :discussion => d) }
19
+ end
20
+
21
+ factory :discussion_w_user, :parent => :discussion do |discussion|
22
+ user
23
+ discussion.after_build { |d| Factory(:post_w_user, :discussion => d,
24
+ :user => d.user) }
25
+ end
26
+
27
+ factory :user do
28
+ name "Alice Mcduffry"
29
+ email { Factory.next(:email) }
30
+ password "tester"
31
+ encrypted_password "$2a$10$5JwEZ3gf0udh3MRlNYQP3Ow3fAsw/jFJZA4tKMB760wC.Uv7w7jJi"
32
+ end
33
+
34
+ factory :category, :class => Cornerstone::Category do
35
+ name { Factory.next(:category_name) }
36
+ category_type Cornerstone::Category::TYPES.first
37
+ description "Description for category."
38
+ item_count 4
39
+ end
40
+
41
+ factory :post, :class => Cornerstone::Post do
42
+ body "This is a post"
43
+ discussion
44
+ end
45
+
46
+ factory :post_no_user, :parent => :post do
47
+ name "Joe Blow"
48
+ email { Factory.next(:email) }
49
+ end
50
+
51
+ factory :post_w_user, :parent => :post do
52
+ user
53
+ end
54
+
55
+ factory :article, :class => Cornerstone::Article do
56
+ title "How to Create a Widget"
57
+ body "Step 1: bla bla"
58
+ category
59
+ end
60
+
61
+ end
62
+
@@ -0,0 +1,20 @@
1
+ def random_alphanumeric(size=16)
2
+ s = ""
3
+ size.times { s << (i = Kernel.rand(62); i += ((i < 10) ? 48 : ((i < 36) ? 55 : 61 ))).chr }
4
+ s
5
+ end
6
+
7
+
8
+ def sign_in_admin(admin=nil)
9
+ @admin = admin || Factory(:user)
10
+ login_as @admin
11
+ controller.stub(:current_cornerstone_user) {@admin} if controller
12
+ @admin.stub(:cornerstone_admin?) {true}
13
+ end
14
+
15
+ def sign_in_user(user=nil)
16
+ @user = user || Factory(:user)
17
+ login_as @user
18
+ controller.stub(:current_cornerstone_user) {@user} if controller
19
+ @user.stub(:cornerstone_admin?) {false}
20
+ end
@@ -0,0 +1,15 @@
1
+ module MailerMacros
2
+
3
+ def last_email
4
+ ActionMailer::Base.deliveries.last
5
+ end
6
+
7
+ def reset_email
8
+ ActionMailer::Base.deliveries = []
9
+ end
10
+
11
+ def emails
12
+ ActionMailer::Base.deliveries
13
+ end
14
+
15
+ end