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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fembem-forem (0.0.2)
4
+ fembem-forem (0.0.3)
5
5
  rails (~> 3.1.3)
6
6
 
7
7
  GEM
@@ -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."
@@ -10,7 +10,7 @@ module Forem
10
10
  before_save :set_post_user
11
11
 
12
12
  def last_post
13
- Post.order("created_at").last
13
+ posts.last
14
14
  end
15
15
 
16
16
  private
@@ -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
- <td id='last_post'>last post was <%= time_ago_in_words(topic.last_post.created_at) %> ago by <%= topic.last_post.user %></td>
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>
@@ -1,3 +1,3 @@
1
1
  module Forem
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,3 +1,8 @@
1
1
  class ApplicationController < ActionController::Base
2
2
  protect_from_forgery
3
+
4
+ def method_in_main_app
5
+ #puts "in main app!"
6
+ end
7
+
3
8
  end
@@ -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
@@ -8,6 +8,10 @@
8
8
  </head>
9
9
  <body>
10
10
 
11
+ <% flash.each do |key, message| %>
12
+ <div id='flash_<%= key %>'><%= message %></div>
13
+ <% end %>
14
+
11
15
  <%= yield %>
12
16
 
13
17
  </body>
@@ -3,5 +3,6 @@ Rails.application.routes.draw do
3
3
  mount Forem::Engine => "/forem"
4
4
 
5
5
  match "/sign_in", :to => "fake#sign_in", :as => "sign_in"
6
+ match "/signed_in", :to => "fake#signed_in", :as => "signed_in"
6
7
 
7
8
  end
@@ -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.2
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-22 00:00:00.000000000 Z
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: -733322225
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: -733322225
212
+ hash: -641642705
213
213
  requirements: []
214
214
  rubyforge_project:
215
215
  rubygems_version: 1.8.25