diff
stringlengths 65
26.7k
| message
stringlengths 7
9.92k
|
|---|---|
diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/dashboard_controller.rb
+++ b/app/controllers/dashboard_controller.rb
@@ -1,29 +1,72 @@ class DashboardController < ApplicationController
def index
@current_account = current_account
- @entries = current_entries
+ @entries = account_entries(@current_account)
- mount_entries_lists
+ mount_entries_lists(@entries)
mount_totalizers
+
+ top_categories_entries(@current_account, @entries)
+ end
+
+ def top_categories_entries account, entries
+ @categories = top_categories_totalizer(account, entries)
end
private
- def current_entries
+ def account_entries account
begin_date = Date.today.beginning_of_month
end_date = Date.today.end_of_month
- @current_account.entries.where(date: begin_date...end_date)
+
+ account.entries.where(date: begin_date...end_date)
end
- def mount_entries_lists
- @all_incomes = @entries.where(entries_type: 'income')
- @all_expenses = @entries.where(entries_type: 'expense')
+ def mount_entries_lists entries
+ @all_incomes = select_entries(entries, 'income')
+ @all_expenses = select_entries(entries, 'expense')
@incomes = @all_incomes.where(paid: false)
@expenses = @all_expenses.where(paid: false)
+ end
+
+ def select_entries entries, entry_type
+ entries.where(entries_type: entry_type).order(date: :asc, description: :asc)
end
def mount_totalizers
@totalizer_incomes = @all_incomes.sum :value
@totalizer_expenses = @all_expenses.sum :value
end
+
+ def top_categories_totalizer account, entries
+ expenses = select_entries(entries, 'expense')
+ account_categories = account.categories
+ categories = Array.new
+
+ account_categories.each do |category|
+ expenses_category = expenses.where(category_id: category.id)
+
+ if expenses_category.length > 0
+ expenses_sum = expenses_category.sum :value
+ formatted_value = format_value(expenses_sum, account.read_attribute('currency_type'))
+
+ categories.push({
+ category: category.name,
+ value: expenses_sum,
+ color: category.color,
+ label: "#{category.name} - #{formatted_value}"
+ })
+ end
+ end
+
+ if categories.length > 0
+ categories.sort! { |x,y| y[:value] <=> x[:value] }
+ end
+
+ categories
+ end
+
+ def format_value value, unit
+ view_context.number_to_currency(value, unit: unit, separator: ",", delimiter: ".")
+ end
end
|
Update dashboard controller to load chart data
|
diff --git a/app/controllers/employers_controller.rb b/app/controllers/employers_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/employers_controller.rb
+++ b/app/controllers/employers_controller.rb
@@ -1,7 +1,7 @@ class EmployersController < ApplicationController
before_action :authenticate_employer!, only: :edit
before_action :authenticate_user!, except: :edit
- before_action :set_employer, only: :show
+ before_action :set_employer, only: [:show, :edit]
# GET /employers/:id
def show
@@ -9,7 +9,6 @@
# GET /employers/:id/edit
def edit
- redirect_to root_path && return if @employer != current_employer
end
private
@@ -17,5 +16,6 @@ def set_employer
@login = params[:id]
@employer = Employer.find_by_login!(@login)
+ redirect_to root_path unless @employer == current_employer
end
end
|
Fix permission and set employer
|
diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/proposals_controller.rb
+++ b/app/controllers/proposals_controller.rb
@@ -2,19 +2,20 @@ respond_to :html
def index
- # Fetch open proposals
- @proposals = co.proposals.currently_open
-
- # Fetch five most recent decisions
- @decisions = co.decisions.order("id DESC").limit(5)
-
- # Fetch five most recent failed proposals
- @failed_proposals = co.proposals.failed.limit(5)
-
case co
when Coop
+ @proposals = co.resolutions.currently_open
@draft_proposals = co.resolutions.draft
@resolution_proposals = co.resolution_proposals
+ else
+ # Fetch open proposals
+ @proposals = co.proposals.currently_open
+
+ # Fetch five most recent decisions
+ @decisions = co.decisions.order("id DESC").limit(5)
+
+ # Fetch five most recent failed proposals
+ @failed_proposals = co.proposals.failed.limit(5)
end
end
|
Fix /proposals displaying resolution-proposals as currently-open resolutions.
|
diff --git a/app/controllers/sms_tests_controller.rb b/app/controllers/sms_tests_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/sms_tests_controller.rb
+++ b/app/controllers/sms_tests_controller.rb
@@ -8,16 +8,20 @@ # handles a request for a test. this will be an AJAX call so we only return the message body
def create
# create an incoming sms object
- sms = Sms::Message.create(:adapter_name => "Test Console",
+ sms = Sms::Message.create(:adapter_name => 'Test Console',
:from => params[:sms_test][:from],
:body => params[:sms_test][:body],
:mission => current_mission)
- # submit it to the handle method over in the SmsController and get the reply
- reply = SmsController.handle_sms(sms)
-
- # save the reply and let the sent_at default to now
- reply.save if reply
+
+ # Submit it to the handle method over in the SmsController and get the reply.
+ if reply = SmsController.handle_sms(sms)
+ # Need to set adapter name on the reply here.
+ reply.adapter_name = 'Test Console'
+
+ # Let the sent_at default to now.
+ reply.save
+ end
# render the body of the reply
render :text => reply ? reply.body : "<em>#{t('sms_console.no_reply')}</em>".html_safe
@@ -28,4 +32,4 @@ def model_class
Sms::Test
end
-end+end
|
Set adapter name on reply
|
diff --git a/lib/llt/diff/parser/postag_diff.rb b/lib/llt/diff/parser/postag_diff.rb
index abc1234..def5678 100644
--- a/lib/llt/diff/parser/postag_diff.rb
+++ b/lib/llt/diff/parser/postag_diff.rb
@@ -1,5 +1,7 @@ module LLT
class Diff::Parser
+ # This class is redundant right now, we keep it around because we
+ # still need to decide if we show datapoint diffs
class PostagDiff
attr_reader :original, :new
|
Add comment in PostagDiff about its current status
|
diff --git a/app/models/gobierto_common/custom_field.rb b/app/models/gobierto_common/custom_field.rb
index abc1234..def5678 100644
--- a/app/models/gobierto_common/custom_field.rb
+++ b/app/models/gobierto_common/custom_field.rb
@@ -4,6 +4,7 @@ class CustomField < ApplicationRecord
belongs_to :site
has_many :records, dependent: :destroy, class_name: "CustomFieldRecord"
+ validates :name, presence: true
enum field_type: { string: 0,
localized_string: 1,
|
Add validation to custom field name
|
diff --git a/app/presenters/money_question_presenter.rb b/app/presenters/money_question_presenter.rb
index abc1234..def5678 100644
--- a/app/presenters/money_question_presenter.rb
+++ b/app/presenters/money_question_presenter.rb
@@ -6,7 +6,7 @@ end
def hint_text
- text = [body, "in £", suffix_label].reject(&:blank?).compact.join(", ")
+ text = [body, suffix_label].reject(&:blank?).compact.join(", ")
ActionView::Base.full_sanitizer.sanitize(text)
end
end
|
Remove "in £" from money input
As recommended by the Content Designers.
|
diff --git a/app/graphql/annict_schema.rb b/app/graphql/annict_schema.rb
index abc1234..def5678 100644
--- a/app/graphql/annict_schema.rb
+++ b/app/graphql/annict_schema.rb
@@ -1,24 +1,24 @@ # frozen_string_literal: true
-AnnictSchema = GraphQL::Schema.define do
+class AnnictSchema < GraphQL::Schema
query ObjectTypes::Query
mutation ObjectTypes::Mutation
use GraphQL::Batch
- id_from_object ->(object, type_definition, _query_ctx) {
+ def self.id_from_object(object, type_definition, _query_ctx)
GraphQL::Schema::UniqueWithinType.encode(type_definition.name, object.id)
- }
+ end
- object_from_id ->(id, _query_ctx) {
+ def self.object_from_id(id, _query_ctx)
type_name, item_id = GraphQL::Schema::UniqueWithinType.decode(id)
return nil if type_name.blank? || item_id.blank?
Object.const_get(type_name).find(item_id)
- }
+ end
- resolve_type ->(_type, obj, _ctx) {
+ def self.resolve_type(_type, obj, _ctx)
case obj
when Activity
UnionTypes::Activity
@@ -41,5 +41,5 @@ else
raise "Unexpected object: #{obj}"
end
- }
+ end
end
|
Change to class style schema
|
diff --git a/app/views/api/v1/places/index.json.rabl b/app/views/api/v1/places/index.json.rabl
index abc1234..def5678 100644
--- a/app/views/api/v1/places/index.json.rabl
+++ b/app/views/api/v1/places/index.json.rabl
@@ -1,6 +1,5 @@ collection @places
attributes :id, :name, :city, :address, :latitude, :longitude,
:accepts_new_members, :is_established, :description, :contact_name,
-:contact_phone, :contact_url, :type, :user_id, :updated_at, :vegetable_products,
-:animal_products, :beverages, :additional_product_information
+:contact_phone, :contact_url, :type, :user_id, :updated_at
attributes :contact_email, :if => lambda { |p| p.authorized? current_user }
|
Remove farm attribute form places.
|
diff --git a/features/support/remote_command_helpers.rb b/features/support/remote_command_helpers.rb
index abc1234..def5678 100644
--- a/features/support/remote_command_helpers.rb
+++ b/features/support/remote_command_helpers.rb
@@ -17,8 +17,8 @@
def safely_remove_file(_path)
run_vagrant_command("rm #{test_file}")
- rescue VagrantHelpers::VagrantSSHCommandError
- nil
+ rescue
+ VagrantHelpers::VagrantSSHCommandError
end
end
|
Revert issue introduced by misunderstanding of rescue modifier
|
diff --git a/config/initializers/extensions.rb b/config/initializers/extensions.rb
index abc1234..def5678 100644
--- a/config/initializers/extensions.rb
+++ b/config/initializers/extensions.rb
@@ -3,8 +3,8 @@ idx = path.rindex(/\//)
if idx
file_portion = path.slice(idx+1, path.length)
- versions << file_portion if file_portion.match(/v\d+/)
+ versions << $1.to_i if file_portion.match(/v\d+/)
end
end
-::AP::SchedulerExtension::Scheduler::Config.instance.latest_version = versions.last+::AP::SchedulerExtension::Scheduler::Config.instance.latest_version = "V#{versions.sort.last}"
|
Fix issue with finding the latest version of models
|
diff --git a/config/initializers/udp_logger.rb b/config/initializers/udp_logger.rb
index abc1234..def5678 100644
--- a/config/initializers/udp_logger.rb
+++ b/config/initializers/udp_logger.rb
@@ -20,8 +20,7 @@ id: id,
message: name,
racing_association: RacingAssociation.current.short_name,
- start: start,
- _ttl: { enabled: true, default: "7d" }
+ start: start
}.merge(
parameter_filter.filter payload
)
|
Remove _ttl from logger. Needs to be in Logstash -> Elasticsearch bit.
|
diff --git a/spec/integration/adapter_spec.rb b/spec/integration/adapter_spec.rb
index abc1234..def5678 100644
--- a/spec/integration/adapter_spec.rb
+++ b/spec/integration/adapter_spec.rb
@@ -7,15 +7,9 @@ let(:path) { File.expand_path("./spec/fixtures/users.csv") }
# If :csv is not passed in the repository is named `:default`
- let(:setup) { ROM.setup(csv: "csv://#{path}") }
+ let(:setup) { ROM.setup("csv://#{path}") }
before do
- setup.schema do
- base_relation(:users) do
- repository :csv
- end
- end
-
setup.relation(:users) do
def by_name(name)
find_all { |row| row[:name] == name }
|
Update spec to pass on latest rom
|
diff --git a/spec/integration/console_spec.rb b/spec/integration/console_spec.rb
index abc1234..def5678 100644
--- a/spec/integration/console_spec.rb
+++ b/spec/integration/console_spec.rb
@@ -18,6 +18,6 @@ subject(:console_access) { client.console_access(vm: vm) }
it "returns html for console access" do
- expect(console_access).to match(/frame src/)
+ expect(console_access).to match %r{<html>.*<frame src=.*</html>}
end
end
|
Make console integration spec more specific
|
diff --git a/spec/react/refs_callback_spec.rb b/spec/react/refs_callback_spec.rb
index abc1234..def5678 100644
--- a/spec/react/refs_callback_spec.rb
+++ b/spec/react/refs_callback_spec.rb
@@ -1,3 +1,7 @@+require 'spec_helper'
+
+if opal?
+
describe 'Refs callback' do
before do
stub_const 'Foo', Class.new
@@ -15,11 +19,8 @@ end
end
- stub_const 'MyBar', nil
Foo.class_eval do
- def my_bar=(bar)
- MyBar = bar
- end
+ attr_accessor :my_bar
def render
React.create_element(Bar, ref: method(:my_bar=).to_proc)
@@ -27,16 +28,13 @@ end
element = React.create_element(Foo)
- React::Test::Utils.render_into_document(element)
- expect(MyBar).to be_a(Bar)
+ instance = React::Test::Utils.render_into_document(element)
+ expect(instance.my_bar).to be_a(Bar)
end
it "is invoked with the actual DOM node" do
- stub_const 'MyDiv', nil
Foo.class_eval do
- def my_div=(div)
- MyDiv = div
- end
+ attr_accessor :my_div
def render
React.create_element('div', ref: method(:my_div=).to_proc)
@@ -44,7 +42,9 @@ end
element = React.create_element(Foo)
- React::Test::Utils.render_into_document(element)
- expect(`#{MyDiv}.nodeType`).to eq(1)
+ instance = React::Test::Utils.render_into_document(element)
+ expect(`#{instance.my_div}.nodeType`).to eq(1)
end
end
+
+end
|
Fix dynamic constant assignment error
|
diff --git a/app/jobs/export_async_job.rb b/app/jobs/export_async_job.rb
index abc1234..def5678 100644
--- a/app/jobs/export_async_job.rb
+++ b/app/jobs/export_async_job.rb
@@ -12,14 +12,14 @@ params_class = "#{resource_class_name}Parameters".constantize
# Get a new ActiveRecord::Relation from the sql_string
- resources = resource_class.from("(#{sql_string}) #{resource_class_name.underscore.pluralize}")
+ resources = resource_class.from("(#{sql_string}) #{resource_class.table_name}")
export_attributes = params_class.csv_export_attributes
# Make a /tmp directory if one does not already exist
::FileUtils.mkdir_p(Rails.root.join("tmp"))
# filename is in the form of "course_group_best_efforts-1668309553.csv"
- filename = "#{controller_name.underscore.pluralize}-#{Time.current.to_i}.csv"
+ filename = "#{controller_name.underscore.pluralize}-#{Time.current.to_i}-#{resources.count}.csv"
full_path = ::File.join(Rails.root.join("tmp"), filename)
file = ::File.open(full_path, "w")
|
Add record count to the filename
|
diff --git a/app/services/pickup_cards.rb b/app/services/pickup_cards.rb
index abc1234..def5678 100644
--- a/app/services/pickup_cards.rb
+++ b/app/services/pickup_cards.rb
@@ -1,14 +1,6 @@-class PickupCards
- attr_reader :errors
-
- def initialize(player, round)
- @player = player
- @round = round
- @errors = []
- end
-
+class PickupCards < Struct.new(:player, :round, :pickups)
def call
- @round.game.with_lock do
+ round.game.with_lock do
validate_cards_available
pickup_card if errors.none?
end
@@ -16,16 +8,19 @@ errors.none?
end
+ def errors
+ @errors ||= []
+ end
+
private
- # def validate_cards_available
def validate_cards_available
- errors << "no cards in deck" if @round.deck.none?
+ errors << "no cards in deck" if round.deck.none?
end
def pickup_card
- card = @round.deck.pickup
- @player.pickup!(card)
+ card = round.deck.pickup
+ player.pickup!(card)
end
# TODO increment round fool!
|
Refactor PickupCards into a struct for simplicity
|
diff --git a/spec/models/organization_spec.rb b/spec/models/organization_spec.rb
index abc1234..def5678 100644
--- a/spec/models/organization_spec.rb
+++ b/spec/models/organization_spec.rb
@@ -10,4 +10,18 @@ str_dump.should include('Kirjasto')
end
+ it 'provides an error on duplicate key' do
+ h = FactoryGirl.create(:helsinki_uni)
+
+ o = Organization.new key: h.key
+
+ o.should have(1).errors_on(:key)
+ end
+
+ it 'provides an error with blank key' do
+ o = Organization.new key: ''
+
+ o.should have(1).errors_on(:key)
+ end
+
end
|
Add specs for Organization validations
|
diff --git a/spec/unit/view/null_part_spec.rb b/spec/unit/view/null_part_spec.rb
index abc1234..def5678 100644
--- a/spec/unit/view/null_part_spec.rb
+++ b/spec/unit/view/null_part_spec.rb
@@ -0,0 +1,39 @@+require 'rodakase/view/null_part'
+
+RSpec.describe Rodakase::View::NullPart do
+ subject(:part) do
+ Rodakase::View::NullPart.new(renderer, data)
+ end
+
+ let(:name) { :user }
+ let(:data) { { user: nil } }
+
+ let(:renderer) { double(:renderer) }
+
+ describe '#[]' do
+ it 'returns nil for any data value names' do
+ expect(part[:email]).to eql(nil)
+ end
+ end
+
+ describe '#method_missing' do
+ it 'renders a template with the _missing suffix' do
+ expect(renderer).to receive(:lookup).with('_row_missing').and_return('_row_missing.slim')
+ expect(renderer).to receive(:render).with('_row_missing.slim', part)
+
+ part.row
+ end
+
+ it 'renders a _missing template within another when block is passed' do
+ block = proc { part.fields }
+
+ expect(renderer).to receive(:lookup).with('_form_missing').and_return('form_missing.slim')
+ expect(renderer).to receive(:lookup).with('_fields_missing').and_return('fields_missing.slim')
+
+ expect(renderer).to receive(:render).with('form_missing.slim', part, &block)
+ expect(renderer).to receive(:render).with('fields_missing.slim', part)
+
+ part.form(block)
+ end
+ end
+end
|
Add some initial unit tests for null part
|
diff --git a/simple_form_fancy_uploads.gemspec b/simple_form_fancy_uploads.gemspec
index abc1234..def5678 100644
--- a/simple_form_fancy_uploads.gemspec
+++ b/simple_form_fancy_uploads.gemspec
@@ -15,7 +15,7 @@
s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md"]
- s.add_dependency "rails", "~> 4.0.0"
+ s.add_dependency "rails", ">= 4.0.0"
s.add_dependency "simple_form", "~> 3.0.0"
s.add_dependency "carrierwave"
|
Allow gem to work with Rails 4.1
|
diff --git a/activesupport/lib/active_support/message_verifier.rb b/activesupport/lib/active_support/message_verifier.rb
index abc1234..def5678 100644
--- a/activesupport/lib/active_support/message_verifier.rb
+++ b/activesupport/lib/active_support/message_verifier.rb
@@ -25,10 +25,10 @@
def verify(signed_message)
data, digest = signed_message.split("--")
- if digest != generate_digest(data)
+ if secure_compare(digest, generate_digest(data))
+ Marshal.load(ActiveSupport::Base64.decode64(data))
+ else
raise InvalidSignature
- else
- Marshal.load(ActiveSupport::Base64.decode64(data))
end
end
@@ -38,6 +38,19 @@ end
private
+ # constant-time comparison algorithm to prevent timing attacks
+ def secure_compare(a, b)
+ if a.length == b.length
+ result = 0
+ for i in 0..(a.length - 1)
+ result |= a[i] ^ b[i]
+ end
+ result == 0
+ else
+ false
+ end
+ end
+
def generate_digest(data)
require 'openssl' unless defined?(OpenSSL)
OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new(@digest), @secret, data)
|
Fix timing attack vulnerability in ActiveSupport::MessageVerifier.
Use a constant-time comparison algorithm to compare the candidate HMAC with the calculated HMAC to prevent leaking information about the calculated HMAC.
Signed-off-by: Michael Koziarski <17b9e1c64588c7fa6419b4d29dc1f4426279ba01@koziarski.com>
|
diff --git a/aphrodite/app/views/api/v2/documents/index.json.rabl b/aphrodite/app/views/api/v2/documents/index.json.rabl
index abc1234..def5678 100644
--- a/aphrodite/app/views/api/v2/documents/index.json.rabl
+++ b/aphrodite/app/views/api/v2/documents/index.json.rabl
@@ -1,2 +1,11 @@ collection @documents
-attributes :id, :title, :created_at
+attributes :id, :title, :created_at, :percentage
+
+node :counters do |document|
+ {
+ people: document.context_cache.fetch('people', []).count,
+ organizations: document.context_cache.fetch('organizations', []).count,
+ places: document.context_cache.fetch('places', []).count,
+ dates: document.context_cache.fetch('dates', []).count
+ }
+end
|
[aphrodite] Add counters information to documents
|
diff --git a/examples/authorization/create_authorization_with_account.rb b/examples/authorization/create_authorization_with_account.rb
index abc1234..def5678 100644
--- a/examples/authorization/create_authorization_with_account.rb
+++ b/examples/authorization/create_authorization_with_account.rb
@@ -0,0 +1,56 @@+require_relative "../boot"
+
+# Create Authorization with Account
+#
+# You need to give:
+# - notification_url
+# - redirect_url
+# - permissions defaults to all permissions
+# - applications credentials (APP_ID, APP_KEY)
+# - account params
+#
+# You can pass this parameters to PagSeguro::AuthorizationRequest#new
+#
+# PS: For more details look the class PagSeguro::AuthorizationRequest
+
+credentials = PagSeguro::ApplicationCredentials.new('APP_ID', 'APP_KEY')
+
+options = {
+ credentials: credentials, # Unnecessary if you set in application config
+ permissions: [:checkouts, :searches, :notifications],
+ notification_url: 'http://seusite.com.br/redirect',
+ redirect_url: 'http://seusite.com.br/notification',
+ reference: '123',
+ account: {
+ email: 'usuario@seusite.com.br',
+ type: 'SELLER',
+ person: {
+ name: 'Antonio Carlos',
+ birth_date: Date.new(1982, 2, 5),
+ address: {
+ postal_code: '01452002',
+ street: 'Av. Brig. Faria Lima',
+ number: '1384',
+ complement: '5o andar',
+ district: 'Jardim Paulistano',
+ city: 'Sao Paulo',
+ state: 'SP',
+ country: 'BRA'
+ },
+ documents: [{type: 'CPF', value: '23606838450'}],
+ phones: [
+ {type: 'HOME', area_code: '11', number: '30302323'},
+ {type: 'MOBILE', area_code: '11', number: '976302323'},
+ ]
+ }
+ }
+}
+
+authorization_request = PagSeguro::AuthorizationRequest.new(options)
+
+if authorization_request.create
+ print "Use this link to confirm authorizations: "
+ puts authorization_request.url
+else
+ puts authorization_request.errors.join("\n")
+end
|
Add example create authorization request with an account
|
diff --git a/app/controllers/compare_controller.rb b/app/controllers/compare_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/compare_controller.rb
+++ b/app/controllers/compare_controller.rb
@@ -18,8 +18,8 @@ query_results = {}
base_selection = UserSelections.new(
__safe_params: {
- from: user_compare_selections.from_date,
- to: user_compare_selections.to_date
+ 'from' => user_compare_selections.from_date,
+ 'to' => user_compare_selections.to_date
}
)
|
Fix for ignored date params in compare search.
Proposed fix for #118 'date picker not working in compare view'. The
problem was that seeding the user selections model with the given
from and to dates was using symbol keys not string keys.
|
diff --git a/app/controllers/exports_controller.rb b/app/controllers/exports_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/exports_controller.rb
+++ b/app/controllers/exports_controller.rb
@@ -9,7 +9,6 @@ attendances = AttendanceExportsHelper.
get_attendances(params[:course_id], params[:start_date], params[:end_date])
if attendances.count > 1000
- render json: { large_file: true }
tenant = Apartment::Tenant.current
Apartment::Tenant.switch(Application::PUBLIC_TENANT) do
AttendanceReportJob.
@@ -22,6 +21,7 @@ params[:end_date],
)
end
+ render json: { large_file: true }
else
final_csv = AttendanceExportsHelper.generate_csv(attendances)
send_data(final_csv)
|
Move render to end of statement
|
diff --git a/app/controllers/profile_controller.rb b/app/controllers/profile_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/profile_controller.rb
+++ b/app/controllers/profile_controller.rb
@@ -1,5 +1,5 @@ class ProfileController < ArticlesController
- before_action :require_sign_in
+ before_action :authenticate_user!
def edit
end
@@ -10,10 +10,4 @@
render :edit
end
-
- private
-
- def require_sign_in
- redirect_to new_user_session_path unless user_signed_in?
- end
end
|
Use Device provided `before_action :authenticate_user!` instead of `user_signed_in?` from the Authentication concern.
|
diff --git a/lib/bumbleworks/redis/adapter.rb b/lib/bumbleworks/redis/adapter.rb
index abc1234..def5678 100644
--- a/lib/bumbleworks/redis/adapter.rb
+++ b/lib/bumbleworks/redis/adapter.rb
@@ -1,4 +1,5 @@ require "bumbleworks/storage_adapter"
+require "rufus-json/automatic"
require "ruote-redis"
module Bumbleworks
|
Use rufus-json's automatic JSON library loading
|
diff --git a/spec/features/config_spec.rb b/spec/features/config_spec.rb
index abc1234..def5678 100644
--- a/spec/features/config_spec.rb
+++ b/spec/features/config_spec.rb
@@ -40,6 +40,10 @@ expect(User.all.count).to equal 1
expect(page).to have_content "Logged in as"
end
+
+ it 'outputs table header as html' do
+ expect(page).to have_selector "table#pages th.name"
+ end
end
end
end
|
Add test for table header on pages list
Make sure the table header is html, not escaped text.
Conflicts:
spec/features/config_spec.rb
|
diff --git a/spec/lib/pixi_client_spec.rb b/spec/lib/pixi_client_spec.rb
index abc1234..def5678 100644
--- a/spec/lib/pixi_client_spec.rb
+++ b/spec/lib/pixi_client_spec.rb
@@ -6,6 +6,7 @@ configuration.endpoint = 'endpoint'
configuration.username = 'username'
configuration.password = 'random-password'
+ configuration.wsdl = 'some/path/somewhere.wsdl'
end
end
@@ -14,6 +15,7 @@ expect(PixiClient.configuration.endpoint).to eq 'endpoint'
expect(PixiClient.configuration.username).to eq 'username'
expect(PixiClient.configuration.password).to eq 'random-password'
+ expect(PixiClient.configuration.wsdl).to eq 'some/path/somewhere.wsdl'
end
end
end
|
Test the configuration too after adding the wsdl
|
diff --git a/spec/models/relation_spec.rb b/spec/models/relation_spec.rb
index abc1234..def5678 100644
--- a/spec/models/relation_spec.rb
+++ b/spec/models/relation_spec.rb
@@ -0,0 +1,26 @@+require 'rails_helper'
+
+describe RelatedContent do
+
+ let(:parent_relationable) { create([:proposal, :debate, :budget_investment].sample) }
+ let(:child_relationable) { create([:proposal, :debate, :budget_investment].sample) }
+
+ it "should allow relationables from various classes" do
+ expect(build(:related_content, parent_relationable: parent_relationable, child_relationable: child_relationable)).to be_valid
+ expect(build(:related_content, parent_relationable: parent_relationable, child_relationable: child_relationable)).to be_valid
+ expect(build(:related_content, parent_relationable: parent_relationable, child_relationable: child_relationable)).to be_valid
+ end
+
+ it "should not allow empty relationables" do
+ expect(build(:related_content)).not_to be_valid
+ expect(build(:related_content, parent_relationable: parent_relationable)).not_to be_valid
+ expect(build(:related_content, child_relationable: child_relationable)).not_to be_valid
+ end
+
+ it "should not allow repeated related contents" do
+ related_content = create(:related_content, parent_relationable: parent_relationable, child_relationable: child_relationable)
+ new_related_content = build(:related_content, parent_relationable: related_content.parent_relationable, child_relationable: related_content.child_relationable)
+ expect(new_related_content).not_to be_valid
+ end
+
+end
|
Add basic RelatedContent model spec to check multiple models can be related
|
diff --git a/spec/support/proc_helpers.rb b/spec/support/proc_helpers.rb
index abc1234..def5678 100644
--- a/spec/support/proc_helpers.rb
+++ b/spec/support/proc_helpers.rb
@@ -11,6 +11,8 @@ yield
[$stdout.string, $stderr.string]
+ rescue SystemExit => ex
+ fail "Unexpected SystemExit in capture_io: stdout=#{$stdout.string}, stderr=#{$stderr.string}"
ensure
$stdout = stdout
$stderr = stdout
|
Improve capture_io handling of unexpected exceptions
We frequently use `capture_io` in specs for testing running CLI
commands, many of which will indirectly end up calling `exit 1` in
failure conditions.
For a happy-path spec, if a regression breaks the spec, this is
problematic because `exit 1` gets called & `rspec` exits prematurely.
And, since stderr & stdout are being captured at the time of exit, you
don't see any message associated with the exit, and it's very
mysterious.
This add a rescue similar to `capture_io_and_exit_code` (which is
explicitly intended to test failure cases) to `capture_io` which will
fail the spec with an informative message if something does call `exit`.
|
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/home_controller.rb
+++ b/app/controllers/home_controller.rb
@@ -11,7 +11,7 @@ for slice in graph
res = http.head("/devices/?query=#{CGI::escape ActiveSupport::JSON.encode(slice['query'])}")
slice['data'] = res['Total'].to_i
- slice['href'] = url_for(controller: 'devices', action: 'index', params: {query: ActiveSupport::JSON.encode(slice['query'])})
+ slice['href'] = url_for(controller: 'devices', action: 'index', params: {query: ActiveSupport::JSON.encode(slice['query'])}, only_path: true)
slice.delete('query')
end
end
|
Use path-only URLs for chart slices.
|
diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb
index abc1234..def5678 100644
--- a/app/controllers/site_controller.rb
+++ b/app/controllers/site_controller.rb
@@ -7,6 +7,8 @@ @character = Character.where(id: params[:id], public: true).pluck(:name, :description).first
elsif params[:qc]
@character = Qc.where(id: params[:id], public: true).pluck(:name, :description).first
+ elsif params[:battlegroup]
+ @character = Battlegroup.where(id: params[:id], public: true).pluck(:name, :description).first
end
end
end
|
Support public battlegroup name/description on Discord links
|
diff --git a/app/helpers/font_awesome_helper.rb b/app/helpers/font_awesome_helper.rb
index abc1234..def5678 100644
--- a/app/helpers/font_awesome_helper.rb
+++ b/app/helpers/font_awesome_helper.rb
@@ -10,17 +10,20 @@
def label_with_icon(label, icon, opts = {})
+ fa_icon(icon, opts) + label
+ end
+
+
+ def fa_icon(icon, opts = {})
inverse = opts.delete(:inverse){ false }
fixed = opts.delete(:fixed){ false }
-
css_class = [ 'fa', 'fa-lg' ]
css_class.push(icon)
css_class.push('fa-inverse') if inverse
css_class.push('fa-fw') if fixed
css_class.delete('fa-lg') if fixed
-
klass = [opts.delete(:class), css_class].flatten.compact
- content_tag(:i, '', class: klass) + label
+ content_tag(:i, '', class: klass)
end
end
|
Add a hlper method to render FontAwesome icons
|
diff --git a/app/models/prompt_delivery_hour.rb b/app/models/prompt_delivery_hour.rb
index abc1234..def5678 100644
--- a/app/models/prompt_delivery_hour.rb
+++ b/app/models/prompt_delivery_hour.rb
@@ -5,11 +5,11 @@ end
def in_time_zone
- in_24_hours(hour + offset)
+ in_24_hours(hour + time_zone_offset)
end
def in_utc
- in_24_hours(hour - offset)
+ in_24_hours(hour - time_zone_offset)
end
private
@@ -26,15 +26,7 @@ end
end
- def offset
- time_zone_offset + dst_offset
- end
-
def time_zone_offset
- ActiveSupport::TimeZone[time_zone].utc_offset / 1.hour
- end
-
- def dst_offset
- Time.zone.now.in_time_zone(time_zone).dst? ? 1 : 0
+ Time.zone.now.in_time_zone(time_zone).utc_offset / 1.hour
end
end
|
Use Rails voodoo to get DST offset automatically
|
diff --git a/rocketjob_mission_control.gemspec b/rocketjob_mission_control.gemspec
index abc1234..def5678 100644
--- a/rocketjob_mission_control.gemspec
+++ b/rocketjob_mission_control.gemspec
@@ -16,7 +16,7 @@
s.add_dependency "access-granted", "~> 1.3"
s.add_dependency "jquery-rails"
- s.add_dependency "rails", ">= 5.0"
+ s.add_dependency "railties", ">= 5.0"
s.add_dependency "rocketjob", ">= 5.2.0"
s.add_dependency "sass-rails", ">= 3.2"
end
|
Change rails dependency to railties
|
diff --git a/lib/kepler_processor/saveable.rb b/lib/kepler_processor/saveable.rb
index abc1234..def5678 100644
--- a/lib/kepler_processor/saveable.rb
+++ b/lib/kepler_processor/saveable.rb
@@ -1,5 +1,6 @@ module KeplerProcessor
module Saveable
+
def full_output_filename
"#{@options[:output_path]}/#{output_filename}"
end
@@ -9,16 +10,17 @@ end
def save!
- if output_filename
- od = output_data || input_data || []
- ::FileUtils.mkpath options[:output_path]
- raise FileExistsError if File.exist?(full_output_filename) && !options[:force_overwrite]
- LOGGER.info "Writing output to #{full_output_filename}"
- CSV.open(full_output_filename, options[:force_overwrite] ? "w+" : "a+", :col_sep => "\t") do |csv|
- # impicitly truncate file by file mode when force overwriting
- od.each { |record| csv << record }
- end
+ return unless output_filename
+ od = output_data || input_data || []
+ ::FileUtils.mkpath options[:output_path]
+ raise FileExistsError if File.exist?(full_output_filename) && !options[:force_overwrite]
+ LOGGER.info "Writing output to #{full_output_filename}"
+ CSV.open(full_output_filename, options[:force_overwrite] ? "w+" : "a+", :col_sep => "\t") do |csv|
+ # impicitly truncate file by file mode when force overwriting
+ od.each { |record| csv << record }
end
+ true
end
+
end
end
|
Make Saveable a little prettier
|
diff --git a/lib/magnum/integration/github.rb b/lib/magnum/integration/github.rb
index abc1234..def5678 100644
--- a/lib/magnum/integration/github.rb
+++ b/lib/magnum/integration/github.rb
@@ -7,7 +7,8 @@ end
def repositories
- client.repositories.map { |r| format_repository(r) }
+ resp = client.repositories(nil, sort: "pushed", direction: "desc")
+ resp.map { |r| format_repository(r) }
end
def repository(id)
|
Sort repositories by push date
|
diff --git a/lib/rails_translation_manager.rb b/lib/rails_translation_manager.rb
index abc1234..def5678 100644
--- a/lib/rails_translation_manager.rb
+++ b/lib/rails_translation_manager.rb
@@ -13,4 +13,12 @@ autoload :Exporter, "rails_translation_manager/exporter"
autoload :Importer, "rails_translation_manager/importer"
autoload :Stealer, "rails_translation_manager/stealer"
+
+ rails_i18n_path = Gem::Specification.find_by_name("rails-i18n").gem_dir
+ rails_translation_manager = Gem::Specification.find_by_name("rails_translation_manager").gem_dir
+
+ I18n.load_path.concat(
+ Dir["#{rails_i18n_path}/rails/pluralization/*.rb"],
+ ["#{rails_translation_manager}/config/locales/plurals.rb"]
+ )
end
|
Add plural rules to I18n load path
This adds the native plural rules in rails-i18n and the bespoke list we
created in `config/locales/plurals.rb`. This allows them to be located
when we lookup the plural rules for all our supported languages.
`concat` and `Dir` have been used instead of `<< `..pluralization/*.rb`
for adding files to the load path due to the tests being unable to
expand the path, generating the below error:
```
Errno::ENOENT:
No such file or directory @ rb_sysopen - /Users/peterhartshorn/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rails-i18n-6.0.0/rails/pluralization/*.rb
```
|
diff --git a/config/initializers/active_record_mysql_timestamp.rb b/config/initializers/active_record_mysql_timestamp.rb
index abc1234..def5678 100644
--- a/config/initializers/active_record_mysql_timestamp.rb
+++ b/config/initializers/active_record_mysql_timestamp.rb
@@ -0,0 +1,30 @@+# Make sure that MySQL won't try to use CURRENT_TIMESTAMP when the timestamp
+# column is NOT NULL. See https://gitlab.com/gitlab-org/gitlab-ce/issues/36405
+# And also: https://bugs.mysql.com/bug.php?id=75098
+# This patch was based on:
+# https://github.com/rails/rails/blob/15ef55efb591e5379486ccf53dd3e13f416564f6/activerecord/lib/active_record/connection_adapters/mysql/schema_creation.rb#L34-L36
+
+if Gitlab::Database.mysql?
+ require 'active_record/connection_adapters/abstract/schema_creation'
+
+ module MySQLTimestampFix
+ def add_column_options!(sql, options)
+ # By default, TIMESTAMP columns are NOT NULL, cannot contain NULL values,
+ # and assigning NULL assigns the current timestamp. To permit a TIMESTAMP
+ # column to contain NULL, explicitly declare it with the NULL attribute.
+ # See http://dev.mysql.com/doc/refman/5.7/en/timestamp-initialization.html
+ if sql.end_with?('timestamp') && !options[:primary_key]
+ if options[:null] != false
+ sql << ' NULL'
+ elsif options[:column].default.nil?
+ sql << ' DEFAULT 0'
+ end
+ end
+
+ super
+ end
+ end
+
+ ActiveRecord::ConnectionAdapters::AbstractAdapter::SchemaCreation
+ .prepend(MySQLTimestampFix)
+end
|
Make sure MySQL would not use CURRENT_TIMESTAMP
for timestamp columns magically. See:
https://gitlab.com/gitlab-org/gitlab-ce/issues/36405
|
diff --git a/config/initializers/refraction_rules.rb b/config/initializers/refraction_rules.rb
index abc1234..def5678 100644
--- a/config/initializers/refraction_rules.rb
+++ b/config/initializers/refraction_rules.rb
@@ -8,7 +8,7 @@ Rails.logger.add(1, "\n\nREDIRECT : redirect issued for old heroku address\n\n")
req.permanent! :host => "travis-ci.org"
end
- # Rails.logger.flush
+ Rails.logger.flush
elsif req.host =~ /([-\w]+\.)+travis-ci\.org/
# we don't want to use www for now
req.permanent! :host => "travis-ci.org"
|
Revert "the flush was causing an app error, why was this not caught earlier?"
This reverts commit 834ebf3a026ae3de951917b231eecf70062756d9.
|
diff --git a/spec/bitmap_spec.rb b/spec/bitmap_spec.rb
index abc1234..def5678 100644
--- a/spec/bitmap_spec.rb
+++ b/spec/bitmap_spec.rb
@@ -1,33 +1,36 @@ require 'bitmap'
require 'color'
-RSpec.describe Bitmap, "#init" do
- context "With a given width and height" do
- width, height = 2, 2
- it "initializes a 2D array with given width and height" do
- bitmap = Bitmap.new width, height
- expect(bitmap.data.length).to eq width
- expect(bitmap.data[0].length).to eq height
+describe Bitmap do
+
+ width, height = 2, 2
+ factor = 2
+
+ before(:each) do
+ @bitmap = Bitmap.new width, height
+ end
+
+ describe "when initialized" do
+ it "should have the correct width and height" do
+ expect(@bitmap.data.length).to eq width
+ expect(@bitmap.data[0].length).to eq height
end
- it "initializes a 2D array with random color" do
- bitmap = Bitmap.new width, height
- expect(bitmap.data[0][0]).to be_a RandomColor
+ it "should have random color entries" do
+ expect(@bitmap.data[0][0]).to be_a RandomColor
+ end
+ end
+
+ describe "when enlarged" do
+ before(:each) do
+ @bitmap.enlarge factor
+ end
+ it "should be factor times greater in width and height." do
+ expect(@bitmap.data.length).to eq width*factor
+ (height*factor).times do |index|
+ expect(@bitmap.data[index].length).to eq height*factor
+ end
end
end
end
-
-RSpec.describe Bitmap, "#enlarge" do
- context "With a given width, height and color" do
- width, height, factor = 2, 2, 2
- color = Color.new 1, 2, 3
- it "enlarging a 2x2 bitmap by 2 will yield a 4x4 bitmap." do
- bitmap = Bitmap.new width, height, color
- bitmap.enlarge 2
- expect(bitmap.data.length).to eq width*factor
- (height*factor).times do |index|
- expect(bitmap.data[index].length).to eq height*factor
- end
- end
- end
-end
+# TODO add tests for width and heigth stretch
|
Refactor tests and add todo for new test cases.
|
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index abc1234..def5678 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,27 +1,15 @@ require 'serverspec'
-require 'net/ssh'
-
-include SpecInfra::Helper::DetectOS
-include SpecInfra::Helper::Exec
-include SpecInfra::Helper::Ssh
if ENV['RAKE_ANSIBLE_USE_VAGRANT']
require 'lib/vagrant'
- conn = Vagrant.new
+ c = Vagrant.new
else
require 'lib/docker'
- conn = Docker.new
+ c = Docker.new
end
-RSpec.configure do |config|
- config.before :all do
- config.host = conn.ssh_host
- opts = Net::SSH::Config.for(config.host)
- opts[:port] = conn.ssh_port
- opts[:keys] = conn.ssh_keys
- opts[:auth_methods] = Net::SSH::Config.default_auth_methods
- config.ssh = Net::SSH.start(conn.ssh_host, conn.ssh_user, opts)
- end
-end
+set :backend, :ssh
+set :host, c.ssh_host
+set :ssh_options, :user => c.ssh_user, :port => c.ssh_port, :keys => c.ssh_keys
|
Update integration testing to work with Serverspec 2.N
|
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index abc1234..def5678 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1 +1,12 @@ require 'cassandra/mapper'
+
+TEST_KEYSPACE = 'test_mapper'
+
+# create testing keyspace if needed
+cassandra = Cassandra.new('system')
+unless cassandra.keyspaces.include? TEST_KEYSPACE
+ cassandra.add_keyspace Cassandra::Keyspace.new \
+ name: TEST_KEYSPACE,
+ strategy_options: { 'replication_factor' => '1' },
+ cf_defs: []
+end
|
Create testing keyspace if needed
|
diff --git a/app/views/osc_jobs/show.json.jbuilder b/app/views/osc_jobs/show.json.jbuilder
index abc1234..def5678 100644
--- a/app/views/osc_jobs/show.json.jbuilder
+++ b/app/views/osc_jobs/show.json.jbuilder
@@ -1 +1,2 @@ json.extract! @osc_job, :name, :batch_host, :created_at, :updated_at
+json.folder_contents @folder_contents
|
Include job folder contents in payload
|
diff --git a/config/initializers/delayed_job.rb b/config/initializers/delayed_job.rb
index abc1234..def5678 100644
--- a/config/initializers/delayed_job.rb
+++ b/config/initializers/delayed_job.rb
@@ -12,4 +12,28 @@
ActionMailer::Base.logger = Delayed::Worker.logger
+ module Delayed
+ module Backend
+ module ActiveRecord
+ class Job
+ class << self
+
+ alias_method :reserve_original, :reserve
+
+ def reserve(worker, max_run_time = Worker.max_run_time)
+ previous_level = ::ActiveRecord::Base.logger.level
+ ::ActiveRecord::Base.logger.level = Logger::WARN if previous_level < Logger::WARN
+
+ value = reserve_original(worker, max_run_time)
+ ::ActiveRecord::Base.logger.level = previous_level
+
+ value
+ end
+
+ end
+ end
+ end
+ end
+ end
+
end
|
Hide delayed job sql messages in production.log
|
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index abc1234..def5678 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,5 +1,10 @@ require 'coveralls'
Coveralls.wear!
+
+SimpleCov.formatter = Coveralls::SimpleCov::Formatter
+SimpleCov.start do
+ add_filter 'spec/dummy'
+end
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
Exclude spec/dummy from SimpleCov for Coveralls
|
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index abc1234..def5678 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -21,12 +21,11 @@ config.run_all_when_everything_filtered = true
config.filter_run :focus
config.raise_errors_for_deprecations!
-
- # Run specs in random order to surface order dependencies. If you find an
- # order dependency and want to debug it, you can fix the order by providing
- # the seed, which is printed after each run.
- # --seed 1234
- config.order = 'random'
+ config.mock_with :rspec do |mocks|
+ mocks.verify_partial_doubles = true
+ end
+ config.disable_monkey_patching!
+ config.order = :random
# Remove defined constants
config.before :each do
|
Update specs helper to prevent monkey patching.
|
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index abc1234..def5678 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,2 +1,14 @@ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'rubyxls'
+
+RSpec.configure do |config|
+
+ config.after(:all) do
+ FileUtils.rm_rf("#{tmp_dir_path}/.")
+ end
+
+end
+
+def tmp_dir_path
+ File.expand_path('../../tmp/', __FILE__)
+end
|
Remove contents of tmp dir after build
|
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index abc1234..def5678 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -9,3 +9,9 @@ Dir[SPEC_DIR.join("support", "**", "*.rb")].each {|f| require f}
CONFIG = YAML.load_file(SPEC_DIR.join("config.yml")).with_indifferent_access
+
+RSpec.configure do |c|
+ c.before do
+ BloomRemitClient.sandbox = true
+ end
+end
|
Set sandbox to true for tests
|
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index abc1234..def5678 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,10 +1,10 @@-require 'bundler'
-Bundler.require
-
require 'coveralls'
Coveralls.wear! do
add_filter 'spec'
end
+
+require 'bundler'
+Bundler.require
require 'acfs'
require 'webmock/rspec'
|
Move Bundler.require to get coverage back.
|
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index abc1234..def5678 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -17,7 +17,7 @@ add_group 'Libraries', '/lib/'
end
- SimpleCov.minimum_coverage(99)
+ SimpleCov.minimum_coverage(98)
SimpleCov.start 'gem'
end
|
Drop test coverage to 98%
Tests are good but 99% is very high and we need
the VPN functionality ASAP.
|
diff --git a/api.rb b/api.rb
index abc1234..def5678 100644
--- a/api.rb
+++ b/api.rb
@@ -6,9 +6,7 @@ "It runs from Heroku!"
end
-get '/messages/next' do
- return {:message => "A message!"}.to_json
-end
+### MOBILE CLIENT API
# API sends 'message' as :
# message_id
@@ -16,23 +14,31 @@ # delay (of current message)
# children (message_id, choice)
-# when a client app opens a "game scenario" for the first time
-get '/scenarios/:unique_scenario_id/messages' do
- # get from request body 'first_time' (boolean)
+# ALL routes below require a user token parameter (so linked to an account)
- # if user's first time
- # create a new record (table) for this particular scenario
- # insert scenario's first message into the table
- # return first message
- # elsif user already played scenario
- # return the message log and next message
- # end
+get '/scenarios' do
+ # return all_available_scenario_ids
end
-post '/scenarios/:unique_scenario_id/messages/:message_id/choices/:choice_id' do
+get '/scenarios/:unique_scenario_id' do
+ # return scenario specific information
+end
- # update the user's scenario log in table
+# only called by the client when first time opening a scenario
+get '/scenarios/:unique_scenario_id/messages' do
+ # if a user already has a log
+ # return all messages
- # return next message
+ # else
+ # create a new empty store
+ # return first message(s)
+end
+put '/messages/:message_id/choices/:choice_id' do
+ # REQUIRES
+ # a paramater corresponding to a scenario id
+
+ # update the store
+
+ # returns the next message(s)
end
|
Clarify mobile client API routes
Shorten the base routes and move required paramaters. Add basic
pseudocode to methods.
|
diff --git a/spec/acceptance/001_basic_spec.rb b/spec/acceptance/001_basic_spec.rb
index abc1234..def5678 100644
--- a/spec/acceptance/001_basic_spec.rb
+++ b/spec/acceptance/001_basic_spec.rb
@@ -34,7 +34,7 @@ expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
sleep 5
end
-logstash
+
describe service(service_name) do
it { should be_enabled }
it { should be_running }
|
Remove extra string in stub acceptance test
|
diff --git a/spec/active_record_spec_helper.rb b/spec/active_record_spec_helper.rb
index abc1234..def5678 100644
--- a/spec/active_record_spec_helper.rb
+++ b/spec/active_record_spec_helper.rb
@@ -16,7 +16,7 @@ /../config/initializers/#{name}.rb")
end
- connection_info = YAML.load_file("config/database.yml")
+ connection_info = YAML.load(ERB.new(File.read("config/database.yml")).result)
ActiveRecord::Base.establish_connection(connection_info['test'])
app_translations = Dir[
|
Fix yaml erb parsing when Rails is not loaded
|
diff --git a/spec/controllers/conference_registration_controller_spec.rb b/spec/controllers/conference_registration_controller_spec.rb
index abc1234..def5678 100644
--- a/spec/controllers/conference_registration_controller_spec.rb
+++ b/spec/controllers/conference_registration_controller_spec.rb
@@ -0,0 +1,76 @@+require 'spec_helper'
+
+describe ConferenceRegistrationsController, type: :controller do
+ let(:conference) { create(:conference) }
+ let(:user) { create(:user) }
+
+ context 'user is signed in' do
+ before { sign_in(user) }
+
+ describe 'GET #edit' do
+ before do
+ @registration = create(:registration, conference: conference, user: user)
+ get :edit, conference_id: conference.short_title
+ end
+
+ it 'assigns conference and registration variable' do
+ expect(assigns(:conference)).to eq conference
+ expect(assigns(:registration)).to eq @registration
+ end
+
+ it 'renders the edit template' do
+ expect(response).to render_template('edit')
+ end
+ end
+
+ describe 'PATCH #update' do
+ before do
+ @registration = create(:registration,
+ conference: conference,
+ user: user,
+ arrival: Date.new(2014, 04, 25))
+ end
+
+ context 'updates successfully' do
+ before do
+ patch :update, registration: attributes_for(:registration, arrival: Date.new(2014, 04, 29)),
+ conference_id: conference.short_title
+ end
+
+ it 'redirects to registration show path' do
+ expect(response).to redirect_to conference_conference_registrations_path(conference.short_title)
+ end
+
+ it 'shows success message in flash notice' do
+ expect(flash[:notice]).to match('Registration was successfully updated.')
+ end
+
+ it 'updates the registration' do
+ @registration.reload
+ expect(@registration.arrival).to eq Date.new(2014, 04, 29)
+ end
+ end
+
+ context 'update fails' do
+ before do
+ allow_any_instance_of(Registration).to receive(:update_attributes).and_return(false)
+ patch :update, registration: attributes_for(:registration, arrival: Date.new(2014, 04, 27)),
+ conference_id: conference.short_title
+ end
+
+ it 'renders edit template' do
+ expect(response).to render_template('edit')
+ end
+
+ it 'shows error in flash message' do
+ expect(flash[:error]).to match "Could not update your registration for The dog and pony show: #{@registration.errors.full_messages.join('. ')}."
+ end
+
+ it 'does not update the registration' do
+ @registration.reload
+ expect(@registration.arrival).to eq Date.new(2014, 04, 25)
+ end
+ end
+ end
+ end
+end
|
Add test for conference registration controller edit and update action
|
diff --git a/app.rb b/app.rb
index abc1234..def5678 100644
--- a/app.rb
+++ b/app.rb
@@ -15,6 +15,7 @@
DB_DIR = APP_ROOT + 'db'
DB_DIR.mkpath
+
DataMapper.setup(:default,
ENV['DATABASE_URL'] || "sqlite://#{DB_DIR}/tdrb.db")
end
|
Add newline in configure block for cleanliness
|
diff --git a/app.rb b/app.rb
index abc1234..def5678 100644
--- a/app.rb
+++ b/app.rb
@@ -1,4 +1,6 @@ require 'sinatra'
+
+set :sessions, true
get '/' do
File.read('index.html')
@@ -6,4 +8,11 @@
post '/demo' do
"The username is #{params['username']} and the password is #{params['password']}"
+ session[:userid] = params['username']
+ session[:token] = 'token here'
+ redirect to '/videos'
end
+
+get '/videos' do
+ "List of videos for #{session[:userid]} with token #{session[:token]}"
+end
|
Add a little more info
|
diff --git a/spec/controllers/requests_controller_spec.rb b/spec/controllers/requests_controller_spec.rb
index abc1234..def5678 100644
--- a/spec/controllers/requests_controller_spec.rb
+++ b/spec/controllers/requests_controller_spec.rb
@@ -28,14 +28,8 @@ context 'when request ID is not created' do
it 'throws a 404' do
get 'show_raw', :rid => create_uuid
-
+
expect(response.status).to eq(404)
- end
- end
-
- context 'when a request is private' do
- it 'appends correct no-cache headers' do
- # check the cache control header
end
end
end
|
Remove check for private requests
Not used and it was showing as a passing test.
|
diff --git a/lib/api_wrapper_example/mock/api_server.rb b/lib/api_wrapper_example/mock/api_server.rb
index abc1234..def5678 100644
--- a/lib/api_wrapper_example/mock/api_server.rb
+++ b/lib/api_wrapper_example/mock/api_server.rb
@@ -8,6 +8,15 @@
get '/v1/mittens' do
JSON.dump(REPO)
+ end
+
+ get '/v1/mittens/:name' do |name|
+ halt 404 unless REPO.key?(name)
+
+ [200, JSON.dump(
+ 'name' => name,
+ 'color' => REPO[name]
+ )]
end
post '/v1/mittens/:name' do |name|
|
Implement mock version of GET /v1/mittens/:name
|
diff --git a/lib/brewery_db/middleware/error_handler.rb b/lib/brewery_db/middleware/error_handler.rb
index abc1234..def5678 100644
--- a/lib/brewery_db/middleware/error_handler.rb
+++ b/lib/brewery_db/middleware/error_handler.rb
@@ -6,7 +6,7 @@ when 200
when 400 then raise BadRequest.new(env[:body].error_message)
when 404 then raise NotFound.new(env[:body].error_message)
- else raise Error.new(env[:status])
+ else raise Error.new(env[:status].to_s)
end
end
end
|
Fix failing error handler specs under Ruby 1.9.2.
|
diff --git a/lib/minitest/ruby_golf_metrics/reporter.rb b/lib/minitest/ruby_golf_metrics/reporter.rb
index abc1234..def5678 100644
--- a/lib/minitest/ruby_golf_metrics/reporter.rb
+++ b/lib/minitest/ruby_golf_metrics/reporter.rb
@@ -21,7 +21,7 @@
def report
io.puts "\nRuby Golf Metrics"
- @ergs.each do |method_name, ergs|
+ @ergs.sort.each do |method_name, ergs|
begin
if ergs.all?
begin
|
Sort metrics output by method name
|
diff --git a/lib/puppet-lint/plugins/check_variables.rb b/lib/puppet-lint/plugins/check_variables.rb
index abc1234..def5678 100644
--- a/lib/puppet-lint/plugins/check_variables.rb
+++ b/lib/puppet-lint/plugins/check_variables.rb
@@ -1,23 +1,18 @@ class PuppetLint::Plugins::CheckVariables < PuppetLint::CheckPlugin
+ # Public: Test the manifest tokens for variables that contain a dash and
+ # record a warning for each instance found.
+ #
+ # Returns nothing.
check 'variable_contains_dash' do
- tokens.each_index do |token_idx|
- token = tokens[token_idx]
-
- if token.first == :VARIABLE
- variable = token.last[:value]
- line_no = token.last[:line]
- if variable.match(/-/)
- notify :warning, :message => "variable contains a dash", :linenumber => line_no
- end
- end
-
- if token.first == :DQPRE
- end_of_string_idx = tokens[token_idx..-1].index { |r| r.first == :DQPOST }
- tokens[token_idx..end_of_string_idx].each do |t|
- if t.first == :VARIABLE and t.last[:value].match(/-/)
- notify :warning, :message => "variable contains a dash", :linenumber => t.last[:line]
- end
- end
+ tokens.select { |r|
+ [:VARIABLE, :UNENC_VARIABLE].include? r.type
+ }.each do |token|
+ if token.value.match(/-/)
+ notify :warning, {
+ :message => 'variable contains a dash',
+ :linenumber => token.line,
+ :column => token.column,
+ }
end
end
end
|
Rewrite variable_contains_dash check to use new lexer
|
diff --git a/lib/puppet/parser/functions/query_nodes.rb b/lib/puppet/parser/functions/query_nodes.rb
index abc1234..def5678 100644
--- a/lib/puppet/parser/functions/query_nodes.rb
+++ b/lib/puppet/parser/functions/query_nodes.rb
@@ -11,8 +11,8 @@
EOT
) do |args|
+ query, filter = args
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'puppetdb'))
- query, filter = args
raise(Puppet::Error, 'Query is a required parameter') unless query
- PuppetDB.new.query_nodes(:query => query, :filter => filter, :only_active => true)
+ PuppetDB.new.query_nodes(:query => query, :filter => filter)
end
|
Fix query node to remove active only filter.
Query node should not filter by active_only node.
|
diff --git a/db/migrate/20150618193748_create_skills.rb b/db/migrate/20150618193748_create_skills.rb
index abc1234..def5678 100644
--- a/db/migrate/20150618193748_create_skills.rb
+++ b/db/migrate/20150618193748_create_skills.rb
@@ -2,8 +2,8 @@ def change
create_table :skills do |t|
t.string :title
- t.integer :current_streak
- t.integer :longest_streak
+ t.integer :current_streak, default: 1
+ t.integer :longest_streak, default: 1
t.references :user
t.timestamps
|
Add defaults to skills migration
|
diff --git a/db/seeds/modules/gobierto_data/seeds.rb b/db/seeds/modules/gobierto_data/seeds.rb
index abc1234..def5678 100644
--- a/db/seeds/modules/gobierto_data/seeds.rb
+++ b/db/seeds/modules/gobierto_data/seeds.rb
@@ -0,0 +1,52 @@+# frozen_string_literal: true
+
+module GobiertoSeeds
+ class Recipe
+ def self.run(site)
+ description = site.custom_fields.localized_string.where(class_name: "GobiertoData::Dataset").find_or_initialize_by(uid: "description")
+ if description.new_record?
+ description.name_translations = { ca: "Descripció", en: "Description", es: "Descripción" }
+ description.position = 1
+ description.options = { configuration: {} }
+ description.save
+ end
+
+ frequency = site.custom_fields.vocabulary_options.where(class_name: "GobiertoData::Dataset").find_or_initialize_by(uid: "frequency")
+ if frequency.new_record?
+ vocabulary = site.vocabularies.find_or_initialize_by(slug: "datasets-frequency")
+ if vocabulary.new_record?
+ vocabulary.name_translations = { ca: "Freqüència", en: "Frequency", es: "Frecuencia" }
+ vocabulary.save
+ vocabulary.terms.create(name_translations: { ca: "Anual", en: "Annual", es: "Anual" })
+ vocabulary.terms.create(name_translations: { ca: "Trimestral", en: "Quarterly", es: "Trimestral" })
+ vocabulary.terms.create(name_translations: { ca: "Mensual", en: "Monthly", es: "Mensual" })
+ vocabulary.terms.create(name_translations: { ca: "Diària", en: "Daily", es: "Diaria" })
+ end
+ frequency.name_translations = { ca: "Freqüència", en: "Frequency", es: "Frecuencia" }
+ frequency.position = 2
+ frequency.options = {
+ configuration: { vocabulary_type: "single_select" },
+ vocabulary_id: vocabulary.id.to_s
+ }
+ frequency.save
+ end
+
+ category = site.custom_fields.vocabulary_options.where(class_name: "GobiertoData::Dataset").find_or_initialize_by(uid: "category")
+ return unless category.new_record?
+
+ vocabulary = site.vocabularies.find_or_initialize_by(slug: "datasets-category")
+ if vocabulary.new_record?
+ vocabulary.name_translations = { ca: "Categoria", en: "Category", es: "Categoría" }
+ vocabulary.save
+ vocabulary.terms.create(name_translations: { ca: "General", en: "General", es: "General" })
+ end
+ category.name_translations = { ca: "Categoria", en: "Category", es: "Categoría" }
+ category.position = 3
+ category.options = {
+ configuration: { vocabulary_type: "single_select" },
+ vocabulary_id: vocabulary.id.to_s
+ }
+ category.save
+ end
+ end
+end
|
Add seed recipe of gobierto data with default custom fields
|
diff --git a/app/channels/run_channel.rb b/app/channels/run_channel.rb
index abc1234..def5678 100644
--- a/app/channels/run_channel.rb
+++ b/app/channels/run_channel.rb
@@ -11,6 +11,8 @@ run,
time_since_upload: ApplicationController.render(partial: 'runs/time_since_upload', locals: {run: run})
)
+ rescue ActiveRecord::RecordNotFound # If the run has been deleted since we scheduled this job, noop
+ nil
end
end
end
|
Fix jobs running on dead runs
|
diff --git a/test/unit/document_queue_test.rb b/test/unit/document_queue_test.rb
index abc1234..def5678 100644
--- a/test/unit/document_queue_test.rb
+++ b/test/unit/document_queue_test.rb
@@ -0,0 +1,18 @@+require "test_helper"
+require "elasticsearch/document_queue"
+require "elasticsearch/bulk_index_worker"
+
+class DocumentQueueTest < MiniTest::Unit::TestCase
+ def sample_document_hashes
+ %w(foo bar baz).map do |slug|
+ {:link => "/#{slug}", :title => slug.capitalize}
+ end
+ end
+
+ def test_can_queue_documents_in_bulk
+ Elasticsearch::BulkIndexWorker.expects(:perform_async)
+ .with("test-index", sample_document_hashes)
+ queue = Elasticsearch::DocumentQueue.new("test-index")
+ queue.queue_many(sample_document_hashes)
+ end
+end
|
Test the functionality of the DocumentQueue.
|
diff --git a/test/cookbooks/apache2_test/recipes/setup.rb b/test/cookbooks/apache2_test/recipes/setup.rb
index abc1234..def5678 100644
--- a/test/cookbooks/apache2_test/recipes/setup.rb
+++ b/test/cookbooks/apache2_test/recipes/setup.rb
@@ -2,19 +2,9 @@
case node['platform_family']
when 'debian'
- %w(libxml2 libxml2-dev libxslt1-dev).each do |pkg|
- package pkg do
- action :install
- end
- end
+ package %w(libxml2 libxml2-dev libxslt1-dev)
when 'rhel'
- %w(gcc make ruby-devel libxml2 libxml2-devel libxslt libxslt-devel).each do |pkg|
- package pkg do
- action :install
- end
- end
+ package %w(gcc make ruby-devel libxml2 libxml2-devel libxslt libxslt-devel)
end
-package 'curl' do
- action :install
-end
+package 'curl'
|
Use multipackage installs in the test recipe
Signed-off-by: Tim Smith <764ef62106582a09ed09dfa0b6bff7c05fd7d1e4@chef.io>
|
diff --git a/tasks/modules/logging/collins.rb b/tasks/modules/logging/collins.rb
index abc1234..def5678 100644
--- a/tasks/modules/logging/collins.rb
+++ b/tasks/modules/logging/collins.rb
@@ -10,8 +10,8 @@ end
def self.log message
- if self.facter['asset_tag']
- collins.log! 'tumblrtag301', message
+ if facter['asset_tag']
+ collins.log! facter['asset_tag'], message
end
end
end
|
Use asset tag from facter when logging
|
diff --git a/config/deploy/production2.rb b/config/deploy/production2.rb
index abc1234..def5678 100644
--- a/config/deploy/production2.rb
+++ b/config/deploy/production2.rb
@@ -4,7 +4,7 @@ # uncomment in case of travis, capistrano will have its own
set :ssh_options, keys: ["config/deploy_id_rsa"] if File.exist?("config/deploy_id_rsa")
set :ssh_options, port: 7047
-set :api_token, "k5p3CkdUBDg4wORWbdFHejGATB9onFHYK7cWqG12Th7Q6XvhCCzquF1PQAEEPVmj"
+set :api_token, "bTEXsl4wJJomq5h1BaDEWCstSPbcGmIqFWO8IS5bltOcy6eBgrOD3H7Vgh8wUQnk"
set :deploy_to, "/var/www/pricewars-merchant2"
# Configuration
|
Update token for merchant 2
|
diff --git a/ci_environment/postgresql/attributes/default.rb b/ci_environment/postgresql/attributes/default.rb
index abc1234..def5678 100644
--- a/ci_environment/postgresql/attributes/default.rb
+++ b/ci_environment/postgresql/attributes/default.rb
@@ -13,6 +13,7 @@ default['postgresql']['data_on_ramfs'] = true # enabled for CI purpose
if node['postgresql']['data_on_ramfs']
+ include_attribute 'ramfs::default'
default['postgresql']['data_dir'] = "#{node['ramfs']['dir']}/postgresql"
else
default['postgresql']['data_dir'] = '/var/lib/postgresql'
|
Fix RAMFS dependency problem in PostgreSQL
Related to 050c194a4be0bdcc6a6dd1bcfc61c69ffe41df97
Still pending to check if this regression affects Chef 10 and 11
|
diff --git a/spec/system/cars_endpoint_spec.rb b/spec/system/cars_endpoint_spec.rb
index abc1234..def5678 100644
--- a/spec/system/cars_endpoint_spec.rb
+++ b/spec/system/cars_endpoint_spec.rb
@@ -0,0 +1,39 @@+require "json"
+
+RSpec.describe "System tests" do
+ describe "/cars API endpoint" do
+ let!(:pipe) { open("|cars_api server") }
+
+ after do
+ Process.kill("INT", pipe.pid)
+ end
+
+ context "when car store is empty" do
+ it "is empty" do
+ `cars_api import ./spec/fixtures/empty.json`
+ markers = fetch_data
+ expect(markers["cars"].count).to eq(0)
+ end
+ end
+
+ context "when car store has something" do
+ it "returns some car markers" do
+ `cars_api import ./spec/fixtures/data.json`
+ markers = fetch_data
+ expect(markers["cars"].count).to be > 0
+ end
+ end
+
+ def fetch_data(retries = 30)
+ raise "Unable to fetch data" if retries < 0
+
+ output = `curl localhost:4567/cars?location=45.67,23.37 2>/dev/null`
+ begin
+ JSON.parse(output)
+ rescue
+ sleep(0.5)
+ fetch_data(retries - 1)
+ end
+ end
+ end
+end
|
Add smoke tests for /cars endpoint together with import command
|
diff --git a/cookbooks/elasticsearch/recipes/sensu_checks.rb b/cookbooks/elasticsearch/recipes/sensu_checks.rb
index abc1234..def5678 100644
--- a/cookbooks/elasticsearch/recipes/sensu_checks.rb
+++ b/cookbooks/elasticsearch/recipes/sensu_checks.rb
@@ -8,6 +8,9 @@ sensu_check 'check-es-cluster-status' do
command "#{node['sensu']['directories']['base']}/plugins/sensu-yieldbot-plugins/elasticsearch/check-es-cluster-status.rb"
handlers ['devops-red']
+ additional(
+ :occurrences => 3
+ )
standalone true
end
|
Set the number of occurrences to 3 for the cluster status alarm.
|
diff --git a/test/admin_ui/test_api_scopes.rb b/test/admin_ui/test_api_scopes.rb
index abc1234..def5678 100644
--- a/test/admin_ui/test_api_scopes.rb
+++ b/test/admin_ui/test_api_scopes.rb
@@ -0,0 +1,54 @@+require_relative "../test_helper"
+
+class Test::AdminUi::TestApiScopes < Minitest::Capybara::Test
+ include Capybara::Screenshot::MiniTestPlugin
+ include ApiUmbrellaTestHelpers::AdminAuth
+ include ApiUmbrellaTestHelpers::Setup
+
+ def setup
+ super
+ setup_server
+
+ ApiScope.delete_all
+ end
+
+ def test_create
+ admin_login
+ visit("/admin/#/api_scopes/new")
+
+ fill_in("Name", :with => "Example")
+ fill_in("Host", :with => "example.com")
+ fill_in("Path Prefix", :with => "/foo/")
+
+ click_button("Save")
+ assert_text("Successfully saved")
+
+ api_scope = ApiScope.desc(:created_at).first
+ assert_equal("Example", api_scope.name)
+ assert_equal("example.com", api_scope.host)
+ assert_equal("/foo/", api_scope.path_prefix)
+ end
+
+ def test_update
+ api_scope = FactoryGirl.create(:api_scope)
+
+ admin_login
+ visit("/admin/#/api_scopes/#{api_scope.id}/edit")
+
+ assert_field("Name", :with => "Example")
+ assert_field("Host", :with => "localhost")
+ assert_field("Path Prefix", :with => "/example")
+
+ fill_in("Name", :with => "Example2")
+ fill_in("Host", :with => "2.example.com")
+ fill_in("Path Prefix", :with => "/2/")
+
+ click_button("Save")
+ assert_text("Successfully saved")
+
+ api_scope.reload
+ assert_equal("Example2", api_scope.name)
+ assert_equal("2.example.com", api_scope.host)
+ assert_equal("/2/", api_scope.path_prefix)
+ end
+end
|
Add tests for api scope forms in admin UI too.
|
diff --git a/examples/multi_select_disabled_paged.rb b/examples/multi_select_disabled_paged.rb
index abc1234..def5678 100644
--- a/examples/multi_select_disabled_paged.rb
+++ b/examples/multi_select_disabled_paged.rb
@@ -0,0 +1,22 @@+# frozen_string_literal: true
+
+require_relative "../lib/tty-prompt"
+
+prompt = TTY::Prompt.new
+
+numbers = [
+ {name: '1', disabled: 'out'},
+ '2',
+ {name: '3', disabled: 'out'},
+ '4',
+ '5',
+ {name: '6', disabled: 'out'},
+ '7',
+ '8',
+ '9',
+ {name: '10', disabled: 'out'}
+]
+
+answer = prompt.multi_select('Which letter?', numbers, per_page: 4, cycle: true)
+
+puts answer.inspect
|
Add multi_select prompt pagination of disabled items example
|
diff --git a/custom_counter_cache.gemspec b/custom_counter_cache.gemspec
index abc1234..def5678 100644
--- a/custom_counter_cache.gemspec
+++ b/custom_counter_cache.gemspec
@@ -13,7 +13,7 @@ s.require_paths = ['lib']
s.files = Dir['lib/**/*.rb']
s.required_rubygems_version = '>= 1.3.6'
- s.add_dependency('rails', '>= 3.1')
+ s.add_dependency('rails', Gem::Platform::RUBY < '1.9.2' ? '~> 3.1' : '>= 3.1')
s.add_development_dependency('sqlite3')
s.test_files = Dir['test/**/*.rb']
s.rubyforge_project = 'custom_counter_cache'
|
Fix Rails version requirement for Travis.
|
diff --git a/chef/site-cookbooks/sana-protocol-builder/recipes/default.rb b/chef/site-cookbooks/sana-protocol-builder/recipes/default.rb
index abc1234..def5678 100644
--- a/chef/site-cookbooks/sana-protocol-builder/recipes/default.rb
+++ b/chef/site-cookbooks/sana-protocol-builder/recipes/default.rb
@@ -28,7 +28,7 @@
command '/root/.virtualenvs/sana_protocol_builder/bin/gunicorn sana_builder.wsgi:application -c config/gunicorn.conf.py'
directory '/opt/sana.protocol_builder'
- environment 'PATH=\"/root/.virtualenvs/sana_protocol_builder/bin\"'
+ environment 'PATH' => '/root/.virtualenvs/sana_protocol_builder/bin'
redirect_stderr true
end
|
Fix environment to be a hash.
|
diff --git a/lib/pathway/rspec/matchers/list_helpers.rb b/lib/pathway/rspec/matchers/list_helpers.rb
index abc1234..def5678 100644
--- a/lib/pathway/rspec/matchers/list_helpers.rb
+++ b/lib/pathway/rspec/matchers/list_helpers.rb
@@ -3,8 +3,8 @@ module Pathway
module Rspec
module ListHelpers
- def as_list(items)
- as_sentence(items.map(&:inspect))
+ def as_list(items, **kwargs)
+ as_sentence(items.map(&:inspect), **kwargs)
end
def as_sentence(items, connector: ', ', last_connector: ' and ')
|
Allow as_list helper for matcher to take connectors as params
|
diff --git a/config/deploy/interactions-staging.rb b/config/deploy/interactions-staging.rb
index abc1234..def5678 100644
--- a/config/deploy/interactions-staging.rb
+++ b/config/deploy/interactions-staging.rb
@@ -1,5 +1,6 @@ # interactions staging branch
set :user, "deploy"
+set :gateway, "otto.concord.org"
set :domain, "63.138.119.195" # ruby-vm12
set :deploy_to, "/web/portal"
server domain, :app, :web
|
Update interactions staging deploy config
|
diff --git a/config.ru b/config.ru
index abc1234..def5678 100644
--- a/config.ru
+++ b/config.ru
@@ -1,5 +1,6 @@-require 'chaindrive/api'
-require 'chaindrive/web'
+$:.unshift('lib').uniq!
+
+require 'chaindrive'
use Rack::Session::Cookie
run Rack::Cascade.new [Chaindrive::API, Chaindrive::Web]
|
Fix issue with load path and lib folder.
|
diff --git a/lib/docbert/parser.rb b/lib/docbert/parser.rb
index abc1234..def5678 100644
--- a/lib/docbert/parser.rb
+++ b/lib/docbert/parser.rb
@@ -4,7 +4,6 @@ class Parser < Kramdown::Parser::Kramdown
EXAMPLE_KEYWORDS = "Given|When|Then|And|But|\\|"
EXAMPLE_START = /#{BLANK_LINE}?^\s*Example:/
- EXAMPLE_BODY = /(?:\s*(?:#{EXAMPLE_KEYWORDS}).+?\n|#{BLANK_LINE})+/m
def initialize(source, options)
super
@@ -13,6 +12,10 @@ end
private
+
+ def example_body_regexp(keywords)
+ /(?:\s*(?:#{keywords}).+?\n|#{BLANK_LINE})+/m
+ end
# Parse an example block.
#
@@ -23,7 +26,10 @@
example = new_block_el(:example)
title_el = Element.new(:example_title, @src.scan(/.+?\n/).strip)
- body = @src.scan(EXAMPLE_BODY).gsub(/^ +/, '').strip
+ body = @src.
+ scan(example_body_regexp(EXAMPLE_KEYWORDS)).
+ gsub(/^ +/, '').
+ strip
body_el = Element.new(:example_body, body)
example.children << title_el << body_el
|
Make example body regexp dynamically configurable.
|
diff --git a/lib/llt/review/api.rb b/lib/llt/review/api.rb
index abc1234..def5678 100644
--- a/lib/llt/review/api.rb
+++ b/lib/llt/review/api.rb
@@ -9,11 +9,15 @@ gold = Array(params[:gold])
rev = Array(params[:reviewable])
+ comp_param = params[:compare]
+ comparables = comp_param ? Array(comp_param).map(&:to_sym) : nil
+
klass = params[:type]
# return an error if klass is neither treebank nor Alignment
diff = LLT::Review.const_get(klass.capitalize).new
- diff.diff(gold, rev)
+ puts comparables
+ diff.diff(gold, rev, comparables)
respond_to do |f|
f.xml { diff.to_xml }
|
Add compare param to diff routes
|
diff --git a/lib/mill/navigator.rb b/lib/mill/navigator.rb
index abc1234..def5678 100644
--- a/lib/mill/navigator.rb
+++ b/lib/mill/navigator.rb
@@ -14,13 +14,14 @@
end
- def initialize(items: [])
+ def initialize(items: [], site: nil)
@items = Hash[
items.map do |uri, title|
item = Item.new(uri: uri, title: title)
[item.uri, item]
end
]
+ @site = site
end
def items
|
Save site object in Navigator class for subclassing use.
|
diff --git a/fourchan_kit.gemspec b/fourchan_kit.gemspec
index abc1234..def5678 100644
--- a/fourchan_kit.gemspec
+++ b/fourchan_kit.gemspec
@@ -21,4 +21,6 @@ spec.add_development_dependency "bundler", "~> 1.6"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec"
+ spec.add_development_dependency "vcr", "~> 2.9"
+ spec.add_development_dependency "webmock", "~> 1.17"
end
|
Add two dependencies for RSpec
|
diff --git a/lib/mongoid_seeder.rb b/lib/mongoid_seeder.rb
index abc1234..def5678 100644
--- a/lib/mongoid_seeder.rb
+++ b/lib/mongoid_seeder.rb
@@ -47,6 +47,6 @@ end
def self.after_tests
- Mongoid.session(:default).collections.select{|a| Config.condition_to_drop_collection.call(a) }.each(&:drop)
+ Mongoid.session(:default).collections.select{|a| Config.condition_to_drop_collection.call(a) }.each{|a| a.where.remove_all }
end
end
|
Make the collections truncate instead of drop
|
diff --git a/contrib/connected_active_record/sample/config/application.rb b/contrib/connected_active_record/sample/config/application.rb
index abc1234..def5678 100644
--- a/contrib/connected_active_record/sample/config/application.rb
+++ b/contrib/connected_active_record/sample/config/application.rb
@@ -28,6 +28,8 @@ # Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
# the framework and any gems in your application.
+ config.paths.add 'orders/lib', eager_load: true
+ config.paths.add 'payments/lib', eager_load: true
# Don't generate system test files.
config.generators.system_tests = nil
|
Add load path for BCs
|
diff --git a/lib/souffle/server.rb b/lib/souffle/server.rb
index abc1234..def5678 100644
--- a/lib/souffle/server.rb
+++ b/lib/souffle/server.rb
@@ -1,5 +1,6 @@ require 'puma'
require 'eventmachine'
+require 'em-synchrony'
require 'souffle/http'
# The souffle server and management daemon.
@@ -12,7 +13,7 @@ # Runs the server.
def run
if Souffle::Config[:server]
- EM.run do
+ EM.synchrony do
@app = Rack::Builder.new do
use Rack::Lint
use Rack::ShowExceptions
|
Update event loop to use em-synchrony
|
diff --git a/db/migrate/20160912161354_reset_pk.rb b/db/migrate/20160912161354_reset_pk.rb
index abc1234..def5678 100644
--- a/db/migrate/20160912161354_reset_pk.rb
+++ b/db/migrate/20160912161354_reset_pk.rb
@@ -0,0 +1,7 @@+class ResetPk < ActiveRecord::Migration[5.0]
+ def change
+ ActiveRecord::Base.connection.tables.each do |t|
+ ActiveRecord::Base.connection.reset_pk_sequence!(t)
+ end
+ end
+end
|
Add migration to fix primary key issue
|
diff --git a/lib/kaminari/models/mongoid_criteria_methods.rb b/lib/kaminari/models/mongoid_criteria_methods.rb
index abc1234..def5678 100644
--- a/lib/kaminari/models/mongoid_criteria_methods.rb
+++ b/lib/kaminari/models/mongoid_criteria_methods.rb
@@ -1,5 +1,9 @@ module Kaminari
module MongoidCriteriaMethods
+ def entry_name
+ model_name.human.downcase
+ end
+
def limit_value #:nodoc:
options[:limit]
end
|
Simplify page_entries_info by adding entry_name interface to each ORM
|
diff --git a/spec/entities/resource_spec.rb b/spec/entities/resource_spec.rb
index abc1234..def5678 100644
--- a/spec/entities/resource_spec.rb
+++ b/spec/entities/resource_spec.rb
@@ -0,0 +1,29 @@+describe Dox::Entities::Resource do
+ subject { described_class }
+
+ let(:resource_name) { 'Pokemons' }
+ let(:details) do
+ {
+ resource_desc: 'Pokemons',
+ resource_endpoint: '/pokemons',
+ }
+ end
+
+ let(:resource) { subject.new(resource_name, details) }
+
+ describe '#name' do
+ it { expect(resource.name).to eq(resource_name) }
+ end
+
+ describe '#desc' do
+ it { expect(resource.desc).to eq(details[:resource_desc]) }
+ end
+
+ describe '#endpoint' do
+ it { expect(resource.endpoint).to eq(details[:resource_endpoint]) }
+ end
+
+ describe '#actions' do
+ it { expect(resource.actions).to eq({}) }
+ end
+end
|
Add entities specs for resource
|
diff --git a/spec/features/donation_spec.rb b/spec/features/donation_spec.rb
index abc1234..def5678 100644
--- a/spec/features/donation_spec.rb
+++ b/spec/features/donation_spec.rb
@@ -11,8 +11,22 @@
Capybara.within_frame 'stripe_checkout_app' do
fill_in 'Email', with: 'rspec@example.com'
- fill_in 'Card number', with: '4242 4242 4242 4242'
- fill_in 'MM / YY', with: 1.year.from_now.strftime('%m/%y')
+ # the next bit *would* be:
+ # fill_in 'Card number', with: '4242 4242 4242 4242'
+ # except that the result is that card_number becomes
+ # 4242 (actually a random subset of above)
+ card_number_field = page.find_by_id('card_number')
+ '4242424242424242'.chars.each do |digit|
+ card_number_field.send_keys digit
+ sleep 0.1
+ end
+
+ # fill_in 'MM / YY', with: 1.year.from_now.strftime('%m/%y')
+ cc_exp_field = page.find_by_id 'cc-exp'
+ 1.year.from_now.strftime('%m/%y').chars.each do |char|
+ cc_exp_field.send_keys char
+ sleep 0.1
+ end
fill_in 'CVC', with: '322'
click_button 'Pay $5.45'
end
|
Use stupid workaround for stripe input
|
diff --git a/lib/parkaby/frameworks/camping.rb b/lib/parkaby/frameworks/camping.rb
index abc1234..def5678 100644
--- a/lib/parkaby/frameworks/camping.rb
+++ b/lib/parkaby/frameworks/camping.rb
@@ -1,34 +1,58 @@ Parkaby.load('parse_tree', 'ParseTree')
module Parkaby::Frameworks::Camping
+ class Processor < SexpProcessor
+ def initialize(*a)
+ super
+ self.require_empty = false
+ end
+
+ def process_call(exp)
+ if partial?(exp)
+ s(:call, nil, :text, s(:arglist, exp))
+ else
+ exp
+ end
+ end
+
+ def partial?(exp)
+ exp[1].nil? &&
+ exp[2].to_s[0] == ?_
+ end
+ end
+
def self.included(mod)
mod.module_eval %q{
include(CompiledViews = Module.new {
include Views
})
+ module Views
+ def self.compile!
+ instance_methods(false).each do |method|
+ compile_method(method)
+ end
+ end
+
+ def self.compile_method(method)
+ sexp = ParseTree.translate(Views, method)
+ sexp = Unifier.new.process(sexp)
+ sexp = Parkaby::Frameworks::Camping::Processor.new.process(sexp)
+ sexp[3] = Parkaby::Processor.new(Views).build(sexp[3])
+ ruby = Parkaby::Generator.new.process(sexp)
+ CompiledViews.class_eval(ruby)
+ end
+ end
+
def render(m)
parkaby(m, m.to_s[0] != ?_)
end
def parkaby(method, layout, &blk)
- parkify(method) unless parkified?(method)
s = send(method, &blk)
s = parkaby(:layout, false) { s } if layout
s
end
-
- def parkified?(method)
- CompiledViews.instance_methods(false).include?(method.to_s)
- end
-
- def parkify(method)
- # method(method).to_sexp is broken
- sexp = ParseTree.translate(Views, method)
- sexp = Unifier.new.process(sexp)
- temp = Parkaby::Template.new(sexp[3])
- temp.def_method(CompiledViews, method)
- end
}
end
end
|
Make the Camping handler smarter
|
diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb
index abc1234..def5678 100644
--- a/spec/spec_helper_acceptance.rb
+++ b/spec/spec_helper_acceptance.rb
@@ -4,20 +4,21 @@ require 'beaker/module_install_helper'
run_puppet_install_helper unless ENV['BEAKER_provision'] == 'no'
-install_ca_certs unless ENV['PUPPET_INSTALL_TYPE'] =~ %r{pe}i
-install_module_on(hosts)
-install_module_dependencies_on(hosts)
RSpec.configure do |c|
# Readable test descriptions
c.formatter = :documentation
- hosts.each do |host|
- if host[:platform] =~ %r{el-7-x86_64} && host[:hypervisor] =~ %r{docker}
- on(host, "sed -i '/nodocs/d' /etc/yum.conf")
- end
- if fact_on(host, 'osfamily') == 'RedHat'
- on host, puppet('resource', 'package', 'epel-release', 'ensure=installed')
- on host, puppet('resource', 'package', 'redhat-lsb-core', 'ensure=installed')
+
+ # Configure all nodes in nodeset
+ c.before :suite do
+ install_module
+ install_module_dependencies
+
+ hosts.each do |host|
+ if fact_on(host, 'osfamily') == 'RedHat'
+ host.install_package('epel-release')
+ host.install_package('redhat-lsb-core')
+ end
end
end
end
|
Clean up acceptance spec helper
|
diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb
index abc1234..def5678 100644
--- a/spec/spec_helper_acceptance.rb
+++ b/spec/spec_helper_acceptance.rb
@@ -3,7 +3,7 @@
hosts.each do |host|
# Install Puppet
- on host, install_puppet
+ install_package(host, 'puppet')
end
RSpec.configure do |c|
|
Install puppet package from distro sources
My acceptance tests should run against the lowest common denominator on
which the module is supported. This is currently puppet 2.7 as shipped
with Debian Wheezy. install_puppet installs from Puppetlabs repos, so switch
to install_package instead.
|
diff --git a/spec/twitter/geo/point_spec.rb b/spec/twitter/geo/point_spec.rb
index abc1234..def5678 100644
--- a/spec/twitter/geo/point_spec.rb
+++ b/spec/twitter/geo/point_spec.rb
@@ -28,7 +28,7 @@
describe "#latitude" do
it "returns the latitude" do
- @point.latitude.should eq -122.399983
+ @point.latitude.should eq(-122.399983)
end
end
|
Fix "ambiguous first argument" warning
|
diff --git a/test/unit/repository_test.rb b/test/unit/repository_test.rb
index abc1234..def5678 100644
--- a/test/unit/repository_test.rb
+++ b/test/unit/repository_test.rb
@@ -2,6 +2,10 @@ require 'citrus/repository'
class RepositoryTest < UnitTestCase
+ def valid_repository_url
+ "git://github.com/pawelpacana/citrus-sample-repository"
+ end
+
def test_should_checkout_remote_repository
with_citrus_root do |root|
tmpdir = File.join(root, 'test_repo')
|
Fix repository url used in tests.
|
diff --git a/lib/brewery_db/collection.rb b/lib/brewery_db/collection.rb
index abc1234..def5678 100644
--- a/lib/brewery_db/collection.rb
+++ b/lib/brewery_db/collection.rb
@@ -4,7 +4,7 @@
BATCH_SIZE = 50
- attr_reader :size, :page_count
+ attr_reader :size
alias length size
def initialize(response)
|
Remove page_count; it is not a concern of Collection
|
diff --git a/spec/requests/voice_survey_spec.rb b/spec/requests/voice_survey_spec.rb
index abc1234..def5678 100644
--- a/spec/requests/voice_survey_spec.rb
+++ b/spec/requests/voice_survey_spec.rb
@@ -0,0 +1,20 @@+require 'spec_helper'
+
+describe "Voice Survey Interface" do
+
+ def hash_from_xml(nokogiri_doc)
+ Hash.from_xml(nokogiri_doc.to_s)
+ end
+
+ describe "initial call" do
+ before(:each) do
+ post 'route_to_survey'
+ @body_hash = hash_from_xml(response.body)
+ end
+ it "prompts for property vs hood" do
+ @body_hash["Response"]["Say"].should include("enter the property code")
+ end
+ end
+
+
+end
|
Set up test for initial routing
|
diff --git a/spec/warden/jwt_auth/hooks_spec.rb b/spec/warden/jwt_auth/hooks_spec.rb
index abc1234..def5678 100644
--- a/spec/warden/jwt_auth/hooks_spec.rb
+++ b/spec/warden/jwt_auth/hooks_spec.rb
@@ -17,12 +17,20 @@ end
context 'when method and path match and scope is known ' do
- it 'codes a token and adds it to env' do
+ before do
login_as user, scope: :user
post '/sign_in'
+ end
+ it 'codes a token and adds it to env' do
expect(token(last_request)).not_to be_nil
+ end
+
+ it 'adds user info to the token' do
+ payload = Warden::JWTAuth::TokenDecoder.new.call(token(last_request))
+
+ expect(payload['sub']).to eq(user.jwt_subject)
end
end
|
Test hook provides user when generating the token
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.