fembem-forem 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/app/controllers/forem/application_controller.rb +17 -0
- data/app/models/forem/topic.rb +1 -1
- data/app/views/forem/topics/index.html.erb +2 -1
- data/app/views/layouts/forem/{application.html.erb → application.html.erb.example} +0 -0
- data/lib/forem/version.rb +1 -1
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/fake_controller.rb +5 -0
- data/spec/dummy/app/views/layouts/application.html.erb +4 -0
- data/spec/dummy/config/routes.rb +1 -0
- data/spec/integration/posts_spec.rb +5 -1
- metadata +5 -5
data/Gemfile.lock
CHANGED
@@ -1,7 +1,24 @@
|
|
1
1
|
module Forem
|
2
|
+
|
2
3
|
class ApplicationController < ::ApplicationController
|
3
4
|
|
5
|
+
before_filter :set_user_from_session
|
6
|
+
before_filter :method_in_main_app
|
7
|
+
|
4
8
|
private
|
9
|
+
|
10
|
+
def set_user_from_session
|
11
|
+
if session['user']
|
12
|
+
ApplicationController.class_eval <<-STRING
|
13
|
+
def current_user
|
14
|
+
User.find_or_create_by_login("forem_user")
|
15
|
+
end
|
16
|
+
|
17
|
+
helper_method :current_user
|
18
|
+
STRING
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
5
22
|
def authenticate_forem_user!
|
6
23
|
if !current_user
|
7
24
|
flash[:notice] = "You must be authenticated before you can do that."
|
data/app/models/forem/topic.rb
CHANGED
@@ -18,7 +18,8 @@
|
|
18
18
|
<tr>
|
19
19
|
<td id='topic_subject'><%= link_to topic.subject, topic %></td>
|
20
20
|
<td id='posts_count'><%= topic.posts_count %></td>
|
21
|
-
|
21
|
+
<% last_post = topic.last_post %>
|
22
|
+
<td id='last_post'>last post was <%= time_ago_in_words(last_post.created_at) %> ago by <%= last_post.user %></td>
|
22
23
|
</tr>
|
23
24
|
<% end %>
|
24
25
|
</tbody>
|
File without changes
|
data/lib/forem/version.rb
CHANGED
@@ -2,4 +2,9 @@ class FakeController < ApplicationController
|
|
2
2
|
def sign_in
|
3
3
|
render :text => "Placeholder login page."
|
4
4
|
end
|
5
|
+
|
6
|
+
def signed_in
|
7
|
+
session['user'] = User.find_or_create_by_login("forem_user").login
|
8
|
+
render :text => "You are now signed in as #{session['user']}."
|
9
|
+
end
|
5
10
|
end
|
data/spec/dummy/config/routes.rb
CHANGED
@@ -2,10 +2,14 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "posts" do
|
4
4
|
before do
|
5
|
+
#Forem:Post.destroy_all
|
6
|
+
#Forem:Topic.destroy_all
|
5
7
|
@user = User.create!(:login => "some_guy")
|
6
8
|
@topic = Forem::Topic.new(:subject => "First topic!", :user => @user)
|
7
9
|
@topic.posts.build(:text => "First post!")
|
8
10
|
@topic.save!
|
11
|
+
puts 'topic: ' + @topic.id.to_s
|
12
|
+
puts @topic.posts.inspect
|
9
13
|
end
|
10
14
|
context "unauthenticated users" do
|
11
15
|
before do
|
@@ -20,7 +24,7 @@ describe "posts" do
|
|
20
24
|
within "#topics tbody td#posts_count" do
|
21
25
|
page.should have_content("1")
|
22
26
|
end
|
23
|
-
within "#topics tbody td#last_post" do
|
27
|
+
within "#topics tbody tr:last td#last_post" do
|
24
28
|
page.should have_content("last post was less than a minute ago by some_guy")
|
25
29
|
end
|
26
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fembem-forem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -122,7 +122,7 @@ files:
|
|
122
122
|
- app/views/forem/topics/index.html.erb
|
123
123
|
- app/views/forem/topics/new.html.erb
|
124
124
|
- app/views/forem/topics/show.html.erb
|
125
|
-
- app/views/layouts/forem/application.html.erb
|
125
|
+
- app/views/layouts/forem/application.html.erb.example
|
126
126
|
- bin/erubis
|
127
127
|
- bin/rackup
|
128
128
|
- bin/rails
|
@@ -200,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
200
200
|
version: '0'
|
201
201
|
segments:
|
202
202
|
- 0
|
203
|
-
hash: -
|
203
|
+
hash: -641642705
|
204
204
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
205
|
none: false
|
206
206
|
requirements:
|
@@ -209,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
209
|
version: '0'
|
210
210
|
segments:
|
211
211
|
- 0
|
212
|
-
hash: -
|
212
|
+
hash: -641642705
|
213
213
|
requirements: []
|
214
214
|
rubyforge_project:
|
215
215
|
rubygems_version: 1.8.25
|