my_forum 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +12 -1
  3. data/Rakefile +4 -3
  4. data/{test/dummy/public/favicon.ico → app/assets/javascripts/my_forum/admin/categories.js.coffee} +0 -0
  5. data/app/assets/javascripts/my_forum/admin/dashboard.js.coffee +0 -0
  6. data/app/assets/javascripts/my_forum/admin/forums.js.coffee +0 -0
  7. data/app/assets/javascripts/my_forum/admin/roles.js +2 -0
  8. data/app/assets/javascripts/my_forum/admin/users.js +2 -0
  9. data/app/assets/javascripts/my_forum/application.js +6 -0
  10. data/app/assets/javascripts/my_forum/forums.js.coffee +0 -0
  11. data/app/assets/javascripts/my_forum/jquery.scrollTo.min.js +7 -0
  12. data/app/assets/javascripts/my_forum/jquery.selection.js +354 -0
  13. data/app/assets/javascripts/my_forum/my_forum.js.coffee +118 -0
  14. data/app/assets/javascripts/my_forum/posts.js.coffee +20 -0
  15. data/app/assets/javascripts/my_forum/topics.js.coffee +0 -0
  16. data/app/assets/javascripts/my_forum/users.js.coffee +0 -0
  17. data/app/assets/javascripts/my_forum/welcome.js.coffee +0 -0
  18. data/app/assets/stylesheets/my_forum/admin/categories.css.scss +0 -0
  19. data/app/assets/stylesheets/my_forum/admin/dashboard.css.scss +3 -0
  20. data/app/assets/stylesheets/my_forum/admin/forums.css.scss +7 -0
  21. data/app/assets/stylesheets/my_forum/admin/roles.css +4 -0
  22. data/app/assets/stylesheets/my_forum/admin/users.css +4 -0
  23. data/app/assets/stylesheets/my_forum/application.css.scss +80 -0
  24. data/app/assets/stylesheets/my_forum/forums.css.scss +31 -0
  25. data/app/assets/stylesheets/my_forum/posts.css.scss +138 -0
  26. data/app/assets/stylesheets/my_forum/private_messages.css.scss +11 -0
  27. data/app/assets/stylesheets/my_forum/topics.css.scss +16 -0
  28. data/app/assets/stylesheets/my_forum/users.css.scss +3 -0
  29. data/app/assets/stylesheets/my_forum/welcome.css.scss +73 -0
  30. data/app/controllers/my_forum/admin/categories_controller.rb +36 -0
  31. data/app/controllers/my_forum/admin/dashboard_controller.rb +13 -0
  32. data/app/controllers/my_forum/admin/emoticons_controller.rb +65 -0
  33. data/app/controllers/my_forum/admin/forums_controller.rb +35 -0
  34. data/app/controllers/my_forum/admin/mail_controller.rb +31 -0
  35. data/app/controllers/my_forum/admin/roles_controller.rb +38 -0
  36. data/app/controllers/my_forum/admin/users_controller.rb +14 -0
  37. data/app/controllers/my_forum/application_controller.rb +81 -0
  38. data/app/controllers/my_forum/attachments_controller.rb +30 -0
  39. data/app/controllers/my_forum/forums_controller.rb +39 -0
  40. data/app/controllers/my_forum/images_controller.rb +7 -0
  41. data/app/controllers/my_forum/posts_controller.rb +96 -0
  42. data/app/controllers/my_forum/private_messages_controller.rb +73 -0
  43. data/app/controllers/my_forum/topics_controller.rb +96 -0
  44. data/app/controllers/my_forum/users_controller.rb +145 -0
  45. data/app/controllers/my_forum/welcome_controller.rb +30 -0
  46. data/app/helpers/my_forum/admin/dashboard_helper.rb +4 -0
  47. data/app/helpers/my_forum/admin/forums_helper.rb +4 -0
  48. data/app/helpers/my_forum/admin/roles_helper.rb +4 -0
  49. data/app/helpers/my_forum/admin/users_helper.rb +4 -0
  50. data/app/helpers/my_forum/application_helper.rb +43 -0
  51. data/app/helpers/my_forum/emoticons_helper.rb +7 -0
  52. data/app/helpers/my_forum/forums_helper.rb +44 -0
  53. data/app/helpers/my_forum/posts_helper.rb +76 -0
  54. data/app/helpers/my_forum/private_messages_helper.rb +25 -0
  55. data/app/helpers/my_forum/topics_helper.rb +18 -0
  56. data/app/helpers/my_forum/users_helper.rb +33 -0
  57. data/app/helpers/my_forum/welcome_helper.rb +4 -0
  58. data/app/mailers/application_mailer.rb +4 -0
  59. data/app/mailers/my_forum/user_mailer.rb +31 -0
  60. data/app/models/my_forum/attachment.rb +12 -0
  61. data/app/models/my_forum/avatar.rb +11 -0
  62. data/app/models/my_forum/category.rb +7 -0
  63. data/app/models/my_forum/category_permission.rb +6 -0
  64. data/app/models/my_forum/emoticon.rb +6 -0
  65. data/app/models/my_forum/forum.rb +50 -0
  66. data/app/models/my_forum/image.rb +5 -0
  67. data/app/models/my_forum/log_read_mark.rb +4 -0
  68. data/app/models/my_forum/post.rb +26 -0
  69. data/app/models/my_forum/private_message.rb +8 -0
  70. data/app/models/my_forum/role.rb +6 -0
  71. data/app/models/my_forum/topic.rb +41 -0
  72. data/app/models/my_forum/user.rb +71 -0
  73. data/app/models/my_forum/user_group.rb +13 -0
  74. data/app/models/my_forum/user_group_link.rb +6 -0
  75. data/app/models/my_forum/user_roles.rb +6 -0
  76. data/app/views/layouts/mailer.html.erb +5 -0
  77. data/app/views/layouts/mailer.text.erb +1 -0
  78. data/app/views/layouts/my_forum/_guest_navbar.html.haml +4 -0
  79. data/app/views/layouts/my_forum/_user_navbar.html.haml +19 -0
  80. data/app/views/layouts/my_forum/admin_application.haml +29 -0
  81. data/app/views/layouts/my_forum/application.haml +23 -0
  82. data/app/views/my_forum/admin/categories/edit.haml +9 -0
  83. data/app/views/my_forum/admin/categories/new.haml +5 -0
  84. data/app/views/my_forum/admin/dashboard/index.haml +0 -0
  85. data/app/views/my_forum/admin/emoticons/edit.haml +4 -0
  86. data/app/views/my_forum/admin/emoticons/index.haml +15 -0
  87. data/app/views/my_forum/admin/emoticons/new.haml +5 -0
  88. data/app/views/my_forum/admin/forums/index.haml +47 -0
  89. data/app/views/my_forum/admin/forums/new.haml +6 -0
  90. data/app/views/my_forum/admin/mail/index.haml +9 -0
  91. data/app/views/my_forum/admin/roles/index.haml +12 -0
  92. data/app/views/my_forum/admin/roles/new.haml +22 -0
  93. data/app/views/my_forum/admin/users/index.haml +10 -0
  94. data/app/views/my_forum/forums/_topic_subject.html.haml +16 -0
  95. data/app/views/my_forum/forums/show.haml +29 -0
  96. data/app/views/my_forum/posts/edit.html.haml +31 -0
  97. data/app/views/my_forum/private_messages/_sidebar.haml +10 -0
  98. data/app/views/my_forum/private_messages/inbox.haml +26 -0
  99. data/app/views/my_forum/private_messages/new.haml +21 -0
  100. data/app/views/my_forum/private_messages/show.haml +10 -0
  101. data/app/views/my_forum/shared/_post_preview.haml +15 -0
  102. data/app/views/my_forum/shared/_upload_photo.haml +45 -0
  103. data/app/views/my_forum/shared/post_preview.js.coffee +4 -0
  104. data/app/views/my_forum/topics/_post.haml +29 -0
  105. data/app/views/my_forum/topics/_profile_popover.haml +47 -0
  106. data/app/views/my_forum/topics/_quick_answer.haml +34 -0
  107. data/app/views/my_forum/topics/_topic_header.haml +4 -0
  108. data/app/views/my_forum/topics/_user_info.haml +9 -0
  109. data/app/views/my_forum/topics/new.haml +38 -0
  110. data/app/views/my_forum/topics/show.haml +60 -0
  111. data/app/views/my_forum/user_mailer/custom_email.text.erb +1 -0
  112. data/app/views/my_forum/user_mailer/ping_from_post.haml +8 -0
  113. data/app/views/my_forum/user_mailer/ping_from_post.text.erb +6 -0
  114. data/app/views/my_forum/user_mailer/pm_notification.text.erb +6 -0
  115. data/app/views/my_forum/user_mailer/reset_password_email.haml +1 -0
  116. data/app/views/my_forum/user_mailer/reset_password_email.text.erb +1 -0
  117. data/app/views/my_forum/users/edit.haml +36 -0
  118. data/app/views/my_forum/users/forgot_password.haml +10 -0
  119. data/app/views/my_forum/users/new.haml +14 -0
  120. data/app/views/my_forum/users/signin.haml +14 -0
  121. data/app/views/my_forum/users/signout.haml +0 -0
  122. data/app/views/my_forum/welcome/index.haml +37 -0
  123. data/config/initializers/will_paginate.rb +24 -0
  124. data/config/locales/en.yml +68 -0
  125. data/config/locales/ru.yml +198 -0
  126. data/config/routes.rb +48 -0
  127. data/db/migrate/20141117122725_create_my_forum_forums.rb +12 -0
  128. data/db/migrate/20141117122742_create_my_forum_topics.rb +17 -0
  129. data/db/migrate/20141117122751_create_my_forum_posts.rb +11 -0
  130. data/db/migrate/20141118081021_create_my_forum_categories.rb +8 -0
  131. data/db/migrate/20141118131215_create_my_forum_users.rb +34 -0
  132. data/db/migrate/20141222094522_create_my_forum_roles.rb +10 -0
  133. data/db/migrate/20141222094538_create_my_forum_user_roles.rb +9 -0
  134. data/db/migrate/20150202115250_create_my_forum_log_read_marks.rb +10 -0
  135. data/db/migrate/20150215200453_create_my_forum_user_groups.rb +15 -0
  136. data/db/migrate/20150215204852_create_my_forum_user_group_links.rb +9 -0
  137. data/db/migrate/20150215212443_create_my_forum_category_permissions.rb +9 -0
  138. data/db/migrate/20150227210814_create_my_forum_private_messages.rb +16 -0
  139. data/db/migrate/20151012095554_create_my_forum_images.rb +12 -0
  140. data/db/migrate/20151218135729_add_is_deleted.rb +6 -0
  141. data/db/migrate/20151220121140_create_my_forum_emoticons.rb +10 -0
  142. data/db/migrate/20151221203243_my_forum_rename_user_avatar.rb +5 -0
  143. data/db/migrate/20151221205045_my_forum_change_user_avatar.rb +5 -0
  144. data/db/migrate/20160122202142_add_latest_post_info_for_topic.rb +24 -0
  145. data/db/migrate/20160210130805_add_indexes_for_topics.rb +7 -0
  146. data/db/migrate/20160214085201_add_edited_by_for_post.rb +5 -0
  147. data/lib/my_forum/engine.rb +31 -0
  148. data/lib/my_forum/version.rb +1 -1
  149. data/lib/tasks/my_forum_tasks.rake +155 -4
  150. data/spec/controllers/my_forum/admin/emoticons_controller_spec.rb +7 -0
  151. data/spec/controllers/my_forum/admin/mail_controller_spec.rb +7 -0
  152. data/spec/controllers/my_forum/private_messages_controller_spec.rb +7 -0
  153. data/spec/controllers/my_forum/users_controller_spec.rb +76 -0
  154. data/{test → spec}/dummy/README.rdoc +0 -0
  155. data/{test → spec}/dummy/Rakefile +0 -0
  156. data/{test → spec}/dummy/app/assets/javascripts/application.js +1 -1
  157. data/{app/assets/stylesheets/my_forum → spec/dummy/app/assets/stylesheets}/application.css +1 -1
  158. data/{test → spec}/dummy/app/controllers/application_controller.rb +0 -0
  159. data/{test → spec}/dummy/app/helpers/application_helper.rb +0 -0
  160. data/{test → spec}/dummy/app/views/layouts/application.html.erb +0 -0
  161. data/{test → spec}/dummy/bin/bundle +0 -0
  162. data/{test → spec}/dummy/bin/rails +0 -0
  163. data/{test → spec}/dummy/bin/rake +0 -0
  164. data/{test → spec}/dummy/config/application.rb +0 -0
  165. data/{test → spec}/dummy/config/boot.rb +0 -0
  166. data/{test → spec}/dummy/config/database.yml +0 -0
  167. data/{test → spec}/dummy/config/environment.rb +0 -0
  168. data/{test → spec}/dummy/config/environments/development.rb +0 -0
  169. data/{test → spec}/dummy/config/environments/production.rb +1 -1
  170. data/{test → spec}/dummy/config/environments/test.rb +1 -1
  171. data/{test → spec}/dummy/config/initializers/assets.rb +0 -0
  172. data/{test → spec}/dummy/config/initializers/backtrace_silencers.rb +0 -0
  173. data/{test → spec}/dummy/config/initializers/cookies_serializer.rb +0 -0
  174. data/{test → spec}/dummy/config/initializers/filter_parameter_logging.rb +0 -0
  175. data/{test → spec}/dummy/config/initializers/inflections.rb +0 -0
  176. data/{test → spec}/dummy/config/initializers/mime_types.rb +0 -0
  177. data/{test → spec}/dummy/config/initializers/session_store.rb +0 -0
  178. data/{test → spec}/dummy/config/initializers/wrap_parameters.rb +0 -0
  179. data/{test → spec}/dummy/config/locales/en.yml +0 -0
  180. data/{test → spec}/dummy/config/routes.rb +0 -0
  181. data/{test → spec}/dummy/config/secrets.yml +0 -0
  182. data/{test → spec}/dummy/config.ru +0 -0
  183. data/spec/dummy/db/development.sqlite3 +0 -0
  184. data/spec/dummy/db/schema.rb +159 -0
  185. data/spec/dummy/db/test.sqlite3 +0 -0
  186. data/spec/dummy/log/development.log +12 -0
  187. data/{test → spec}/dummy/public/404.html +0 -0
  188. data/{test → spec}/dummy/public/422.html +0 -0
  189. data/{test → spec}/dummy/public/500.html +0 -0
  190. data/spec/dummy/public/favicon.ico +0 -0
  191. data/spec/helpers/my_forum/posts_helper_spec.rb +24 -0
  192. data/spec/helpers/my_forum/private_messages_helper_spec.rb +17 -0
  193. data/spec/models/my_forum/emoticon_spec.rb +7 -0
  194. data/spec/models/my_forum/private_message_spec.rb +7 -0
  195. data/spec/models/my_forum/user_spec.rb +13 -0
  196. data/spec/rails_helper.rb +52 -0
  197. data/spec/spec_helper.rb +87 -0
  198. metadata +356 -83
  199. data/app/views/layouts/my_forum/application.html.erb +0 -14
  200. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  201. data/test/integration/navigation_test.rb +0 -10
  202. data/test/my_forum_test.rb +0 -7
  203. data/test/test_helper.rb +0 -15
