This file contains hidden or 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
| - owner_only do | |
| = link_to "My Control Panel", edit_bracket_path(@bracket), :title => 'My Control Panel' |
This file contains hidden or 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
| Spec::Runner.configure do |config| | |
| config.mock_with :mocha | |
| config.before(:suite) do | |
| DatabaseCleaner.strategy = :transaction | |
| DatabaseCleaner.clean_with(:truncation) | |
| end | |
| config.before(:each) do |
This file contains hidden or 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
| Scenario: I should see a max of 5 comments | |
| Given there are 6 comments |
This file contains hidden or 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
| When /^I delete that comment$/ do | |
| @comment = Comment.last | |
| debugger | |
| When %Q{I press "X" within "#comments li:first .destroy_comment"} | |
| end |
This file contains hidden or 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
| if defined?(ActiveRecord::Base) | |
| begin | |
| require 'database_cleaner' | |
| DatabaseCleaner.strategy = :truncation | |
| DatabaseCleaner.clean | |
| rescue LoadError => ignore_if_database_cleaner_not_present | |
| end | |
| end |
This file contains hidden or 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
| $(function() { | |
| $('#comments li').highlightDeleteButton(); // delete button goes red on hover | |
| }) | |
| $.fn.highlightDeleteButton = function() { | |
| var $delete_button = $(this).find('input[type=submit]'); | |
| $(this).live('hover', function() { | |
| $delete_button.toggleClass('serious')}) | |
| } |
This file contains hidden or 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
| $.fn.highlightDeleteButton = function() { | |
| $(this).live('hover', function() { | |
| this.delete_button = this.delete_button || $(this).find('input[type=submit]'); | |
| this.delete_button.toggleClass('serious'); | |
| }) | |
| } |
This file contains hidden or 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
| # i need the 5 most recent guesses | |
| # option1 - scope on guesses | |
| @bracket.guesses.most_recent(5) | |
| # option2 - relationship that overlaps with bracket has_many :guesses | |
| @bracket.five_most_recent_guesses | |
| #option3 - an explicit method on the bracket instance | |
| @bracket.five_most_recent_guesses which just runs it's own hard coded query |
This file contains hidden or 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
| class Album < ActiveRecord::Base | |
| attr_accessible :title | |
| has_one :artist , :dependent => :destroy | |
| has_many :genres , :dependent => :destroy | |
| accepts_nested_attributes_for :artist, :allow_destroy => true | |
| end |
This file contains hidden or 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
| def index | |
| @comments = .... | |
| respond_to do |wants| | |
| wants.json { render :json => { :comments => render_to_string(:partial => 'comments/comments_box.html.haml', :locals => { :comments => @comments}) }.to_json } | |
| end | |
| end |