
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Inspired by technicalpickles' shoulda_generator (okay blatantly ripped off from ;)
What you'll need:
Use these just like the standard Rails generators.
$ script/generate coulda_model post title:string body:text published:boolean
$ script/generate coulda_scaffold post title:string body:text published:boolean
Using "belongs_to" as the field type provides some extra goodness.
$ script/generate coulda_model post title:string body:text user:belongs_to
will give you this migration:
class CreatePosts < ActiveRecord::Migration
def self.up
create_table :posts do |t|
t.string :title
t.text :body
t.belongs_to :user
t.timestamps
end
add_index :posts, :user_id
end
def self.down
remove_index :posts, :user_id
drop_table :posts
end
end
for this model:
class Post < ActiveRecord::Base
belongs_to :user
end
with this unit test:
require File.dirname(__FILE__) + '/../test_helper'
class PostTest < ActiveSupport::TestCase
should_have_db_column :title, :type => "string"
should_have_db_column :body, :type => "text"
should_belong_to :user
should_have_index :user_id
end
and finally our factory:
Factory.define :post do |f|
f.title 'MyString'
f.body 'MyString'
f.user {|f| f.association(:user)}
end
Mike Breen and Dan Croak
The MIT License
Copyright (c) 2008 Mike Breen
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Unknown package
We found that hardbap-coulda demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.