@@ -1,4 +1,155 @@
1
- # desc "Explaining what the task does"
2
- # task :my_forum do
3
- # # Task goes here
4
- # end
1
+ namespace :my_forum do
2
+ namespace :service do
3
+ desc 'Recalculate category posts count'
4
+ task recalculate_posts_count: :environment do
5
+ MyForum::Forum.all.each do |forum|
6
+ topic_ids = MyForum::Topic.where(forum_id: forum.id).pluck(:id)
7
+ count = MyForum::Post.where(topic_id: topic_ids).count
8
+ forum.update(posts_count: count)
9
+ end
10
+ end
11
+ end
12
+
13
+ namespace :import do
14
+ namespace :smf do
15
+
16
+ if Rails.env.test?
17
+ require 'sqlite3'
18
+ $connection = SQLite3::Database.new('test.db')
19
+ else
20
+ $connection = Mysql2::Client.new(Rails.configuration.database_configuration['smf_import'])
21
+ end
22
+
23
+ desc "Import Boards"
24
+ task boards: :environment do
25
+ MyForum::Category.delete_all
26
+ MyForum::Forum.delete_all
27
+
28
+ sql = <<-SQL
29
+ SELECT
30
+ `smf_categories`.`name` AS category_name,
31
+ `smf_boards`.`name` AS board_name,
32
+ `smf_boards`.`description` AS board_description
33
+ FROM smf_boards
34
+ INNER JOIN `smf_categories` ON `smf_boards`.`id_cat` = `smf_categories`.`id_cat`
35
+ SQL
36
+
37
+ user_groups = MyForum::UserGroup.all
38
+
39
+ result = $connection.query sql
40
+ result.each do |row|
41
+ category = MyForum::Category.find_or_create_by(name: row['category_name'])
42
+ category.user_groups << user_groups if user_groups.any?
43
+
44
+ category.forums.create(name: row['board_name'], description: row['board_description'])
45
+ end
46
+ end
47
+
48
+ desc "Import Users"
49
+ task users: :environment do
50
+ MyForum::User.destroy_all
51
+
52
+ user_group = MyForum::UserGroup.where(name: 'Member').first
53
+
54
+ sql = "SELECT member_name, date_registered, real_name, email_address, personal_text, birthdate, website_title, website_url, signature, avatar, is_activated FROM smf_members;"
55
+ result = $connection.query sql
56
+ result.each do |row|
57
+ begin
58
+ date_registered = Time.at(row['date_registered'].to_i) rescue nil
59
+ user = MyForum::User.create!(
60
+ login: row['member_name'],
61
+ email: row['email_address'],
62
+ real_name: row['real_name'],
63
+ birthdate: row['birthdate'],
64
+ signature: row['signature'],
65
+ avatar: row['avatar'],
66
+ created_at: date_registered,
67
+ additional_info: {
68
+ personal_text: row['personal_text'],
69
+ website_title: row['website_title'],
70
+ website_url: row['website_url'],
71
+ is_activated: row['is_activated']
72
+ })
73
+
74
+ user.user_groups << user_group if user_group
75
+ rescue => e
76
+ print e
77
+ end
78
+ end
79
+ end
80
+
81
+ desc "Import Topics and Posts"
82
+ task topics: :environment do
83
+ MyForum::Topic.delete_all
84
+ MyForum::Post.delete_all
85
+
86
+ sql = <<-SQL
87
+ SELECT
88
+ `smf_boards`.`name` AS board_name, `smf_messages`.`poster_email`, `smf_messages`.`poster_name`, `smf_messages`.`body`,
89
+ `smf_messages`.`subject`, `smf_messages`.`poster_time`, `smf_messages`.`id_topic`
90
+ FROM `smf_messages`
91
+ INNER JOIN `smf_boards` ON `smf_messages`.`id_board` = `smf_boards`.`id_board`
92
+ ORDER BY `id_msg` ASC, `id_topic` ASC;
93
+ SQL
94
+ result = $connection.query sql
95
+ result.each do |row|
96
+ begin
97
+ user = MyForum::User.find_by_email(row['poster_email']) || MyForum::User.find_by_login(row['poster_name'])
98
+ user = MyForum::User.create!(login: row['poster_name'], email: row['poster_email'], is_deleted: true) unless user
99
+
100
+ forum = MyForum::Forum.find_or_create_by(name: row['board_name'])
101
+
102
+ # smf does not uses description field, so i use it temponary while import process
103
+ unless topic = MyForum::Topic.where(description: row['id_topic']).first
104
+ topic = forum.topics.create!(name: row['subject'], description: row['id_topic'])
105
+ end
106
+
107
+ post_time = Time.at(row['poster_time'].to_i)
108
+ topic.posts.create!(user: user, text: row['body'], forum_id: forum.id, created_at: post_time, updated_at: post_time)
109
+ rescue => e
110
+ print e
111
+ end
112
+ end
113
+ MyForum::Topic.update_all(description: nil)
114
+
115
+ end
116
+
117
+ desc "Import Private Messages"
118
+ task pms: :environment do
119
+ MyForum::PrivateMessage.delete_all
120
+
121
+ sql = <<-SQL
122
+ SELECT
123
+ smf_personal_messages.msgtime, smf_personal_messages.subject, smf_personal_messages.body, smf_personal_messages.from_name,
124
+ smf_pm_recipients.id_member as to_member, smf_members.member_name
125
+ FROM smf_personal_messages
126
+ LEFT JOIN smf_pm_recipients ON smf_personal_messages.id_pm = smf_pm_recipients.id_pm
127
+ LEFT JOIN smf_members ON smf_members.id_member = smf_pm_recipients.id_member
128
+ SQL
129
+
130
+ result = $connection.query sql
131
+ result.each do |row|
132
+ sender = MyForum::User.find_by_login(row['from_name'])
133
+ recipient = MyForum::User.find_by_login(row['member_name'])
134
+ next unless sender and recipient
135
+
136
+ pm_time = Time.at(row['msgtime'].to_i)
137
+
138
+ MyForum::PrivateMessage.create!(
139
+ sender_id: sender.id,
140
+ sender_login: sender.login,
141
+ recipient_id: recipient.id,
142
+ recipient_login: recipient.login,
143
+ sender_deleted: false,
144
+ recipient_deleted: false,
145
+ unread: false,
146
+ subject: row['subject'],
147
+ body: row['body'],
148
+ created_at: pm_time,
149
+ updated_at: pm_time)
150
+ end
151
+
152
+ end
153
+ end
154
+ end
155
+ end
@@ -0,0 +1,7 @@
1
+ require 'rails_helper'
2
+
3
+ module MyForum
4
+ RSpec.describe Admin::EmoticonsController, type: :controller do
5
+
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'rails_helper'
2
+
3
+ module MyForum
4
+ RSpec.describe Admin::MailController, type: :controller do
5
+
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'rails_helper'
2
+
3
+ module MyForum
4
+ RSpec.describe PrivateMessagesController, type: :controller do
5
+
6
+ end
7
+ end
@@ -0,0 +1,76 @@
1
+ require 'rails_helper'
2
+
3
+ module MyForum
4
+ RSpec.describe UsersController, type: :controller do
5
+ routes { MyForum::Engine.routes }
6
+
7
+ describe 'Loggin in' do
8
+ it 'should login user by password' do
9
+ user = User.create!(login: 'demo', password: '12345678', email: 'demo@example.com')
10
+
11
+ post :signin, user: { login: 'demo', password: '12345678' }
12
+ expect(session[:user_id]).to eq(user.id)
13
+ expect(response).to redirect_to(root_path)
14
+ end
15
+
16
+ it 'should not login user if login or password incorrect' do
17
+ post :signin, user: { login: '', password: '' }
18
+ expect(response).to render_template(:signin)
19
+ expect(session[:user_id]).to eq(nil)
20
+
21
+ post :signin, user: { login: 'wrong', password: 'credentials' }
22
+ expect(response).to render_template(:signin)
23
+ expect(session[:user_id]).to eq(nil)
24
+ end
25
+ end
26
+
27
+ describe "#forgot_password" do
28
+ it 'should send new generated password for user' do
29
+ user = User.create!(login: 'demo', password: '12345678', email: 'demo@example.com')
30
+ session[:user_id] = user.id
31
+ expect(user.valid_password?('12345678')).to be true
32
+
33
+ post :forgot_password, user: { email: 'demo@example.com'}
34
+ expect(user.reload.valid_password?('12345678')).to be false
35
+
36
+ last_delivery = ActionMailer::Base.deliveries.last
37
+ new_password = last_delivery.text_part.body.decoded.split(' ').last
38
+ expect(user.reload.valid_password?(new_password)).to be true
39
+ end
40
+ end
41
+
42
+ describe "#edit" do
43
+ before :each do
44
+ @user = User.create!(login: 'demo', password: '12345678', email: 'demo@example.com')
45
+ session[:user_id] = @user.id
46
+ end
47
+
48
+ it 'should not change password' do
49
+ patch :update, id: @user.id, user: {email: 'abc@google.com', password: ''}
50
+ expect(@user.reload.valid_password?('12345678')).to be true
51
+ expect(@user.reload.email).to eq('abc@google.com')
52
+ end
53
+
54
+ it 'should not change password if old password not given' do
55
+ patch :update, id: @user.id, user: {email: 'abc@google.com', password: 'new_password'}
56
+ expect(@user.reload.valid_password?('new_password')).to be false
57
+ end
58
+
59
+ it 'should update user with password' do
60
+ expect(@user.reload.valid_password?('12345678')).to be true
61
+ patch :update, id: @user.id, user: {email: 'abc@google.com', password: '12345678', new_password: 'new_password'}
62
+ expect(@user.reload.valid_password?('new_password')).to be true
63
+ expect(@user.reload.email).to eq('abc@google.com')
64
+ end
65
+ end
66
+
67
+ describe "#create" do
68
+ it 'should create new user' do
69
+ post :create, user: {email: 'new_user@google.com', password: 'new_user_pass', login: 'new_user'}
70
+ user = User.find_by_email('new_user@google.com')
71
+ expect(user.login).to eq('new_user')
72
+ expect(user.valid_password?('new_user_pass')).to be true
73
+ end
74
+ end
75
+ end
76
+ end
File without changes
File without changes
@@ -10,4 +10,4 @@
10
10
  // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
