Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: laknock/Macrobo
base: 9348397511
...
head fork: laknock/Macrobo
compare: 71edaa96bd
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 18 files changed
  • 0 commit comments
  • 1 contributor
Commits on Sep 13, 2012
@laknock add new column 12dd171
Commits on Sep 18, 2012
@laknock add spork gem 71edaa9
View
10 Gemfile
@@ -16,6 +16,8 @@ group :assets do
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
+ gem "execjs"
+ gem "therubyracer"
gem 'uglifier', '>= 1.0.3'
gem 'bootstrap-sass', '~> 2.1.0.0'
@@ -24,11 +26,15 @@ end
gem 'jquery-rails'
gem "rspec-rails", ">= 2.10.1", :group => [:development, :test]
gem "factory_girl_rails", ">= 3.3.0", :group => [:development, :test]
-gem "shoulda-matchers", :group => :test
-gem "capybara", ">= 1.1.2", :group => :test
gem "devise", ">= 2.1.0"
gem "annotate", ">= 2.5.0"
+group :test do
+ gem "spork"
+ gem "capybara", ">= 1.1.2"
+ gem "shoulda-matchers"
+end
+
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
View
8 Gemfile.lock
@@ -67,6 +67,7 @@ GEM
factory_girl (~> 4.0.0)
railties (>= 3.0.0)
ffi (1.1.5)
+ ffi (1.1.5-x86-mingw32)
hike (1.2.1)
i18n (0.6.1)
journey (1.0.4)
@@ -74,6 +75,7 @@ GEM
railties (>= 3.1.0, < 5.0)
thor (~> 0.14)
json (1.7.5)
+ libv8 (3.3.10.4)
libwebsocket (0.1.5)
addressable
mail (2.4.4)
@@ -137,12 +139,15 @@ GEM
rubyzip
shoulda-matchers (1.3.0)
activesupport (>= 3.0.0)
+ spork (0.9.2)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.6)
sqlite3 (1.3.6-x86-mingw32)
+ therubyracer (0.10.2)
+ libv8 (~> 3.3.10)
thor (0.16.0)
tilt (1.3.3)
treetop (1.4.10)
@@ -167,11 +172,14 @@ DEPENDENCIES
capybara (>= 1.1.2)
coffee-rails (~> 3.2.1)
devise (>= 2.1.0)
+ execjs
factory_girl_rails (>= 3.3.0)
jquery-rails
rails (= 3.2.8)
rspec-rails (>= 2.10.1)
sass-rails (~> 3.2.3)
shoulda-matchers
+ spork
sqlite3
+ therubyracer
uglifier (>= 1.0.3)
View
19 app/controllers/posts_controller.rb
@@ -5,5 +5,24 @@ class PostsController < ApplicationController
def new
@post = Post.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render :json => @post }
+ end
+ end
+
+ def create
+ @post = Post.new params[:post]
+
+ respond_to do |format|
+ if @post.save
+ format.html { redirect_to writers_path }
+ format.json
+ else
+ format.html { render "new" }
+ format.json
+ end
+ end
end
end
View
2  app/models/post.rb
@@ -13,7 +13,5 @@
class Post < ActiveRecord::Base
attr_accessible :title, :content
- belongs_to :writer
-
validates :title, :content, :presence => true
end
View
1  app/models/writer.rb
@@ -28,5 +28,4 @@ class Writer < ActiveRecord::Base
attr_accessible :email, :password, :password_confirmation, :remember_me
# attr_accessible :title, :body
- has_many :posts
end
View
13 app/views/layouts/writers.html.erb
@@ -5,17 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
- <%= javascript_include_tag 'ckeditor/ckeditor.js' %>
- <script type="text/javascript">
- $(document).ready(function() {
- if ($('textarea').length > 0) {
- var data = $('textarea');
- $.each(data, function(i) {
- CKEDITOR.replace(data[i].id);
- });
- }
- });
- </script>
<%= csrf_meta_tags %>
</head>
<body>
@@ -25,7 +14,6 @@
<ul class="nav">
<li><%= link_to "return to blog", '#', :class => "brand" %></li>
<% if writer_signed_in? %>
- <li><%= link_to "return to post list", writers_path %></li>
<li><%= link_to current_writer.email, edit_writer_registration_path %></li>
<li><%= link_to "Sign out", destroy_writer_session_path, :method => :delete %></li>
<% else %>
@@ -38,5 +26,6 @@
</div>
<%= yield %>
+
</body>
</html>
View
17 app/views/posts/_post.html.erb
@@ -0,0 +1,17 @@
+<%= form_for @post, :html => { :class => "form-horizontal" } do |f| %>
+ <legend>Blog Post</legend>
+
+ <div class="row">
+ <%= f.label :title, :class => "span2" %>
+ <%= f.text_field :title, :class=> "span10" %>
+ </div>
+ <div class="row">
+ <%= f.label :content, :class => "span2" %>
+ <%= f.text_area :content, :class => "span10" %>
+ </div>
+
+ <div class="form-actions">
+ <%= f.submit :class => "btn btn-primary" %>
+ <%= f.submit "Save as Draft", :class => "btn btn-success" %>
+ </div>
+<% end %>
View
22 app/views/posts/new.html.erb
@@ -1,17 +1,9 @@
-<div class="container">
- <%= form_for @post, :html => { :class => "form-horizontal" } do |f| %>
- <legend>Create New Post</legend>
+<div class="container admin-container">
+ <div class="row-fluid">
+ <div class="span9">
+ <%= render @post %>
+ </div>
- <div class="row">
- <%= f.label :title, :class => "span2" %>
- <%= f.text_field :title, :class=> "span7" %>
- </div>
- <%= f.label :content %>
- <%= f.text_area :content %>
-
- <div class="form-actions">
- <%= f.submit "Create", :class => "btn btn-primary" %>
- <%= f.submit "Draft", :class => "btn btn-success" %>
- </div>
- <% end %>
+ <%= render "writers/right_nav" %>
+ </div>
</div>
View
6 app/views/writers/_right_nav.html.erb
@@ -0,0 +1,6 @@
+<div class="span3">
+ <ul class="nav nav-tabs nav-stacked">
+ <li><%= link_to "Post list", writers_path %></li>
+ <li><%= link_to "Draft list", "#" %></li>
+ </ul>
+</div>
View
14 app/views/writers/home.html.erb
@@ -1,7 +1,17 @@
<div class="container admin-container">
<% unless writer_signed_in? %>
+
<h1>Please sign in or create a new writer acount</h1>
+
<% else %>
- <%= link_to "New Post", new_post_path, :class => "btn btn-danger" %>
+
+ <div class="row-fluid">
+ <div class="span9">
+ <%= link_to "New Post", new_post_path, :class => "btn btn-danger" %>
+ </div>
+
+ <%= render "right_nav" %>
+ </div>
+
<% end %>
-</div>
+</div>
View
86 db/schema.rb
@@ -1,43 +1,43 @@
-# encoding: UTF-8
-# This file is auto-generated from the current state of the database. Instead
-# of editing this file, please use the migrations feature of Active Record to
-# incrementally modify your database, and then regenerate this schema definition.
-#
-# Note that this schema.rb definition is the authoritative source for your
-# database schema. If you need to create the application database on another
-# system, you should be using db:schema:load, not running all the migrations
-# from scratch. The latter is a flawed and unsustainable approach (the more migrations
-# you'll amass, the slower it'll run and the greater likelihood for issues).
-#
-# It's strongly recommended to check this file into your version control system.
-
-ActiveRecord::Schema.define(:version => 20120911165429) do
-
- create_table "posts", :force => true do |t|
- t.string "title"
- t.text "content"
- t.integer "writer_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.boolean "draft", :default => false
- end
-
- create_table "writers", :force => true do |t|
- t.string "email", :default => "", :null => false
- t.string "encrypted_password", :default => "", :null => false
- t.string "reset_password_token"
- t.datetime "reset_password_sent_at"
- t.datetime "remember_created_at"
- t.integer "sign_in_count", :default => 0
- t.datetime "current_sign_in_at"
- t.datetime "last_sign_in_at"
- t.string "current_sign_in_ip"
- t.string "last_sign_in_ip"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- end
-
- add_index "writers", ["email"], :name => "index_writers_on_email", :unique => true
- add_index "writers", ["reset_password_token"], :name => "index_writers_on_reset_password_token", :unique => true
-
-end
+# encoding: UTF-8
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 20120911165429) do
+
+ create_table "posts", :force => true do |t|
+ t.string "title"
+ t.text "content"
+ t.integer "writer_id"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.boolean "draft", :default => false
+ end
+
+ create_table "writers", :force => true do |t|
+ t.string "email", :default => "", :null => false
+ t.string "encrypted_password", :default => "", :null => false
+ t.string "reset_password_token"
+ t.datetime "reset_password_sent_at"
+ t.datetime "remember_created_at"
+ t.integer "sign_in_count", :default => 0
+ t.datetime "current_sign_in_at"
+ t.datetime "last_sign_in_at"
+ t.string "current_sign_in_ip"
+ t.string "last_sign_in_ip"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ add_index "writers", ["email"], :name => "index_writers_on_email", :unique => true
+ add_index "writers", ["reset_password_token"], :name => "index_writers_on_reset_password_token", :unique => true
+
+end
View
12 spec/controllers/posts_controller_spec.rb
@@ -11,4 +11,16 @@
response.should render_template(:new)
end
end
+
+ describe "push the POST button" do
+ before :each do
+ writer = FactoryGirl.create :writer
+ sign_in writer
+ end
+
+ it "params commit should be Save Post" do
+ post :create, p: FactoryGirl.attributes_for(:post)
+
+ end
+ end
end
View
2  spec/helpers/macross_helper_spec.rb
@@ -11,5 +11,5 @@
# end
# end
describe MacrossHelper do
- pending "add some examples to (or delete) #{__FILE__}"
+
end
View
2  spec/helpers/posts_helper_spec.rb
@@ -11,5 +11,5 @@
# end
# end
describe PostsHelper do
- pending "add some examples to (or delete) #{__FILE__}"
+
end
View
2  spec/helpers/writers_helper_spec.rb
@@ -11,5 +11,5 @@
# end
# end
describe WritersHelper do
- pending "add some examples to (or delete) #{__FILE__}"
+
end
View
2  spec/models/post_spec.rb
@@ -17,7 +17,7 @@
FactoryGirl.create(:post).should be_valid
end
- it { should belong_to(:writer) }
+ # it { should belong_to(:writer) }
it { should validate_presence_of(:title) }
View
2  spec/models/writer_spec.rb
@@ -24,5 +24,5 @@
FactoryGirl.create(:writer).should be_valid
end
- it { should have_many(:posts) }
+ #it { should have_many(:posts) }
end
View
90 spec/spec_helper.rb
@@ -1,38 +1,54 @@
-# This file is copied to spec/ when you run 'rails generate rspec:install'
-ENV["RAILS_ENV"] ||= 'test'
-require File.expand_path("../../config/environment", __FILE__)
-require 'rspec/rails'
-require 'rspec/autorun'
-
-# Requires supporting ruby files with custom matchers and macros, etc,
-# in spec/support/ and its subdirectories.
-Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
-
-RSpec.configure do |config|
- # ## Mock Framework
- #
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
- #
- # config.mock_with :mocha
- # config.mock_with :flexmock
- # config.mock_with :rr
-
- # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
-
- # If you're not using ActiveRecord, or you'd prefer not to run each of your
- # examples within a transaction, remove the following line or assign false
- # instead of true.
- config.use_transactional_fixtures = true
-
- # If true, the base class of anonymous controllers will be inferred
- # automatically. This will be the default behavior in future versions of
- # rspec-rails.
- config.infer_base_class_for_anonymous_controllers = false
-
- # Run specs in random order to surface order dependencies. If you find an
- # order dependency and want to debug it, you can fix the order by providing
- # the seed, which is printed after each run.
- # --seed 1234
- config.order = "random"
+require 'rubygems'
+require 'spork'
+#uncomment the following line to use spork with the debugger
+#require 'spork/ext/ruby-debug'
+
+Spork.prefork do
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
+ ENV["RAILS_ENV"] ||= 'test'
+ require File.expand_path("../../config/environment", __FILE__)
+ require 'rspec/rails'
+ require 'rspec/autorun'
+ require 'capybara/rspec'
+
+ # Requires supporting ruby files with custom matchers and macros, etc,
+ # in spec/support/ and its subdirectories.
+ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
+
+ RSpec.configure do |config|
+ # ## Mock Framework
+ #
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
+ #
+ # config.mock_with :mocha
+ # config.mock_with :flexmock
+ # config.mock_with :rr
+
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
+
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
+ # examples within a transaction, remove the following line or assign false
+ # instead of true.
+ config.use_transactional_fixtures = true
+
+ # If true, the base class of anonymous controllers will be inferred
+ # automatically. This will be the default behavior in future versions of
+ # rspec-rails.
+ config.infer_base_class_for_anonymous_controllers = false
+
+ # Run specs in random order to surface order dependencies. If you find an
+ # order dependency and want to debug it, you can fix the order by providing
+ # the seed, which is printed after each run.
+ # --seed 1234
+ config.order = "random"
+ end
end
+
+Spork.each_run do
+ # This code will be run each time you run your specs.
+
+end
+
+
+

No commit comments for this range

Something went wrong with that request. Please try again.