What is your distribution of time when coding features?
RSpec.describe Orders::Operation::Create do
context 'success' do
it 'is successful'
it 'creates order'
it 'creates line items'
end
context 'failure' do
it 'is not successful'
it 'contains order errors'
end
endmodule StarCount # :nodoc:
def self.coverage(score)
case score
when 0..15 then 1
when 15..30 then 2
when 30..51 then 3
when 51..71 then 4
else 5
end
end
endclass ContentAddon < ActiveRecord::Base # :nodoc:
def single_channel?
addon_channels.count == 1
end
end
class BundlePackage < ActiveRecord::Base # :nodoc:
def double_play?
package_type == 'double_play' || package_type == 'broadband'
end
end
class Sport < ActiveRecord::Base # :nodoc:
def mark_preincluded(channel)
addon_channels.find_by!(channel: channel)
.update(preincluded: true)
end
def top_show_channel
addon_channels.first.channel
end
end
class Order < ActiveRecord::Base # :nodoc:
def line_items_amount
line_items.selected.map(&:item).sum(&:amount)
end
endclass Profile < ActiveRecord::Base # :nodoc:
validate :favorites_dont_overlap_dislikes
def neutral_buckets
UserBucket.where.not(id: favorite_buckets + disliked_buckets)
end
def subscription_channels
Repository::Subscription.load(subscriptions)
end
private
def favorites_dont_overlap_dislikes
return if favorite_buckets
.none? { |bucket| disliked_buckets.include?(bucket) }
errors.add(
:base, :overlapping_user_buckets,
values: overlapping_user_buckets
)
end
def overlapping_user_buckets
included_in_both(favorite_buckets, disliked_buckets)
.map(&:name).join(', ')
end
def included_in_both(first, second)
first.select { |e| second.include?(e) }
end
end