Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
110 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class CommandsController < RestfulController | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,14 @@ | ||
module ApplicationHelper | ||
end | ||
def title | ||
return @title if @title | ||
if @current_object | ||
if @current_object.new_record? | ||
"New #{current_model}" | ||
else | ||
@current_object.to_s | ||
end | ||
else | ||
current_model.to_s.pluralize | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class Command < ActiveRecord::Base | ||
validates_uniqueness_of :name, :case_sensitive => false | ||
validates_presence_of :name, :description | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<h2><%= command.name %></h2> | ||
<%= command.description %> <br /> | ||
<%= command.mac_only? ? "Mac only" : "" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<% render :collection => @commands %> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= link_to "CmdLiner fancy logo", root_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
ActionController::Routing::Routes.draw do |map| | ||
map.root :controller => 'home' | ||
map.root :controller => :commands | ||
map.login '/login', :controller => "users", :action => "new" | ||
|
||
map.resources :users | ||
map.resources :commands, :only=>[:index, :show] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class CreateCommands < ActiveRecord::Migration | ||
def self.up | ||
create_table :commands do |t| | ||
t.string :name, :null=>false | ||
t.text :description, :null=>false | ||
t.boolean :mac_only, :default=>false, :null=>false | ||
t.timestamps | ||
end | ||
|
||
# enforce uniqueness | ||
add_index :commands, :name, :unique => true | ||
end | ||
|
||
def self.down | ||
drop_table :commands | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'spec/spec_helper' | ||
|
||
describe ApplicationHelper do | ||
include ApplicationHelper | ||
|
||
describe :title do | ||
before do | ||
stub!(:current_model).and_return User | ||
end | ||
|
||
it "fetches the title from @title" do | ||
@title = 'YEP' | ||
title.should == @title | ||
end | ||
|
||
it "gets the title from current_object" do | ||
user = Factory(:user) | ||
@current_object = user | ||
title.should == user.to_s | ||
end | ||
|
||
it "gets the title from new objects" do | ||
user = Factory.build(:user) | ||
@current_object = user | ||
title.should == "New User" | ||
end | ||
|
||
it "gets the title from current_model" do | ||
title.should == 'Users' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters