Permalink
Browse files

added travis-ci config and modified code to work on ruby 1.8.7

  • Loading branch information...
jipiboily
jipiboily committed Apr 21, 2012
1 parent 7cad814 commit e995e899a075be9f568f88968d8611615505a0a4
Showing with 113 additions and 80 deletions.
  1. +13 −0 .travis.yml
  2. +5 −0 Gemfile
  3. +5 −5 app/controllers/monologue/admin/posts_controller.rb
  4. +3 −3 app/controllers/monologue/posts_controller.rb
  5. +7 −7 app/form_builders/monologue_admin_form_builder.rb
  6. +3 −3 app/models/monologue/post.rb
  7. +6 −6 app/models/monologue/posts_revision.rb
  8. +1 −1 app/views/layouts/monologue/admin.html.erb
  9. +1 −1 app/views/layouts/monologue/admin/_nav_bar.html.erb
  10. +6 −6 app/views/monologue/admin/posts/_form.html.erb
  11. +2 −2 app/views/monologue/admin/posts/edit.html.erb
  12. +2 −2 app/views/monologue/admin/posts/index.html.erb
  13. +1 −1 app/views/monologue/admin/posts/new.html.erb
  14. +1 −1 app/views/monologue/admin/sessions/new.html.erb
  15. +2 −2 app/views/monologue/posts/_pagination.html.erb
  16. +2 −2 app/views/monologue/posts/index.html.erb
  17. +1 −1 app/views/monologue/posts/show.html.erb
  18. +6 −6 config/routes.rb
  19. +1 −1 db/migrate/20120120193858_create_monologue_posts_revisions.rb
  20. +1 −1 db/seeds.rb
  21. +15 −0 spec/dummy/config/database-travis.yml
  22. +1 −1 spec/dummy/config/database.yml
  23. +4 −4 spec/factories/monologue_posts_and_revisions.rb
  24. +1 −1 spec/factories/monologue_users.rb
  25. +2 −2 spec/models/monologue/post_spec.rb
  26. +1 −1 spec/models/monologue/posts_revision_spec.rb
  27. +13 −13 spec/requests/admin/posts_spec.rb
  28. +2 −2 spec/requests/admin/sessions_spec.rb
  29. +1 −1 spec/requests/cache_spec.rb
  30. +1 −1 spec/requests/pagination_spec.rb
  31. +1 −1 spec/requests/preview_spec.rb
  32. +2 −2 spec/support/login_helpers.rb