11
  // about supported directives.
12
12
  //
13
- //= require_tree .
13
+ //= require_tree
@@ -10,6 +10,6 @@
10
10
  * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
11
  * file per style scope.
12
12
  *
13
- *= require_tree .
13
+ *= require_tree
14
14
  *= require_self
15
15
  */
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -20,7 +20,7 @@ Rails.application.configure do
20
20
  # config.action_dispatch.rack_cache = true
21
21
 
22
22
  # Disable Rails's static asset server (Apache or nginx will already do this).
23
- config.serve_static_assets = false
23
+ config.serve_static_files = false
24
24
 
25
25
  # Compress JavaScripts and CSS.
26
26
  config.assets.js_compressor = :uglifier
@@ -13,7 +13,7 @@ Rails.application.configure do
13
13
  config.eager_load = false
14
14
 
15
15
  # Configure static asset server for tests with Cache-Control for performance.
16
- config.serve_static_assets = true
16
+ config.serve_static_files = true
17
17
  config.static_cache_control = 'public, max-age=3600'
18
18
 
19
19
  # Show full error reports and disable caching.
File without changes
File without changes
File without changes
File without changes
File without changes
Binary file
@@ -0,0 +1,159 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended that you check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(version: 20151221205045) do
15
+
16
+ create_table "my_forum_categories", force: :cascade do |t|
17
+ t.string "name"
18
+ t.datetime "created_at", null: false
19
+ t.datetime "updated_at", null: false
20
+ end
21
+
22
+ create_table "my_forum_category_permissions", force: :cascade do |t|
23
+ t.integer "user_group_id"
24
+ t.integer "category_id"
25
+ t.datetime "created_at", null: false
26
+ t.datetime "updated_at", null: false
27
+ end
28
+
29
+ create_table "my_forum_emoticons", force: :cascade do |t|
30
+ t.string "file_name"
31
+ t.string "code"
32
+ t.boolean "is_active", default: true
33
+ t.datetime "created_at", null: false
34
+ t.datetime "updated_at", null: false
35
+ end
36
+
37
+ create_table "my_forum_forums", force: :cascade do |t|
38
+ t.integer "category_id"
39
+ t.string "name"
40
+ t.string "description"
41
+ t.integer "topics_count"
42
+ t.integer "posts_count"
43
+ t.datetime "created_at", null: false
44
+ t.datetime "updated_at", null: false
45
+ end
46
+
47
+ create_table "my_forum_images", force: :cascade do |t|
48
+ t.integer "user_id"
49
+ t.integer "post_id"
50
+ t.string "file_name"
51
+ t.integer "file_size"
52
+ t.string "type"
53
+ t.datetime "created_at", null: false
54
+ t.datetime "updated_at", null: false
55
+ end
56
+
57
+ create_table "my_forum_log_read_marks", force: :cascade do |t|
58
+ t.integer "user_id"
59
+ t.integer "topic_id"
60
+ t.integer "post_id"
61
+ t.datetime "created_at", null: false
62
+ t.datetime "updated_at", null: false
63
+ end
64
+
65
+ create_table "my_forum_posts", force: :cascade do |t|
66
+ t.integer "user_id"
67
+ t.integer "topic_id"
68
+ t.integer "forum_id"
69
+ t.text "text", limit: 4294967295
70
+ t.datetime "created_at", null: false
71
+ t.datetime "updated_at", null: false
72
+ t.boolean "is_deleted", default: false
73
+ end
74
+
75
+ create_table "my_forum_private_messages", force: :cascade do |t|
76
+ t.integer "sender_id"
77
+ t.string "sender_login"
78
+ t.integer "recipient_id"
79
+ t.string "recipient_login"
80
+ t.boolean "sender_deleted", default: false
81
+ t.boolean "recipient_deleted", default: false
82
+ t.boolean "unread", default: true
83
+ t.string "subject"
84
+ t.text "body"
85
+ t.datetime "created_at", null: false
86
+ t.datetime "updated_at", null: false
87
+ end
88
+
89
+ create_table "my_forum_roles", force: :cascade do |t|
90
+ t.string "name"
91
+ t.string "color"
92
+ t.text "rights"
93
+ t.datetime "created_at", null: false
94
+ t.datetime "updated_at", null: false
95
+ end
96
+
97
+ create_table "my_forum_topics", force: :cascade do |t|
98
+ t.integer "forum_id"
99
+ t.integer "user_id"
100
+ t.integer "latest_post_id"
101
+ t.string "name"
102
+ t.string "description"
103
+ t.integer "views"
104
+ t.integer "posts_count", default: 0
105
+ t.boolean "pinned", default: false
106
+ t.boolean "closed", default: false
107
+ t.boolean "deleted", default: false
108
+ t.datetime "created_at", null: false
109
+ t.datetime "updated_at", null: false
110
+ t.boolean "is_deleted", default: false
111
+ end
112
+
113
+ create_table "my_forum_user_group_links", force: :cascade do |t|
114
+ t.integer "user_id"
115
+ t.integer "user_group_id"
116
+ t.datetime "created_at", null: false
117
+ t.datetime "updated_at", null: false
118
+ end
119
+
120
+ create_table "my_forum_user_groups", force: :cascade do |t|
121
+ t.string "name"
122
+ t.string "html_color"
123
+ t.boolean "default", default: false
124
+ t.datetime "created_at", null: false
125
+ t.datetime "updated_at", null: false
126
+ end
127
+
128
+ create_table "my_forum_user_roles", force: :cascade do |t|
129
+ t.integer "user_id"
130
+ t.integer "role_id"
131
+ t.datetime "created_at", null: false
132
+ t.datetime "updated_at", null: false
133
+ end
134
+
135
+ create_table "my_forum_users", force: :cascade do |t|
136
+ t.string "login"
137
+ t.string "password"
138
+ t.string "salt"
139
+ t.string "real_name"
140
+ t.integer "gender"
141
+ t.date "birthdate"
142
+ t.text "signature"
143
+ t.text "avatar_url"
144
+ t.string "location"
145
+ t.string "user_ip"
146
+ t.text "additional_info"
147
+ t.string "email"
148
+ t.integer "posts_count"
149
+ t.boolean "activated", default: false
150
+ t.boolean "is_admin", default: false
151
+ t.boolean "is_moderator", default: false
152
+ t.boolean "is_deleted", default: false
153
+ t.boolean "permanently_banned", default: false
154
+ t.datetime "created_at", null: false
155
+ t.datetime "updated_at", null: false
156
+ t.datetime "last_logged_in"
157
+ end
158
+
159
+ end
Binary file
@@ -0,0 +1,12 @@
1
+ MyForum::User Load (0.1ms) SELECT "my_forum_users".* FROM "my_forum_users" ORDER BY "my_forum_users"."id" DESC LIMIT 1
2
+ SQLite3::SQLException: no such table: my_forum_users: SELECT "my_forum_users".* FROM "my_forum_users" ORDER BY "my_forum_users"."id" DESC LIMIT 1
3
+ MyForum::User Load (0.1ms) SELECT "my_forum_users".* FROM "my_forum_users" ORDER BY "my_forum_users"."id" DESC LIMIT 1
4
+ SQLite3::SQLException: no such table: my_forum_users: SELECT "my_forum_users".* FROM "my_forum_users" ORDER BY "my_forum_users"."id" DESC LIMIT 1
5
+ MyForum::User Load (0.1ms) SELECT "my_forum_users".* FROM "my_forum_users" ORDER BY "my_forum_users"."id" DESC LIMIT 1
6
+ SQLite3::SQLException: no such table: my_forum_users: SELECT "my_forum_users".* FROM "my_forum_users" ORDER BY "my_forum_users"."id" DESC LIMIT 1
7
+  (1.7ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
8
+  (0.1ms) select sqlite_version(*)
9
+  (1.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
10
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
11
+ MyForum::User Load (0.1ms) SELECT "my_forum_users".* FROM "my_forum_users" ORDER BY "my_forum_users"."id" DESC LIMIT 1
12
+ SQLite3::SQLException: no such table: my_forum_users: SELECT "my_forum_users".* FROM "my_forum_users" ORDER BY "my_forum_users"."id" DESC LIMIT 1
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,24 @@
1
+ require 'rails_helper'
2
+
3
+ module MyForum
4
+ RSpec.describe PostsHelper, type: :helper do
5
+ describe 'Youtube' do
6
+ it 'should parse youtube links' do
7
+ {
8
+ 'some text https://www.youtube.com/watch?v=HX-Jz3GESM0 text' => "some text <iframe width='560' height='315' src='https://www.youtube.com/embed/HX-Jz3GESM0' frameborder='0' allowfullscreen></iframe> text",
9
+ 'some text https://www.youtube.com/watch?v=IEmU6Oqpx7E text' => "some text <iframe width='560' height='315' src='https://www.youtube.com/embed/IEmU6Oqpx7E' frameborder='0' allowfullscreen></iframe> text",
10
+ 'some text http://youtu.be/croRTTsFtdw' => "some text <iframe width='560' height='315' src='https://www.youtube.com/embed/croRTTsFtdw' frameborder='0' allowfullscreen></iframe>",
11
+ 'http://www.youtube.com/watch?v=TsDbnX_YgU4#ws' => "<iframe width='560' height='315' src='https://www.youtube.com/embed/TsDbnX_YgU4' frameborder='0' allowfullscreen></iframe>#ws"
12
+
13
+ }.each do |text, formatted_text|
14
+ expect(format_bbcode(text.dup)).to eq formatted_text
15
+ end
16
+ end
17
+
18
+ end
19
+
20
+ def emoticons_list
21
+ []
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,17 @@
1
+ require 'rails_helper'
2
+
3
+ # Specs in this file have access to a helper object that includes
4
+ # the PrivateMessagesHelper. For example:
5
+ #
6
+ # describe PrivateMessagesHelper do
7
+ # describe "string concat" do
8
+ # it "concats two strings with spaces" do
9
+ # expect(helper.concat_strings("this","that")).to eq("this that")
10
+ # end
11
+ # end
12
+ # end
13
+ module MyForum
14
+ RSpec.describe PrivateMessagesHelper, type: :helper do
15
+ pending "add some examples to (or delete) #{__FILE__}"
16
+ end
17
+ end
@@ -0,0 +1,7 @@
1
+ require 'rails_helper'
2
+
3
+ module MyForum
4
+ RSpec.describe Emoticon, type: :model do
5
+ pending "add some examples to (or delete) #{__FILE__}"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'rails_helper'
2
+
3
+ module MyForum
4
+ RSpec.describe PrivateMessage, type: :model do
5
+ pending "add some examples to (or delete) #{__FILE__}"
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ require 'rails_helper'
2
+
3
+ module MyForum
4
+ RSpec.describe User, type: :model do
5
+ describe 'User password' do
6
+ it 'should save user with password' do
7
+ user = User.new
8
+ user.password = 'test'
9
+ expect(user.save).to eq(true)
10
+ end
11
+ end
12
+ end
13
+ end