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
context 'buyer names changes' do | |
let(:name) { 'Lindt' } | |
let(:supplier) { Supplier.create(name: 'Cocoa Beans Inc', email: '[email protected]', password: 'password') } | |
let(:buyer) { Buyer.cretae(name: name, email: '[email protected]', password: 'password') } | |
subject { | |
FactoryGirl.create(:trade_request, buyer: buyer, supplier: supplier) | |
} | |
# go for a logical context name |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
class Admin::GroupsController < Admin::BaseController | |
def delete_all_groups | |
GroupService.new(current_user, @group).delete_all_groups | |
end | |
end | |
class GroupService | |
def initialize(user, group) | |
@user = user | |
@group = group |
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
class FeaturedPhotosService | |
def self.clean_featured_photo_for(listing_photo) | |
updated_record_count = Listing.where(featured_photo_id: listing_photo.id). | |
update_all(featured_photo_id: nil) | |
listing_photo.destroy if updated_record_count > 0 | |
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
<% @settings['sites'].keys.sort.each do |sitename| %> | |
<% sitename[sitename].keys.delete_if { |key, val| key != 'path_map' }.sort.each do |siteatt| | |
<% siteatt.keys.sort.each do |sitemap| %> | |
backend backend_<% sitename %>_<%= sitemap %> | |
<% 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
context "Description" do | |
before(:each) do | |
group | |
end | |
context "is less than 25 characters" do | |
context "without line breaks" do | |
before(:each) { row[:Description] = "123456789012345678901234" } | |
it { is_expected.to be false } | |
end | |
context "with line breaks" do |
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
context "Description" do | |
before(:each) do | |
group | |
end | |
context "is less than 25 characters" do | |
context "without line breaks" do | |
before(:each) { row[:Description] = "123456789012345678901234" } | |
it { is_expected.to be false } | |
end | |
context "with line breaks" do |
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
// link <a title="recipe" href="sampleapp://recipes/3">recipe</a> | |
//app.js | |
function handleOpenURL(url) { | |
setTimeout(function() { | |
window.location.hash = '/app/show/' + url.split("/").pop(); | |
}, 500); | |
} | |
// following is my router |
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
class ItemsController < ApplicationController | |
#rest of your methods | |
# ...... | |
private | |
def item_params | |
params.require(:item).permit( | |
:name, | |
:content, | |
:image, | |
:address, |
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
=== Rails migrations === | |
In ruby/rails projects , the standard way of hadling database changes (add/edit tables, add/edit columns etc..) | |
through the migrations. this way we can hadle database changes easily. | |
=== where are the migrations === | |
migrations are in the following folder | |
```ruby |
NewerOlder