View
@@ -0,0 +1,13 @@
+language: ruby
+before_script:
+ - export DISPLAY=:99.0
+ - sh -e /etc/init.d/xvfb start
+ - mv spec/dummy/config/database-travis.yml spec/dummy/config/database.yml
+ - bundle exec rake db:create db:migrate
+rvm:
+ - 1.8.7
+ - 1.9.2
+ - 1.9.3
+env:
+ - DB=mysql DB_USERNAME=root
+ - DB=postgresql DB_USERNAME=postgres
View
@@ -20,4 +20,9 @@ gem "jquery-rails"
group :development do
gem "thin"
gem 'rails', '3.2.3'
+
+ if RUBY_PLATFORM.downcase.include?("darwin")
+ gem 'rb-fsevent'
+ gem 'growl'
+ end
end
@@ -1,6 +1,6 @@
class Monologue::Admin::PostsController < Monologue::Admin::BaseController
respond_to :html
- cache_sweeper Monologue::PostsSweeper, only: [:create, :update, :destroy]
+ cache_sweeper Monologue::PostsSweeper, :only => [:create, :update, :destroy]
def index
@posts = Monologue::Post.includes(:posts_revisions).joins(:posts_revisions).order("published_at DESC").all
@@ -20,7 +20,7 @@ def create
@revision.user_id = current_user.id
if @post.save
- redirect_to edit_admin_post_path(@post), notice: 'Monologue created'
+ redirect_to edit_admin_post_path(@post), :notice => 'Monologue created'
else
render :action => "new"
end
@@ -37,7 +37,7 @@ def update
@revision = @post.posts_revisions.build(params[:post][:posts_revision])
@revision.user_id = current_user.id
if @post.save
- redirect_to edit_admin_post_path(@post), notice: 'Monologue saved'
+ redirect_to edit_admin_post_path(@post), :notice => 'Monologue saved'
else
render :edit
end
@@ -46,9 +46,9 @@ def update
def destroy
post = Monologue::Post.find(params[:id])
if post.destroy
- redirect_to admin_posts_path, notice: "Monologue removed"
+ redirect_to admin_posts_path, :notice => "Monologue removed"
else
- redirect_to admin_posts_path, alert: "Failed to remove monologue!"
+ redirect_to admin_posts_path, :alert => "Failed to remove monologue!"
end
end
end
@@ -1,5 +1,5 @@
class Monologue::PostsController < Monologue::ApplicationController
- caches_page :index, :show, :feed , if: Proc.new { current_user.nil? }
+ caches_page :index, :show, :feed , :if => Proc.new { current_user.nil? }
def index
@page = params[:page].nil? ? 1 : params[:page]
@@ -8,9 +8,9 @@ def index
def show
unless current_user
- post = Monologue::Post.published.where("monologue_posts_revisions.url = :url", {url: root_path + params[:post_url]}).first
+ post = Monologue::Post.published.where("monologue_posts_revisions.url = :url", {:url => root_path + params[:post_url]}).first
else
- post = Monologue::Post.default.where("monologue_posts_revisions.url = :url", {url: root_path + params[:post_url]}).first
+ post = Monologue::Post.default.where("monologue_posts_revisions.url = :url", {:url => root_path + params[:post_url]}).first
end
if post.nil?
not_found
@@ -1,9 +1,9 @@
class MonologueAdminFormBuilder < ActionView::Helpers::FormBuilder
- delegate :content_tag, :tag, to: :@template
+ delegate :content_tag, :tag, :to => :@template
%w[text_field text_area password_field collection_select select file_field].each do |method_name|
define_method(method_name) do |name, *args|
- content_tag :div, class: "field" do
+ content_tag :div, :class => "field" do
field_label(name, *args) + super(name, *args)
end
end
@@ -12,24 +12,24 @@ class MonologueAdminFormBuilder < ActionView::Helpers::FormBuilder
def check_box(name, *args)
options = args.extract_options!
required = object.class.validators_on(name).any? { |v| v.kind_of? ActiveModel::Validations::PresenceValidator }
- content_tag :label, class: (required ? "required checkbox inline" : "checkbox inline") do
+ content_tag :label, :class => (required ? "required checkbox inline" : "checkbox inline") do
super + (options[:label] || name)
end
end
def collection_check_boxes(attribute, records, record_id, record_name)
- content_tag :div, class: "field" do
+ content_tag :div, :class => "field" do
@template.hidden_field_tag("#{object_name}[#{attribute}][]") +
records.map do |record|
element_id = "#{object_name}_#{attribute}_#{record.send(record_id)}"
- checkbox = @template.check_box_tag("#{object_name}[#{attribute}][]", record.send(record_id), object.send(attribute).include?(record.send(record_id)), id: element_id)
+ checkbox = @template.check_box_tag("#{object_name}[#{attribute}][]", record.send(record_id), object.send(attribute).include?(record.send(record_id)), :id => element_id)
checkbox + " " + @template.label_tag(element_id, record.send(record_name))
end.join(tag(:br)).html_safe
end
end
def submit(*args)
- content_tag :div, class: "actions" do
+ content_tag :div, :class => "actions" do
super
end
end
@@ -52,7 +52,7 @@ def error_messages
def field_label(name, *args)
options = args.extract_options!
required = object.class.validators_on(name).any? { |v| v.kind_of? ActiveModel::Validations::PresenceValidator }
- label(name, options[:label], class: ("required" if required))
+ label(name, options[:label], :class => ("required" if required))
end
def objectify_options(options)
@@ -1,6 +1,6 @@
module Monologue
class Post < ActiveRecord::Base
- has_many :posts_revisions, dependent: :destroy
+ has_many :posts_revisions, :dependent => :destroy
accepts_nested_attributes_for :posts_revisions
attr_accessible :posts_revisions_attributes
@@ -9,9 +9,9 @@ class Post < ActiveRecord::Base
scope :default, includes(:posts_revisions).where("posts_revision_id = monologue_posts_revisions.id").order("published_at DESC")
- scope :published, default.where(published: true)
+ scope :published, default.where(:published => true)
- validates :posts_revision_id, uniqueness: true
+ validates :posts_revision_id, :uniqueness => true
def just_the_revision_one_before
self.posts_revisions.where("post_id = ?", self.id).order("monologue_posts_revisions.updated_at DESC").offset(1).limit(1).first
@@ -10,12 +10,12 @@ class PostsRevision < ActiveRecord::Base
belongs_to :post
belongs_to :user
- validates :title, presence: true
- validates :content, presence: true
- validates :url, presence: true
- validates :user_id, presence: true
-# validates :post_id, presence: true # TODO: do something about this validation on the first creation of a POST
- validates :published_at, presence: true
+ validates :title, :presence => true
+ validates :content, :presence => true
+ validates :url, :presence => true
+ validates :user_id, :presence => true
+# validates :post_id, :presence => true # TODO: do something about this validation on the first creation of a POST
+ validates :published_at, :presence => true
def latest_revision_is_current
post = Monologue::Post.find(self.post_id)
@@ -12,7 +12,7 @@
<% end %>
<div class="container">
<% flash.each do |name, msg| %>
- <%= content_tag :div, msg, id: "flash_#{name}", class: (name == :notice ? "alert alert-info" : "alert alert-error") %>
+ <%= content_tag :div, msg, :id => "flash_#{name}", :class => (name == :notice ? "alert alert-info" : "alert alert-error") %>
<% end %>
<%= yield %>
@@ -1,7 +1,7 @@
<div class="navbar">
<div class="navbar-inner">
<div class="container">
- <%= link_to "Monologue", admin_path, class: "brand" %>
+ <%= link_to "Monologue", admin_path, :class => "brand" %>
<ul class="nav pull-left">
<li class="<%= request.fullpath === new_admin_post_path ? "active":"" %>">
@@ -1,13 +1,13 @@
<%= post.error_messages %>
<%= post.fields_for @revision do |revision| %>
- <%= revision.text_field :title, label: t(".title"), class: "span6" %>
- <%= revision.text_area :content, label: t(".content"), class: "span12 ckeditor" %>
- <%= revision.text_field :url, label: raw(t(".url")) %>
- <%= revision.text_field :published_at, label: t(".published_at"), data: {datepicker:"datepicker"}, value: revision.object.published_at.nil? ? "" : revision.object.published_at.strftime("%Y-%m-%d") %>
+ <%= revision.text_field :title, :label => t(".title"), :class => "span6" %>
+ <%= revision.text_area :content, :label => t(".content"), :class => "span12 ckeditor" %>
+ <%= revision.text_field :url, :label => raw(t(".url")) %>
+ <%= revision.text_field :published_at, :label => t(".published_at"), :data => {:datepicker => "datepicker"}, :value => revision.object.published_at.nil? ? "" : revision.object.published_at.strftime("%Y-%m-%d") %>
<% end %>
-<%= post.check_box :published, label: t(".published") %>
+<%= post.check_box :published, :label => t(".published") %>
-<%= post.submit t(".save"), class: "btn btn-large btn-primary" %> <a href="<%= @revision.url %>" target="_blank" class="btn btn-large"><%= t(".preview") %></a>
+<%= post.submit t(".save"), :class => "btn btn-large btn-primary" %> <a href="<%= @revision.url %>" target="_blank" class="btn btn-large"><%= t(".preview") %></a>
<script>
if($.fn.datepicker.defaults_<%= I18n.locale %>){
@@ -1,4 +1,4 @@
<h1><%= t(".header") %> "<%= @post.posts_revisions.last.title %>"</h1>
-<%= monologue_admin_form_for ["admin", @post], method: :put do |post| %>
- <%= render partial: 'form', locals: {post: post} %>
+<%= monologue_admin_form_for ["admin", @post], :method => :put do |post| %>
+ <%= render :partial => 'form', :locals => {:post => post} %>
<% end %>
@@ -10,8 +10,8 @@
<% @posts.each do |post|%>
<tr>
<td><%= link_to post.posts_revisions.last.title, edit_admin_post_path(post) %></td>
- <td><%= link_to t(".edit"), edit_admin_post_path(post), class: "btn btn-small" %></td>
- <td><%= link_to t(".delete"), ["admin", post], confirm: 'Are you sure?', method: :delete, class: "btn btn-small btn-danger" %></td>
+ <td><%= link_to t(".edit"), edit_admin_post_path(post), :class => "btn btn-small" %></td>
+ <td><%= link_to t(".delete"), ["admin", post], :confirm => 'Are you sure?', :method => :delete, :class => "btn btn-small btn-danger" %></td>
</tr>
<% end %>
</tbody>
@@ -1,4 +1,4 @@
<h1><%= t(".header") %></h1>
<%= monologue_admin_form_for ["admin", @post] do |post| %>
- <%= render partial: 'form', locals: {post: post} %>
+ <%= render :partial => 'form', :locals => {:post => post} %>
<% end %>
@@ -9,5 +9,5 @@
<%= label_tag :password, t(".password") %>
<%= password_field_tag :password %>
</div>
- <div class="actions"><%= submit_tag t(".button"), class: "btn btn-large btn-primary" %></div>
+ <div class="actions"><%= submit_tag t(".button"), :class => "btn btn-large btn-primary" %></div>
<% end %>
@@ -1,9 +1,9 @@
<div id="pagination">
<% if @posts.total_pages > 1 && @posts.total_pages != @page.to_i %>
- <%= link_to t(".older_posts"), posts_page_path(@page.to_i+1), class: "older_posts" %>
+ <%= link_to t(".older_posts"), posts_page_path(@page.to_i+1), :class => "older_posts" %>
<% end %>
<% if @posts.total_pages > 1 && @page.to_i > 1 %>
- <%= link_to t(".newer_posts"), posts_page_path(@page.to_i-1), class: "newer_posts" %>
+ <%= link_to t(".newer_posts"), posts_page_path(@page.to_i-1), :class => "newer_posts" %>
<% end %>
</div>
@@ -9,9 +9,9 @@
</time>&nbsp;&nbsp;|&nbsp;&nbsp;<%= revision.user.name %>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="<%= revision.url + "#disqus_thread" %>"></a>
</header>
- <p><%= raw truncate(strip_tags(revision.content), length: 1000) %></p>
+ <p><%= raw truncate(strip_tags(revision.content), :length => 1000) %></p>
- <%= link_to t(".readmore"), revision.url, class: "btn alignleft" %>
+ <%= link_to t(".readmore"), revision.url, :class => "btn alignleft" %>
</section>
<% end %>
@@ -4,7 +4,7 @@
<% end %>
<% content_for :meta_description do %>
- <%= truncate(strip_tags(@revision.content), length: 155) %>
+ <%= truncate(strip_tags(@revision.content), :length => 155) %>
<% end %>
<article>
View
@@ -1,15 +1,15 @@
Monologue::Engine.routes.draw do
- root to: "posts#index"
- match "/page/:page", to: "posts#index", as: "posts_page"
- match "/feed" => "posts#feed", as: "feed", defaults: {format: :rss}
+ root :to => "posts#index"
+ match "/page/:page", :to => "posts#index", :as => "posts_page"
+ match "/feed" => "posts#feed", :as => "feed", :defaults => {:format => :rss}
- namespace :admin, path: "monologue" do
- get "/" => "posts#index", as: "" # responds to admin_url and admin_path
+ namespace :admin, :path => "monologue" do
+ get "/" => "posts#index", :as => "" # responds to admin_url and admin_path
get "logout" => "sessions#destroy"
get "login" => "sessions#new"
resources :sessions
resources :posts
end
- match "*post_url" => "posts#show", as: "post"
+ match "*post_url" => "posts#show", :as => "post"
end
@@ -11,7 +11,7 @@ def change
t.timestamps
end
- add_index :monologue_posts_revisions, :id, unique: true
+ add_index :monologue_posts_revisions, :id, :unique => true
add_index :monologue_posts_revisions, :published_at
add_index :monologue_posts_revisions, :post_id
end
View
@@ -1 +1 @@
-Monologue::User.create!({name: "Monologue", email: "monologue@example.com", password: "monologue", password_confirmation: "monologue"})
+Monologue::User.create!({:name => "Monologue", :email => "monologue@example.com", :password => "monologue", :password_confirmation => "monologue"})
@@ -0,0 +1,15 @@
+development:
+ adapter: mysql2
+ encoding: utf8
+ reconnect: false
+ database: monologue_development
+ pool: 5
+ username: root
+
+test:
+ adapter: mysql2
+ encoding: utf8
+ reconnect: false
+ database: monologue_test
+ pool: 5
+ username: root
@@ -22,4 +22,4 @@ production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
- timeout: 5000
+ timeout: 5000
@@ -1,10 +1,10 @@
# encoding: UTF-8
FactoryGirl.define do
- factory :post, class: Monologue::Post do
+ factory :post, :class => Monologue::Post do
published true
end
- factory :posts_revision, class: Monologue::PostsRevision do
+ factory :posts_revision, :class => Monologue::PostsRevision do
sequence(:title) {|i| "post #{i} | revision 1"}
content "this is some text with french accents éàöûù and so on...even html tags like <br />"
sequence(:url) { |i| "/monologue/post/#{i}" }
@@ -13,12 +13,12 @@
sequence(:published_at) {|i| DateTime.new(2012,1,1,12,0,17) + i.days }
end
- factory :unpublished_post, class: Monologue::Post, :parent => :post do |post|
+ factory :unpublished_post, :class => Monologue::Post, :parent => :post do |post|
published false
post.after_create { |p| Factory(:posts_revision, :post => p, :title => "unpublished", :url => "/monologue/unpublished") }
end
- factory :post_with_multiple_revisions, class: Monologue::Post, :parent => :post do |post|
+ factory :post_with_multiple_revisions, :class => Monologue::Post, :parent => :post do |post|
post.after_create { |p| Factory(:posts_revision, :post => p, :title => "post X | revision 1", :url => "/monologue/post/x") }
post.after_create { |p| Factory(:posts_revision, :post => p, :title => "post X | revision 2", :url => "/monologue/post/x") }
end
@@ -1,7 +1,7 @@
# Read about factories at http://github.com/thoughtbot/factory_girl
FactoryGirl.define do
- factory :user, class: Monologue::User do
+ factory :user, :class => Monologue::User do
name "John Doe"
email "jdoe@example.com"
password "secret"
@@ -11,8 +11,8 @@
describe "validations" do
it "is not possible to have twice the same posts_revision_id" do
- Factory(:post, posts_revision_id: 1)
- expect { Factory(:post, posts_revision_id: 1) }.to raise_error(ActiveRecord::RecordInvalid)
+ Factory(:post, :posts_revision_id => 1)
+ expect { Factory(:post, :posts_revision_id => 1) }.to raise_error(ActiveRecord::RecordInvalid)
end
end
end
@@ -24,7 +24,7 @@
it "should create permalink (url) automaticly with title and year if none is provided" do
title = "this is a great title!!!"
- post = Factory(:posts_revision, url:"", title:title, published_at: "2012-02-02")
+ post = Factory(:posts_revision, :url => "", :title => title, :published_at => "2012-02-02")
post.url.should == "/2012/this-is-a-great-title"
end
Oops, something went wrong.

0 comments on commit e995e89

Please sign in to comment.