diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4de46cc0a3..38e8cc39b2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -362,7 +362,7 @@ Layout/SpaceInsideBlockBraces: # Offense count: 57 # Cop supports --auto-correct. -Layout/SpaceInsideBrackets: +Layout/SpaceInsideArrayLiteralBrackets: Enabled: false # Offense count: 1571 @@ -466,7 +466,7 @@ Lint/AssignmentInCondition: # Cop supports --auto-correct. # Configuration parameters: EnforcedStyleAlignWith, SupportedStylesAlignWith. # SupportedStylesAlignWith: either, start_of_block, start_of_line -Lint/BlockAlignment: +Layout/BlockAlignment: Exclude: - 'app/controllers/people_controller.rb' - 'app/mailers/person_mailer.rb' @@ -500,7 +500,7 @@ Lint/DuplicateMethods: # Cop supports --auto-correct. # Configuration parameters: EnforcedStyleAlignWith, SupportedStylesAlignWith, AutoCorrect. # SupportedStylesAlignWith: keyword, variable, start_of_line -Lint/EndAlignment: +Layout/EndAlignment: Enabled: false # Offense count: 1 @@ -709,7 +709,7 @@ Security/YAMLLoad: - 'lib/tasks/sharetribe_db.rake' # Offense count: 16 -Style/AccessorMethodName: +Naming/AccessorMethodName: Exclude: - 'app/controllers/admin/categories_controller.rb' - 'app/controllers/listings_controller.rb' @@ -992,14 +992,14 @@ Style/MethodDefParentheses: - 'app/models/sortable_by_priority.rb' # Offense count: 1 -Style/MethodMissing: +Style/MethodMissingSuper: Exclude: - 'lib/services/paypal_service/test_logger.rb' # Offense count: 1 # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: snake_case, camelCase -Style/MethodName: +Naming/MethodName: Exclude: - 'features/step_definitions/admin_look_and_feel_steps.rb' @@ -1179,7 +1179,7 @@ Style/PerlBackrefs: # NamePrefix: is_, has_, have_ # NamePrefixBlacklist: is_, has_, have_ # NameWhitelist: is_a? -Style/PredicateName: +Naming/PredicateName: Enabled: false # Offense count: 5 @@ -1393,7 +1393,7 @@ Style/TrailingCommaInArguments: # Cop supports --auto-correct. # Configuration parameters: EnforcedStyleForMultiline, SupportedStylesForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, no_comma -Style/TrailingCommaInLiteral: +Style/TrailingCommaInArrayLiteral: Enabled: false # Offense count: 1 @@ -1445,7 +1445,7 @@ Style/UnneededPercentQ: # Offense count: 8 # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: snake_case, normalcase, non_integer -Style/VariableNumber: +Naming/VariableNumber: Exclude: - 'spec/services/paypal_service/data_types/ipn_spec.rb' - 'spec/services/transaction_service/process_spec.rb' @@ -1488,15 +1488,12 @@ Rails/Delegate: - 'app/models/person.rb' Rails/DynamicFindBy: + Enabled: false Exclude: - 'spec/**/*' - 'test/**/*' - 'features/**/*' - -Rails/DynamicFindBy: - Enabled: false - Rails/FilePath: Exclude: - 'spec/**/*' @@ -1682,3 +1679,30 @@ Rails/Validation: Rails/UniqBeforePluck: Exclude: - 'app/services/marketplace_service/inbox.rb' + +Naming/UncommunicativeMethodParamName: + MinNameLength: 1 + +Naming/ConstantName: + Enabled: false + +Style/AccessModifierDeclarations: + Exclude: + - 'test/helper_modules.rb' + +Rails/LexicallyScopedActionFilter: + Exclude: + - 'app/controllers/**/*' + +Naming/RescuedExceptionsVariableName: + Enabled: false + +Naming/MemoizedInstanceVariableName: + Exclude: + - 'app/services/paypal_service/ipn_injector.rb' + - 'app/services/paypal_service/paypal_service_injector.rb' + - 'app/services/transaction_service/jobs/process_preauthorize_command.rb' + - 'app/services/email_service/email_service_injector.rb' + - 'app/services/custom_landing_page/listing_store.rb' + - 'app/services/custom_landing_page/category_store.rb' + diff --git a/Gemfile b/Gemfile index fb42b0e04d..d33f86c937 100644 --- a/Gemfile +++ b/Gemfile @@ -38,9 +38,9 @@ gem 'flying-sphinx', '~> 1.2.0' # Use patched v2.0.2 # Fixes issues: Create a new delayed delta job if there is an existing delta job which has failed gem 'ts-delayed-delta', - :git => 'https://github.com/pat/ts-delayed-delta.git', + :git => 'https://github.com/pat/ts-delayed-delta.git', :branch => 'master', - :ref => '0aef2195f3acc1da048f18bc0191c90538565705' + :ref => '0aef2195f3acc1da048f18bc0191c90538565705' gem 'possibly', '~> 1.0.1' gem 'delayed_job', '~> 4.1.3' @@ -107,7 +107,7 @@ group :staging, :production do end group :development, :test do - gem 'rubocop', '~> 0.49.1', require: false + gem 'rubocop', '~> 0.67.2', require: false gem 'factory_girl_rails', '~> 4.8.0' end diff --git a/Gemfile.lock b/Gemfile.lock index 48a92b3fb5..66c2e61997 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -259,6 +259,7 @@ GEM innertube (1.1.0) intercom (3.5.14) json (>= 1.8) + jaro_winkler (1.5.2) jmespath (1.3.1) joiner (0.3.4) activerecord (>= 4.1.0) @@ -362,7 +363,7 @@ GEM mime-types mimemagic (~> 0.3.0) parallel (1.17.0) - parser (2.6.2.0) + parser (2.6.2.1) ast (~> 2.4.0) passenger (6.0.1) rack @@ -375,7 +376,6 @@ GEM paypal-sdk-permissions (1.96.4) paypal-sdk-core (~> 0.3.0) possibly (1.0.1) - powerpack (0.1.2) premailer (1.10.4) addressable css_parser (>= 1.4.10) @@ -386,6 +386,7 @@ GEM pry-byebug (3.7.0) byebug (~> 11.0) pry (~> 0.10) + psych (3.1.0) public_suffix (2.0.5) pusher-client (0.6.2) json @@ -485,13 +486,14 @@ GEM rspec_junit_formatter (0.2.3) builder (< 4) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (0.49.1) + rubocop (0.67.2) + jaro_winkler (~> 1.5.1) parallel (~> 1.10) - parser (>= 2.3.3.1, < 3.0) - powerpack (~> 0.1) - rainbow (>= 1.99.1, < 3.0) + parser (>= 2.5, != 2.5.1.1) + psych (>= 3.1.0) + rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) + unicode-display_width (>= 1.4.0, < 1.6) ruby-progressbar (1.10.0) ruby_dep (1.5.0) rubyzip (1.2.2) @@ -670,7 +672,7 @@ DEPENDENCIES rest-client (~> 2.0.2) rspec-rails (~> 3.6.0) rspec_junit_formatter - rubocop (~> 0.49.1) + rubocop (~> 0.67.2) rubyzip (~> 1.2.2) sass (~> 3.4.24) sass-rails (~> 5.0.6) diff --git a/Rakefile b/Rakefile index b145b4dc23..387ecbbb3f 100644 --- a/Rakefile +++ b/Rakefile @@ -1,13 +1,13 @@ # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require File.expand_path('../config/application', __FILE__) +require File.expand_path('config/application', __dir__) require 'rake' begin require 'delayed/tasks' rescue LoadError - STDERR.puts "Run `bundle install` to install delayed_job" + warn "Run `bundle install` to install delayed_job" end Kassi::Application.load_tasks diff --git a/app/controllers/admin/categories_controller.rb b/app/controllers/admin/categories_controller.rb index ef44cac4eb..525fa34067 100644 --- a/app/controllers/admin/categories_controller.rb +++ b/app/controllers/admin/categories_controller.rb @@ -45,7 +45,7 @@ def update shapes = @current_community.shapes selected_shape_ids = shape_ids_from_params(params) - if @category.update_attributes(category_params) + if @category.update(category_params) update_category_listing_shapes(selected_shape_ids, @category) redirect_to admin_categories_path else @@ -57,7 +57,7 @@ def update def order new_sort_order = params[:order].map(&:to_i).each_with_index order_categories!(new_sort_order) - render body: nil, status: 200 + render body: nil, status: :ok end # Remove form diff --git a/app/controllers/admin/communities/footer_controller.rb b/app/controllers/admin/communities/footer_controller.rb index 7c229e0940..bc20389be7 100644 --- a/app/controllers/admin/communities/footer_controller.rb +++ b/app/controllers/admin/communities/footer_controller.rb @@ -4,6 +4,7 @@ class Admin::Communities::FooterController < Admin::AdminBaseController def update return if @service.plan_footer_disabled? + if @service.update flash[:notice] = t('layouts.notifications.community_updated') redirect_to admin_footer_edit_path diff --git a/app/controllers/admin/communities/topbar_controller.rb b/app/controllers/admin/communities/topbar_controller.rb index 8d72e1cdf3..dc78caccff 100644 --- a/app/controllers/admin/communities/topbar_controller.rb +++ b/app/controllers/admin/communities/topbar_controller.rb @@ -41,7 +41,7 @@ def update menu_links_params[:logo_link] = params[:logo_link] - if @current_community.update_attributes(menu_links_params) + if @current_community.update(menu_links_params) flash[:notice] = t("layouts.notifications.community_updated") redirect_to admin_topbar_edit_path else diff --git a/app/controllers/admin/communities_controller.rb b/app/controllers/admin/communities_controller.rb index b68d4d505a..908ad2001b 100644 --- a/app/controllers/admin/communities_controller.rb +++ b/app/controllers/admin/communities_controller.rb @@ -98,14 +98,14 @@ def check_email_status render json: HashUtils.camelize_keys(address.merge(translated_verification_sent_time_ago: time_ago(address[:verification_requested_at]))) else - render json: {error: res.error_msg }, status: 500 + render json: {error: res.error_msg }, status: :internal_server_error end end def resend_verification_email EmailService::API::Api.addresses.enqueue_verification_request(community_id: @current_community.id, id: params[:address_id]) - render json: {}, status: 200 + render json: {}, status: :ok end def social_media @@ -265,7 +265,7 @@ def update_analytics def delete_marketplace if can_delete_marketplace?(@current_community.id) && params[:delete_confirmation] == @current_community.ident - @current_community.update_attributes(deleted: true) + @current_community.update(deleted: true) redirect_to Maybe(delete_redirect_url(APP_CONFIG)).or_else(:community_not_found) else @@ -296,7 +296,7 @@ def images_changed?(params) end def update(model, params, path, action, &block) - if model.update_attributes(params) + if model.update(params) flash[:notice] = t("layouts.notifications.community_updated") block.call(model) if block_given? #on success, call optional block redirect_to path @@ -335,7 +335,7 @@ def ensure_white_label_plan def update_feature_flags(community_id:, person_id:, user_enabled:, user_disabled:, community_enabled:, community_disabled:) updates = [] - updates << ->() { + updates << -> { FeatureFlagService::API::Api.features.enable(community_id: community_id, person_id: person_id, features: user_enabled) } unless user_enabled.blank? updates << ->(*) { @@ -354,6 +354,7 @@ def update_feature_flags(community_id:, person_id:, user_enabled:, user_disabled def find_or_initialize_customizations @current_community.locales.each do |locale| next if @current_community.community_customizations.find_by_locale(locale) + @current_community.community_customizations.create( slogan: @current_community.slogan, description: @current_community.description, diff --git a/app/controllers/admin/community_customizations_controller.rb b/app/controllers/admin/community_customizations_controller.rb index 8acf1d750f..6eba04e585 100644 --- a/app/controllers/admin/community_customizations_controller.rb +++ b/app/controllers/admin/community_customizations_controller.rb @@ -35,7 +35,7 @@ def update_details customizations = find_or_initialize_customizations_for_locale(locale) customizations.assign_attributes(locale_params) analytic.process(customizations) - update_results.push(customizations.update_attributes({})) + update_results.push(customizations.update({})) customizations end @@ -51,13 +51,13 @@ def update_details end transaction_agreement_checked = Maybe(params)[:community][:transaction_agreement_checkbox].is_some? - update_results.push(@current_community.update_attributes(transaction_agreement_in_use: transaction_agreement_checked)) + update_results.push(@current_community.update(transaction_agreement_in_use: transaction_agreement_checked)) show_slogan = Maybe(params)[:community][:show_slogan].is_some? - update_results.push(@current_community.update_attributes(show_slogan: show_slogan)) + update_results.push(@current_community.update(show_slogan: show_slogan)) show_description = Maybe(params)[:community][:show_description].is_some? - update_results.push(@current_community.update_attributes(show_description: show_description)) + update_results.push(@current_community.update(show_description: show_description)) analytic.send_properties if update_results.all? && (!process_locales || enabled_locales_valid) diff --git a/app/controllers/admin/community_memberships_controller.rb b/app/controllers/admin/community_memberships_controller.rb index 99c7bca9c6..9436b821a4 100644 --- a/app/controllers/admin/community_memberships_controller.rb +++ b/app/controllers/admin/community_memberships_controller.rb @@ -50,21 +50,21 @@ def unban def promote_admin if @service.removes_itself? - render body: nil, status: 405 + render body: nil, status: :method_not_allowed else @service.promote_admin - render body: nil, status: 200 + render body: nil, status: :ok end end def posting_allowed @service.posting_allowed - render body: nil, status: 200 + render body: nil, status: :ok end def resend_confirmation @service.resend_confirmation - render body: nil, status: 200 + render body: nil, status: :ok end private diff --git a/app/controllers/admin/community_seo_settings_controller.rb b/app/controllers/admin/community_seo_settings_controller.rb index 10264e70c0..3bb8003cac 100644 --- a/app/controllers/admin/community_seo_settings_controller.rb +++ b/app/controllers/admin/community_seo_settings_controller.rb @@ -22,7 +22,7 @@ def update :category_meta_description, ] ) - @current_community.update_attributes(meta_params) + @current_community.update(meta_params) redirect_to action: :show end @@ -31,6 +31,7 @@ def update def find_or_initialize_customizations @current_community.locales.each do |locale| next if @current_community.community_customizations.find_by_locale(locale) + @current_community.community_customizations.create( slogan: @current_community.slogan, description: @current_community.description, diff --git a/app/controllers/admin/custom_fields_controller.rb b/app/controllers/admin/custom_fields_controller.rb index bb57e52b20..0a3bff71ad 100644 --- a/app/controllers/admin/custom_fields_controller.rb +++ b/app/controllers/admin/custom_fields_controller.rb @@ -5,10 +5,8 @@ class Admin::CustomFieldsController < Admin::AdminBaseController CHECKBOX_TO_BOOLEAN = ->(v) { if v == false || v == true v - elsif v == "1" - true else - false + v == "1" end } @@ -179,7 +177,7 @@ def update custom_field_entity = build_custom_field_entity(@custom_field.type, custom_field_params) - @custom_field.update_attributes(custom_field_entity) + @custom_field.update(custom_field_entity) redirect_to admin_custom_fields_path end @@ -215,7 +213,7 @@ def update_price :price_filter_max ) - success = @current_community.update_attributes(price_params) + success = @current_community.update(price_params) if success redirect_to admin_custom_fields_path @@ -228,7 +226,7 @@ def update_price def update_location location_params = params.require(:community).permit(:listing_location_required) - success = @current_community.update_attributes(location_params) + success = @current_community.update(location_params) if success redirect_to admin_custom_fields_path @@ -241,7 +239,7 @@ def update_location def update_expiration listing_expiration_enabled = params[:listing_expiration_enabled] == "enabled" - success = @current_community.update_attributes( + success = @current_community.update( { hide_expiration_date: !listing_expiration_enabled }) if success @@ -278,10 +276,10 @@ def order end @current_community.custom_fields.each do |custom_field| - custom_field.update_attributes(:sort_priority => sort_priorities[custom_field.id]) + custom_field.update(:sort_priority => sort_priorities[custom_field.id]) end - render body: nil, status: 200 + render body: nil, status: :ok end private diff --git a/app/controllers/admin/emails_controller.rb b/app/controllers/admin/emails_controller.rb index 34a0ad2b8e..19b6f1870c 100644 --- a/app/controllers/admin/emails_controller.rb +++ b/app/controllers/admin/emails_controller.rb @@ -1,4 +1,3 @@ -# encoding: utf-8 class Admin::EmailsController < Admin::AdminBaseController def new @selected_tribe_navi_tab = "admin" diff --git a/app/controllers/admin/getting_started_guide_controller.rb b/app/controllers/admin/getting_started_guide_controller.rb index 4c5443c3ac..2c56682e17 100644 --- a/app/controllers/admin/getting_started_guide_controller.rb +++ b/app/controllers/admin/getting_started_guide_controller.rb @@ -58,7 +58,7 @@ def data(page:) additional_info: { listing_shape_name: listing_shape_name } - }, + } } sorted_steps = OnboardingViewUtils.sorted_steps_with_includes(onboarding_status, additional_info) @@ -68,7 +68,7 @@ def data(page:) page: page, onboarding_data: sorted_steps, name: PersonViewUtils.person_display_name(@current_user, @current_community), - info_icon: icon_tag("information"), + info_icon: icon_tag("information") } } end diff --git a/app/controllers/admin/listing_shapes_controller.rb b/app/controllers/admin/listing_shapes_controller.rb index ba4299eaf4..0030b0880f 100644 --- a/app/controllers/admin/listing_shapes_controller.rb +++ b/app/controllers/admin/listing_shapes_controller.rb @@ -143,7 +143,7 @@ def order @current_community.shapes.where(id: d[:value][:id]).update_all(sort_priority: d[:value][:sort_priority]) } - render body: nil, status: 200 + render body: nil, status: :ok end def close_listings @@ -187,7 +187,7 @@ def uneditable_fields(process_summary, author_is_seller) { shipping_enabled: !process_summary[:preauthorize_available] || !author_is_seller, online_payments: !process_summary[:preauthorize_available] || !author_is_seller, - availability: !process_summary[:preauthorize_available] || !author_is_seller, + availability: !process_summary[:preauthorize_available] || !author_is_seller } end @@ -226,7 +226,7 @@ def common_locals(form:, count:, process_summary:, available_locs:) harmony_in_use: APP_CONFIG.harmony_api_in_use.to_s == "true", display_knowledge_base_articles: APP_CONFIG.display_knowledge_base_articles.to_s == "true", knowledge_base_url: APP_CONFIG.knowledge_base_url, - locale_name_mapping: available_locs.map { |name, l| [l, name] }.to_h, + locale_name_mapping: available_locs.map { |name, l| [l, name] }.to_h } end @@ -333,7 +333,7 @@ def params_to_shape(params) parsed_params = form_params.merge( units: parse_units_from_params(form_params), - author_is_seller: form_params[:author_is_seller] == "false" ? false : true # default true + author_is_seller: form_params[:author_is_seller] != "false" # default true ) Shape.call(parsed_params) diff --git a/app/controllers/admin/payment_preferences_controller.rb b/app/controllers/admin/payment_preferences_controller.rb index d38dc44029..7c57b8179a 100644 --- a/app/controllers/admin/payment_preferences_controller.rb +++ b/app/controllers/admin/payment_preferences_controller.rb @@ -25,8 +25,8 @@ def index stripe_connected: stripe_connected, paypal_connected: paypal_connected, payments_connected: stripe_connected || paypal_connected, - stripe_allowed: TransactionService::AvailableCurrencies.stripe_allows_country_and_currency?(@current_community.country, @current_community.currency, stripe_mode), - paypal_allowed: TransactionService::AvailableCurrencies.paypal_allows_country_and_currency?(@current_community.country, @current_community.currency), + stripe_allowed: TransactionService::AvailableCurrencies.stripe_allows_country_and_currency?(@current_community.country, @current_community.currency, stripe_mode), + paypal_allowed: TransactionService::AvailableCurrencies.paypal_allows_country_and_currency?(@current_community.country, @current_community.currency), stripe_ready: StripeHelper.community_ready_for_payments?(@current_community.id), paypal_ready: PaypalHelper.community_ready_for_payments?(@current_community.id), paypal_enabled_by_admin: !!paypal_tx_settings[:active], diff --git a/app/controllers/admin/person_custom_fields_controller.rb b/app/controllers/admin/person_custom_fields_controller.rb index 429b9cc7d6..310f8bf733 100644 --- a/app/controllers/admin/person_custom_fields_controller.rb +++ b/app/controllers/admin/person_custom_fields_controller.rb @@ -32,7 +32,7 @@ def destroy def order @service.order - render body: nil, status: 200 + render body: nil, status: :ok end private diff --git a/app/controllers/amazon_bounces_controller.rb b/app/controllers/amazon_bounces_controller.rb index 2d9957478b..92d6affe12 100644 --- a/app/controllers/amazon_bounces_controller.rb +++ b/app/controllers/amazon_bounces_controller.rb @@ -37,7 +37,7 @@ def send_subscription_confirmation(request_body) require 'open-uri' json = JSON.parse(request_body) subscribe_url = json['SubscribeURL'] - open(subscribe_url) + open(subscribe_url) # rubocop:disable Security/Open end def handle_bounces(msg) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index eba41170f8..a1ed9c9f07 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -308,7 +308,7 @@ def perform_redirect # plain stub for routes, intercepted in perfom_redirect def not_available - render 'errors/community_not_found', layout: false, status: 404, locals: { status: 404, title: "Marketplace not found", host: request.host } + render 'errors/community_not_found', layout: false, status: :not_found, locals: { status: 404, title: "Marketplace not found", host: request.host } end def fetch_community_membership @@ -358,7 +358,7 @@ def cannot_access_without_confirmation end def fetch_community_admin_status - @is_current_community_admin = (@current_user && @current_user.has_admin_rights?(@current_community)) + @is_current_community_admin = (@current_user&.has_admin_rights?(@current_community)) end def fetch_community_plan_expiration_status @@ -384,7 +384,7 @@ def warn_about_missing_payment_info if has_paid_listings && accept_payments.blank? payment_settings_link = view_context.link_to(t("paypal_accounts.from_your_payment_settings_link_text"), - person_payment_settings_path(@current_user), target: "_blank") + person_payment_settings_path(@current_user), target: "_blank", rel: "noopener") flash.now[:warning] = t("stripe_accounts.missing_payment", settings_link: payment_settings_link).html_safe end @@ -445,6 +445,7 @@ def fetch_translations def check_http_auth return true unless APP_CONFIG.use_http_auth.to_s.downcase == 'true' + if authenticate_with_http_basic { |u, p| u == APP_CONFIG.http_auth_username && p == APP_CONFIG.http_auth_password } true else diff --git a/app/controllers/community_memberships_controller.rb b/app/controllers/community_memberships_controller.rb index a928105e05..5347007f45 100644 --- a/app/controllers/community_memberships_controller.rb +++ b/app/controllers/community_memberships_controller.rb @@ -32,7 +32,7 @@ def give_consent form_params = params[:form] || {} values = Form.call(form_params) - invitation_check = ->() { + invitation_check = -> { if @current_community.join_with_invite_only? validate_invitation_code(invitation_code: values[:invitation_code], community: @current_community) @@ -213,12 +213,12 @@ def update_membership!(membership:, invitation_code:, email_address:, consent:, attrs[:admin] = true if make_admin - membership.update_attributes!(attrs) + membership.update!(attrs) update_person_custom_fields(user) end Result::Success.new(membership) - rescue + rescue StandardError errors = "#{membership.errors.full_messages} #{user.errors.full_messages}" Result::Error.new("Updating membership failed", reason: :update_failed, errors: errors) end @@ -255,7 +255,7 @@ def ensure_membership_status(status) def update_person_custom_fields(person) if params[:person].try(:[], :custom_field_values_attributes) - person.update_attributes!(person_params) + person.update!(person_params) end end diff --git a/app/controllers/concerns/hsts.rb b/app/controllers/concerns/hsts.rb index ac1e8a5ed4..69cbad7d8a 100644 --- a/app/controllers/concerns/hsts.rb +++ b/app/controllers/concerns/hsts.rb @@ -5,7 +5,7 @@ def hsts_header(request) if APP_CONFIG.always_use_ssl.to_s == "true" && request.ssl? community = request.env[:current_marketplace] - hsts_max_age = if community && community.use_domain + hsts_max_age = if community&.use_domain community.hsts_max_age else APP_CONFIG.hsts_max_age.to_i diff --git a/app/controllers/confirmations_controller.rb b/app/controllers/confirmations_controller.rb index 0633466d54..82c0be846e 100644 --- a/app/controllers/confirmations_controller.rb +++ b/app/controllers/confirmations_controller.rb @@ -51,7 +51,7 @@ def show record_event(flash, "AccountConfirmed") - if @current_user && @current_user.has_admin_rights?(@current_community) + if @current_user&.has_admin_rights?(@current_community) record_event(flash, "admin_email_confirmed") redirect_to admin_getting_started_guide_path and return elsif @current_user # normal logged in user diff --git a/app/controllers/emails_controller.rb b/app/controllers/emails_controller.rb index 14528bfaec..1e91dcd5b0 100644 --- a/app/controllers/emails_controller.rb +++ b/app/controllers/emails_controller.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../services/email_service', __FILE__) +require File.expand_path('../services/email_service', __dir__) class EmailsController < ApplicationController diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb index a024356ac1..7734c28660 100644 --- a/app/controllers/errors_controller.rb +++ b/app/controllers/errors_controller.rb @@ -7,29 +7,29 @@ class ErrorsController < ActionController::Base def server_error error_id = airbrake_error_id # error_id = 12341234153 # uncomment this to test the last text paragraph - render "status_500", status: 500, locals: { status: 500, title: title(500), error_id: error_id } + render "status_500", status: :internal_server_error, locals: { status: 500, title: title(500), error_id: error_id } end def not_found respond_to do |format| - format.html {render "status_404", status: 404, locals: { status: 404, title: title(404) }} - format.all { render body: nil, status: 404 } + format.html {render "status_404", status: :not_found, locals: { status: 404, title: title(404) }} + format.all { render body: nil, status: :not_found } end end def not_acceptable respond_to do |format| - format.html {render "status_404", status: 406, locals: { status: 406, title: title(406) }} - format.all { render body: nil, status: 406 } + format.html {render "status_404", status: :not_acceptable, locals: { status: 406, title: title(406) }} + format.all { render body: nil, status: :not_acceptable } end end def gone - render "status_410", status: 410, locals: { status: 410, title: title(410) } + render "status_410", status: :gone, locals: { status: 410, title: title(410) } end def community_not_found - render status: 404, locals: { status: 404, title: "Marketplace not found", host: request.host } + render status: :not_found, locals: { status: 404, title: "Marketplace not found", host: request.host } end private @@ -69,11 +69,11 @@ def airbrake_error_id end def can_notify_airbrake - Airbrake && Airbrake.respond_to?(:notify) + Airbrake&.respond_to?(:notify) end def use_airbrake - APP_CONFIG && APP_CONFIG.use_airbrake + APP_CONFIG&.use_airbrake end # For some weird reason, Airbrake gem returns true, if error is not sent diff --git a/app/controllers/harmony_proxy_controller.rb b/app/controllers/harmony_proxy_controller.rb index 150b97ccb1..245123b3f3 100644 --- a/app/controllers/harmony_proxy_controller.rb +++ b/app/controllers/harmony_proxy_controller.rb @@ -107,17 +107,17 @@ def call(req, auth_context) { name: :show_bookable, login_needed: true, - authorization: AND[IsMarketplaceMember, OR[IsListingAuthor, IsAdmin]], + authorization: AND[IsMarketplaceMember, OR[IsListingAuthor, IsAdmin]] }, { name: :create_blocks, login_needed: true, - authorization: AND[IsMarketplaceMember, OR[IsListingAuthor, IsAdmin]], + authorization: AND[IsMarketplaceMember, OR[IsListingAuthor, IsAdmin]] }, { name: :delete_blocks, login_needed: true, - authorization: AND[IsMarketplaceMember, OR[IsListingAuthor, IsAdmin]], + authorization: AND[IsMarketplaceMember, OR[IsListingAuthor, IsAdmin]] } # Add here all whitelisted actions diff --git a/app/controllers/homepage_controller.rb b/app/controllers/homepage_controller.rb index 4de4c5dabc..2cd1c9a659 100644 --- a/app/controllers/homepage_controller.rb +++ b/app/controllers/homepage_controller.rb @@ -1,4 +1,3 @@ -# encoding: utf-8 class HomepageController < ApplicationController before_action :save_current_path, :except => :sign_in @@ -105,7 +104,7 @@ def index render partial: "list_item", collection: @listings, as: :listing, locals: { shape_name_map: shape_name_map } end }.on_error { - render body: nil, status: 500 + render body: nil, status: :internal_server_error } else locals = { @@ -121,7 +120,7 @@ def index current_page: current_page, current_search_path_without_page: search_path(params.except(:page)), viewport: viewport, - search_params: CustomFieldSearchParams.remove_irrelevant_search_params(params, relevant_search_fields), + search_params: CustomFieldSearchParams.remove_irrelevant_search_params(params, relevant_search_fields) } search_result.on_success { |listings| @@ -131,7 +130,7 @@ def index }.on_error { |e| flash[:error] = t("homepage.errors.search_engine_not_responding") @listings = Listing.none.paginate(:per_page => 1, :page => 1) - render status: 500, + render status: :internal_server_error, locals: locals.merge( seo_pagination_links: seo_pagination_links(params, @listings.current_page, @listings.total_pages)) } @@ -286,8 +285,8 @@ def search_modes_in_use(q, lc, main_search) # e.g. 65.123,-10 coords_valid = /^-?\d+(?:\.\d+)?,-?\d+(?:\.\d+)?$/.match(lc) { - keyword: q && (main_search == :keyword || main_search == :keyword_and_location), - location: coords_valid && (main_search == :location || main_search == :keyword_and_location), + keyword: q && [:keyword, :keyword_and_location].include?(main_search), + location: coords_valid && [:location, :keyword_and_location].include?(main_search) } end diff --git a/app/controllers/int_api/listings_controller.rb b/app/controllers/int_api/listings_controller.rb index 2610711e4c..026bec0be9 100644 --- a/app/controllers/int_api/listings_controller.rb +++ b/app/controllers/int_api/listings_controller.rb @@ -5,7 +5,7 @@ class IntApi::ListingsController < ApplicationController def update_working_time_slots listing.update_column(:per_hour_ready, true) # rubocop:disable Rails/SkipsModelValidations - listing.update_attributes(working_time_slots_params) + listing.update(working_time_slots_params) respond_with listing.working_hours_as_json, location: nil end @@ -17,12 +17,13 @@ def listing def working_time_slots_params params.require(:listing).permit( - working_time_slots_attributes: [ :id, :from, :till, :week_day, :_destroy ] + working_time_slots_attributes: [:id, :from, :till, :week_day, :_destroy] ) end def ensure_current_user_is_listing_author return true if current_user?(listing.author) || @current_user.has_admin_rights?(@current_community) + head(403) end end diff --git a/app/controllers/int_api/marketplaces_controller.rb b/app/controllers/int_api/marketplaces_controller.rb index 50402d337f..de5e50b9d7 100644 --- a/app/controllers/int_api/marketplaces_controller.rb +++ b/app/controllers/int_api/marketplaces_controller.rb @@ -9,7 +9,7 @@ class IntApi::MarketplacesController < ApplicationController # Creates a marketplace and an admin user for that marketplace def create form = NewMarketplaceForm.new(params) - return render status: 400, json: form.errors unless form.valid? + return render status: :bad_request, json: form.errors unless form.valid? # As there's no community yet, we store the global service name to thread # so that mail confirmation email is sent from global service name instead @@ -64,7 +64,7 @@ def create # TODO handle error cases with proper response - render status: 201, json: {"marketplace_url" => url, "marketplace_id" => marketplace.id} + render status: :created, json: {"marketplace_url" => url, "marketplace_id" => marketplace.id} end private diff --git a/app/controllers/landing_page_controller.rb b/app/controllers/landing_page_controller.rb index 504ca06531..30b7145900 100644 --- a/app/controllers/landing_page_controller.rb +++ b/app/controllers/landing_page_controller.rb @@ -247,7 +247,7 @@ def parse_int(int_str_or_nil) end def community(request) - @current_community ||= request.env[:current_marketplace] + @current_community ||= request.env[:current_marketplace] # rubocop:disable Naming/MemoizedInstanceVariableName end def user(request) @@ -255,7 +255,7 @@ def user(request) end def plan(request) - @current_plan ||= request.env[:current_plan] + @current_plan ||= request.env[:current_plan] # rubocop:disable Naming/MemoizedInstanceVariableName end def community_customization(request, locale) @@ -281,7 +281,7 @@ def render_landing_page(default_locale:, locale_param:, structure:, cta:) c = community(request) landing_page_locale, sitename = structure["settings"].values_at("locale", "sitename") - topbar_locale = locale_param.present? ? locale_param : default_locale + topbar_locale = locale_param.presence || default_locale initialize_i18n!(c&.id, landing_page_locale) @@ -329,7 +329,7 @@ def render_landing_page(default_locale:, locale_param:, structure:, cta:) sections: denormalizer.to_tree(structure, root: "composition"), community_context: community_context(request, landing_page_locale), feature_flags: FeatureFlagHelper.feature_flags, - asset_host: APP_CONFIG.asset_host, + asset_host: APP_CONFIG.asset_host } end diff --git a/app/controllers/listing_images_controller.rb b/app/controllers/listing_images_controller.rb index 7514d66076..dbaab0e298 100644 --- a/app/controllers/listing_images_controller.rb +++ b/app/controllers/listing_images_controller.rb @@ -10,18 +10,18 @@ def destroy image = ListingImage.find_by_id(params[:id]) if image.nil? - render body: nil, status: 404 + render body: nil, status: :not_found elsif !authorized_to_destroy?(image) - render body: nil, status: 401 + render body: nil, status: :unauthorized else image_destroyed = image.destroy if image_destroyed - render body: nil, status: 204 + render body: nil, status: :no_content else error_messages = image.errors.full_messages - render json: {errors: listing_image.errors.full_messages}, status: 500 + render json: {errors: listing_image.errors.full_messages}, status: :internal_server_error logger.error("Failed to destroy listing image", :image_destroy_failed, @@ -39,7 +39,7 @@ def add_from_url if !url.present? logger.info("No image URL provided", :no_image_url_provided, params) - render json: {:errors => "No image URL provided"}, status: 400, content_type: 'text/plain' + render json: {:errors => "No image URL provided"}, status: :bad_request, content_type: 'text/plain' end add_image(params[:listing_id], {}, url) @@ -57,9 +57,9 @@ def image_status listing_image = ListingImage.find_by_id(params[:id]) if !listing_image - render body: nil, status: 404 + render body: nil, status: :not_found else - render json: ListingImageJsAdapter.new(listing_image).to_json, status: 200 + render json: ListingImageJsAdapter.new(listing_image).to_json, status: :ok end end @@ -102,10 +102,10 @@ def new_image(params, url) logger.info("Listing image is already downloaded", :image_already_downloaded, listing_image_id: listing_image.id, params: params.except(:image)) end - render json: ListingImageJsAdapter.new(listing_image).to_json, status: 202, content_type: 'text/plain' # Browsers without XHR fileupload support do not support other dataTypes than text + render json: ListingImageJsAdapter.new(listing_image).to_json, status: :accepted, content_type: 'text/plain' # Browsers without XHR fileupload support do not support other dataTypes than text else logger.error("Saving listing image failed", :saving_listing_image_failed, params: params, errors: listing_image.errors.messages) - render json: {:errors => listing_image.errors.full_messages}, status: 400, content_type: 'text/plain' + render json: {:errors => listing_image.errors.full_messages}, status: :bad_request, content_type: 'text/plain' end end diff --git a/app/controllers/listings_controller.rb b/app/controllers/listings_controller.rb index 1879de5e98..1b93425af4 100644 --- a/app/controllers/listings_controller.rb +++ b/app/controllers/listings_controller.rb @@ -4,28 +4,28 @@ class ListingDeleted < StandardError; end # Skip auth token check as current jQuery doesn't provide it automatically skip_before_action :verify_authenticity_token, :only => [:close, :update, :follow, :unfollow] - before_action :only => [ :edit, :edit_form_content, :update, :close, :follow, :unfollow ] do |controller| + before_action :only => [:edit, :edit_form_content, :update, :close, :follow, :unfollow] do |controller| controller.ensure_logged_in t("layouts.notifications.you_must_log_in_to_view_this_content") end - before_action :only => [ :new, :new_form_content, :create ] do |controller| + before_action :only => [:new, :new_form_content, :create] do |controller| controller.ensure_logged_in t("layouts.notifications.you_must_log_in_to_create_new_listing", :sign_up_link => view_context.link_to(t("layouts.notifications.create_one_here"), sign_up_path)).html_safe end before_action :save_current_path, :only => :show - before_action :ensure_authorized_to_view, :only => [ :show, :follow, :unfollow ] + before_action :ensure_authorized_to_view, :only => [:show, :follow, :unfollow] - before_action :only => [ :close ] do |controller| + before_action :only => [:close] do |controller| controller.ensure_current_user_is_listing_author t("layouts.notifications.only_listing_author_can_close_a_listing") end - before_action :only => [ :edit, :edit_form_content, :update ] do |controller| + before_action :only => [:edit, :edit_form_content, :update] do |controller| controller.ensure_current_user_is_listing_author t("layouts.notifications.only_listing_author_can_edit_a_listing") end - before_action :ensure_is_admin, :only => [ :move_to_top, :show_in_updates_email ] + before_action :ensure_is_admin, :only => [:move_to_top, :show_in_updates_email] - before_action :is_authorized_to_post, :only => [ :new, :create ] + before_action :is_authorized_to_post, :only => [:new, :create] def index @selected_tribe_navi_tab = "home" @@ -158,9 +158,9 @@ def create if shape.booking? anchor = shape.booking_per_hour? ? 'manage-working-hours' : 'manage-availability' @listing.working_hours_new_set(force_create: true) if shape.booking_per_hour? - redirect_to listing_path(@listing, anchor: anchor, listing_just_created: true), status: 303 + redirect_to listing_path(@listing, anchor: anchor, listing_just_created: true), status: :see_other else - redirect_to @listing, status: 303 + redirect_to @listing, status: :see_other end else logger.error("Errors in creating listing: #{@listing.errors.full_messages.inspect}") @@ -225,7 +225,7 @@ def update end if @listing.location location_params = ListingFormViewUtils.permit_location_params(params) - @listing.location.update_attributes(location_params) + @listing.location.update(location_params) end flash[:notice] = update_flash(old_availability: old_availability, new_availability: shape[:availability]) Delayed::Job.enqueue(ListingUpdatedJob.new(@listing.id, @current_community.id)) @@ -259,7 +259,7 @@ def move_to_top def show_in_updates_email @listing = @current_community.listings.find(params[:id]) @listing.update_attribute(:updates_email_at, Time.now) - render :body => nil, :status => 200 + render :body => nil, :status => :ok end def follow @@ -277,6 +277,7 @@ def verification_required def ensure_current_user_is_listing_author(error_message) @listing = Listing.find(params[:id]) return if current_user?(@listing.author) || @current_user.has_admin_rights?(@current_community) + flash[:error] = error_message redirect_to @listing and return end @@ -335,7 +336,7 @@ def form_content @listing.init_origin_location(@listing_presenter.new_listing_author.location) end - @listing.category = @current_community.categories.find(params[:subcategory].blank? ? params[:category] : params[:subcategory]) + @listing.category = @current_community.categories.find(params[:subcategory].presence || params[:category]) @custom_field_questions = @listing.category.custom_fields @numeric_field_ids = numeric_field_ids(@custom_field_questions) diff --git a/app/controllers/mercury_update_controller.rb b/app/controllers/mercury_update_controller.rb index fb56c00973..29d10490ba 100644 --- a/app/controllers/mercury_update_controller.rb +++ b/app/controllers/mercury_update_controller.rb @@ -16,7 +16,7 @@ def update end if @community_customization - if !@community_customization.update_attributes(param_hash) + if !@community_customization.update(param_hash) flash[:error] = I18n.t("mercury.content_too_long") end else diff --git a/app/controllers/omniauth_controller.rb b/app/controllers/omniauth_controller.rb index 1b636fa9a4..a105c21aca 100644 --- a/app/controllers/omniauth_controller.rb +++ b/app/controllers/omniauth_controller.rb @@ -22,7 +22,7 @@ def failure end def passthru - render status: 404, plain: "Not found. Authentication passthru." + render status: :not_found, plain: "Not found. Authentication passthru." end private diff --git a/app/controllers/paypal_accounts_controller.rb b/app/controllers/paypal_accounts_controller.rb index 22541cc949..ff0ac0d4e1 100644 --- a/app/controllers/paypal_accounts_controller.rb +++ b/app/controllers/paypal_accounts_controller.rb @@ -53,8 +53,8 @@ def ask_billing_agreement body: PaypalService::API::DataTypes.create_create_billing_agreement_request( { description: t("paypal_accounts.new.billing_agreement_description"), - success_url: billing_agreement_success_person_paypal_account_url, - cancel_url: billing_agreement_cancel_person_paypal_account_url + success_url: billing_agreement_success_person_paypal_account_url, + cancel_url: billing_agreement_cancel_person_paypal_account_url } )) diff --git a/app/controllers/paypal_service/checkout_orders_controller.rb b/app/controllers/paypal_service/checkout_orders_controller.rb index 37b2dc43bf..ba2f3cbf69 100644 --- a/app/controllers/paypal_service/checkout_orders_controller.rb +++ b/app/controllers/paypal_service/checkout_orders_controller.rb @@ -3,7 +3,7 @@ class PaypalService::CheckoutOrdersController < ApplicationController before_action do unless PaypalHelper.community_ready_for_payments?(@current_community.id) - render :body => nil, :status => 400 + render :body => nil, :status => :bad_request end end diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 04572991d9..6c06a8e7d7 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -73,7 +73,7 @@ def create ActiveRecord::Base.transaction do @person, email = new_person(params, @current_community) end - rescue => e + rescue StandardError => e flash[:error] = t("people.new.invalid_username_or_email") redirect_to error_redirect_path and return end @@ -156,7 +156,7 @@ def update target_user.emails.build(address: new_email_address, community_id: @current_community.id) } - if target_user.update_attributes(person_params.except(:email_attributes)) + if target_user.update(person_params.except(:email_attributes)) if params[:person][:password] #if password changed Devise needs a new sign in. bypass_sign_in(target_user) @@ -252,7 +252,7 @@ def show_closed? # Create a new person by params and current community def new_person(initial_params, current_community) initial_params[:person][:locale] = params[:locale] || APP_CONFIG.default_locale - initial_params[:person][:test_group_number] = 1 + rand(4) + initial_params[:person][:test_group_number] = rand(1..4) initial_params[:person][:community_id] = current_community.id params = person_create_params(initial_params) diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb index e1018adf6c..be8ca2b1a2 100644 --- a/app/controllers/plans_controller.rb +++ b/app/controllers/plans_controller.rb @@ -77,21 +77,21 @@ def create response = NewPlansResponse.build(plans: created_plans.map { |plan_entity| from_entity(plan_entity) }) - render json: response, status: 200 + render json: response, status: :ok }.on_error { |error_msg, data| case data when JSON::ParserError logger.error("Error while parsing JSON: #{data.message}") - render json: {error: :json_parser_error}, status: 400 + render json: {error: :json_parser_error}, status: :bad_request when :verification_error, :expired_signature, :invalid_sub_error, :token_missing logger.error("Unauthorized", nil, error: data, token: params[:token]) - render json: {error: :unauthorized}, status: 401 + render json: {error: :unauthorized}, status: :unauthorized else logger.error("Unknown error") - render json: {error: :unknown_error}, status: 500 + render json: {error: :unknown_error}, status: :internal_server_error end } end @@ -128,10 +128,10 @@ def get_trials :invalid_sub_error, :token_missing logger.error("Unauthorized", nil, error: data, token: params[:token]) - render json: {error: :unauthorized}, status: 401 + render json: {error: :unauthorized}, status: :unauthorized else logger.error("Unknown error") - render json: {error: :unknown_error}, status: 500 + render json: {error: :unknown_error}, status: :internal_server_error end } end diff --git a/app/controllers/preauthorize_transactions_controller.rb b/app/controllers/preauthorize_transactions_controller.rb index b665f89a52..8d2b144a38 100644 --- a/app/controllers/preauthorize_transactions_controller.rb +++ b/app/controllers/preauthorize_transactions_controller.rb @@ -1,4 +1,3 @@ -# coding: utf-8 class PreauthorizeTransactionsController < ApplicationController before_action do |controller| @@ -262,11 +261,11 @@ def initiation_success(tx_params) render "listing_conversations/initiate", locals: { - start_on: tx_params[:start_on], - end_on: tx_params[:end_on], + start_on: tx_params[:start_on], + end_on: tx_params[:end_on], start_time: tx_params[:start_time], - end_time: tx_params[:end_time], - per_hour: tx_params[:per_hour], + end_time: tx_params[:end_time], + per_hour: tx_params[:per_hour], listing: listing, delivery_method: tx_params[:delivery], quantity: tx_params[:quantity], @@ -326,11 +325,11 @@ def initiated_success(tx_params) delivery_method: tx_params[:delivery], shipping_price: order.shipping_total, booking_fields: { - start_on: tx_params[:start_on], - end_on: tx_params[:end_on], + start_on: tx_params[:start_on], + end_on: tx_params[:end_on], start_time: tx_params[:start_time], - end_time: tx_params[:end_time], - per_hour: tx_params[:per_hour] + end_time: tx_params[:end_time], + per_hour: tx_params[:per_hour] }) handle_tx_response(tx_response, params[:payment_type].to_sym) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 44e8efb312..d5a877a586 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -2,10 +2,10 @@ class SessionsController < ApplicationController - skip_before_action :cannot_access_if_banned, :only => [ :destroy, :confirmation_pending ] - skip_before_action :cannot_access_without_confirmation, :only => [ :destroy, :confirmation_pending ] - skip_before_action :ensure_consent_given, only: [ :destroy, :confirmation_pending ] - skip_before_action :ensure_user_belongs_to_community, :only => [ :destroy, :confirmation_pending ] + skip_before_action :cannot_access_if_banned, :only => [:destroy, :confirmation_pending] + skip_before_action :cannot_access_without_confirmation, :only => [:destroy, :confirmation_pending] + skip_before_action :ensure_consent_given, only: [:destroy, :confirmation_pending] + skip_before_action :ensure_user_belongs_to_community, :only => [:destroy, :confirmation_pending] # For security purposes, Devise just authenticates an user # from the params hash if we explicitly allow it to. That's @@ -100,7 +100,7 @@ def request_new_password end def passthru - render status: 404, plain: "Not found. Authentication passthru." + render status: :not_found, plain: "Not found. Authentication passthru." end private diff --git a/app/controllers/testimonials_controller.rb b/app/controllers/testimonials_controller.rb index 7c7a6c1623..9c9c057a62 100644 --- a/app/controllers/testimonials_controller.rb +++ b/app/controllers/testimonials_controller.rb @@ -53,9 +53,9 @@ def skip is_author = @transaction.author == @current_user if is_author - @transaction.update_attributes(author_skipped_feedback: true) + @transaction.update(author_skipped_feedback: true) else - @transaction.update_attributes(starter_skipped_feedback: true) + @transaction.update(starter_skipped_feedback: true) end respond_to do |format| diff --git a/app/controllers/topbar_api_controller.rb b/app/controllers/topbar_api_controller.rb index 2fcfa14825..aaac85e8ad 100644 --- a/app/controllers/topbar_api_controller.rb +++ b/app/controllers/topbar_api_controller.rb @@ -1,4 +1,3 @@ -# coding: utf-8 class TopbarApiController < ApplicationController skip_before_action :cannot_access_without_confirmation, :ensure_consent_given diff --git a/app/controllers/transactions_controller.rb b/app/controllers/transactions_controller.rb index a73452d44b..0bfaccaec3 100644 --- a/app/controllers/transactions_controller.rb +++ b/app/controllers/transactions_controller.rb @@ -25,13 +25,13 @@ class TransactionsController < ApplicationController [:listing_id, :fixnum, :to_integer, :mandatory], [:message, :string], [:quantity, :fixnum, :to_integer, default: 1], - [:start_on, transform_with: ->(v) { Maybe(v).map { |d| TransactionViewUtils.parse_booking_date(d) }.or_else(nil) } ], - [:end_on, transform_with: ->(v) { Maybe(v).map { |d| TransactionViewUtils.parse_booking_date(d) }.or_else(nil) } ] + [:start_on, transform_with: ->(v) { Maybe(v).map { |d| TransactionViewUtils.parse_booking_date(d) }.or_else(nil) }], + [:end_on, transform_with: ->(v) { Maybe(v).map { |d| TransactionViewUtils.parse_booking_date(d) }.or_else(nil) }] ) def new Result.all( - ->() { + -> { fetch_data(params[:listing_id]) }, ->((listing_id, listing_model)) { @@ -60,7 +60,7 @@ def new def create Result.all( - ->() { + -> { TransactionForm.validate(params) }, ->(form) { @@ -322,7 +322,7 @@ def after_create_actions!(process:, transaction:, community_id:) # def fetch_data(listing_id) Result.all( - ->() { + -> { if listing_id.nil? Result::Error.new("No listing ID provided") else @@ -361,7 +361,7 @@ def price_break_down_locals(tx, conversation) localized_unit_type = tx.unit_type.present? ? ListingViewUtils.translate_unit(tx.unit_type, tx.unit_tr_key) : nil localized_selector_label = tx.unit_type.present? ? ListingViewUtils.translate_quantity(tx.unit_type, tx.unit_selector_tr_key) : nil booking = !!tx.booking - booking_per_hour = tx.booking && tx.booking.per_hour + booking_per_hour = tx.booking&.per_hour quantity = tx.listing_quantity show_subtotal = !!tx.booking || quantity.present? && quantity > 1 || tx.shipping_price.present? total_label = (tx.payment_process != :preauthorize) ? t("transactions.price") : t("transactions.total") @@ -395,7 +395,7 @@ def render_free(listing_model:, author_model:, community:, params:) listing = { id: listing_model.id, title: listing_model.title, - action_button_label: t(listing_model.action_button_tr_key), + action_button_label: t(listing_model.action_button_tr_key) } author = { display_name: PersonViewUtils.person_display_name(author_model, community), diff --git a/app/helpers/analytics_helper.rb b/app/helpers/analytics_helper.rb index 1239a2b83d..7b684f7def 100644 --- a/app/helpers/analytics_helper.rb +++ b/app/helpers/analytics_helper.rb @@ -2,26 +2,26 @@ module AnalyticsHelper def analytics_data user_is_admin = @current_user.try(:is_marketplace_admin?, @current_community) { - community_ident: @current_community.try(:ident), - community_uuid: @current_community.try(:uuid_object).to_s, - community_id: @current_community.try(:id), + community_ident: @current_community.try(:ident), + community_uuid: @current_community.try(:uuid_object).to_s, + community_id: @current_community.try(:id), community_admin_email: (user_is_admin ? IntercomHelper.email(@current_user) : nil), - user_id: @current_user.try(:id), - user_uuid: @current_user.try(:uuid_object).to_s, - user_is_admin: user_is_admin, - user_email: @current_user && IntercomHelper.email(@current_user) || 'null', - user_name: @current_user && @current_community && PersonViewUtils.person_display_name(@current_user, @current_community) || 'null', - user_hash: @current_user && IntercomHelper.user_hash(@current_user.uuid_object.to_s) || 'null', + user_id: @current_user.try(:id), + user_uuid: @current_user.try(:uuid_object).to_s, + user_is_admin: user_is_admin, + user_email: @current_user && IntercomHelper.email(@current_user) || 'null', + user_name: @current_user && @current_community && PersonViewUtils.person_display_name(@current_user, @current_community) || 'null', + user_hash: @current_user && IntercomHelper.user_hash(@current_user.uuid_object.to_s) || 'null', - feature_flags: FeatureFlagHelper.feature_flags, + feature_flags: FeatureFlagHelper.feature_flags, - plan_status: @current_plan && @current_plan[:status] || 'null', - plan_member_limit: @current_plan && @current_plan[:member_limit] || 'null', - plan_created_at: @current_plan && @current_plan[:created_at].to_time.to_i || 'null', - plan_updated_at: @current_plan && @current_plan[:updated_at].to_time.to_i || 'null', - plan_expires_at: @current_plan && @current_plan[:expires_at]&.to_time&.to_i, - plan_features: @current_plan && @current_plan[:features].select { |_, v| v }.keys.join(", ") || 'null', + plan_status: @current_plan && @current_plan[:status] || 'null', + plan_member_limit: @current_plan && @current_plan[:member_limit] || 'null', + plan_created_at: @current_plan && @current_plan[:created_at].to_time.to_i || 'null', + plan_updated_at: @current_plan && @current_plan[:updated_at].to_time.to_i || 'null', + plan_expires_at: @current_plan && @current_plan[:expires_at]&.to_time&.to_i, # rubocop:disable Rails/Date + plan_features: @current_plan && @current_plan[:features].select { |_, v| v }.keys.join(", ") || 'null', identity_information: @current_user ? IntercomHelper.identity_information(@current_user) : 'null' } diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a36b05a403..f4935ad8dd 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,5 +1,3 @@ -# encoding: utf-8 - # rubocop:disable Metrics/ModuleLength module ApplicationHelper @@ -46,7 +44,7 @@ def translate_time_to(unit, count) # used to escape strings to URL friendly format def self.escape_for_url(str) - URI.escape(str, Regexp.new("[^-_!~*()a-zA-Z\\d]")) + CGI.escape(str, Regexp.new("[^-_!~*()a-zA-Z\\d]")) end # Changes line breaks to
-tags and transforms URLs to links @@ -116,9 +114,9 @@ def pageless(total_pages, target_id, url=nil, loader_message='Loading more resul opts = { :currentPage => current_page, :totalPages => total_pages, - :url => url, - :loaderMsg => loader_message, - :targetDiv => target_id # extra parameter for jquery.pageless.js patch + :url => url, + :loaderMsg => loader_message, + :targetDiv => target_id # extra parameter for jquery.pageless.js patch } content_for :extra_javascript do @@ -146,11 +144,11 @@ def available_locales def self.send_error_notification(message, error_class="Special Error", parameters={}) if APP_CONFIG.use_airbrake Airbrake.notify( - :error_class => error_class, - :error_message => message, - :backtrace => $@, + :error_class => error_class, + :error_message => message, + :backtrace => $@, :environment_name => ENV['RAILS_ENV'], - :parameters => parameters) + :parameters => parameters) end Rails.logger.error "#{error_class}: #{message}" end @@ -161,6 +159,7 @@ def self.send_error_notification(message, error_class="Special Error", parameter def self.pick_referer_domain_part_from_request(request) return request.headers["HTTP_ORIGIN"] if request.headers["HTTP_ORIGIN"].present? return request.headers["HTTP_REFERER"][/(^[^\/]*(\/\/)?[^\/]+)/,1] if request.headers["HTTP_REFERER"] + return "" end @@ -343,7 +342,7 @@ def admin_links_for(community) :text => t("admin.left_hand_navigation.subscription"), :icon_class => icon_class("credit_card"), :path => admin_plan_path, - :name => "plan", + :name => "plan" } end @@ -352,7 +351,7 @@ def admin_links_for(community) :text => t("admin.left_hand_navigation.preview"), :icon_class => icon_class("eye"), :path => homepage_without_locale_path(big_cover_photo: true, locale: nil), - :name => "preview", + :name => "preview" } links += [ @@ -461,7 +460,7 @@ def admin_links_for(community) :text => t("admin.landing_page.landing_page"), :icon_class => icon_class("home"), :path => admin_landing_page_path, - :name => "landing_page", + :name => "landing_page" } end @@ -799,35 +798,35 @@ def regex_definition_to_js(string) SOCIAL_LINKS = { facebook: { name: "Facebook", - placeholder: "https://www.facebook.com/CHANGEME", + placeholder: "https://www.facebook.com/CHANGEME" }, twitter: { name: "Twitter", - placeholder: "https://www.twitter.com/CHANGEME", + placeholder: "https://www.twitter.com/CHANGEME" }, instagram: { name: "Instagram", - placeholder: "https://www.instagram.com/CHANGEME", + placeholder: "https://www.instagram.com/CHANGEME" }, youtube: { name: "YouTube", - placeholder: "https://www.youtube.com/channel/CHANGEME", + placeholder: "https://www.youtube.com/channel/CHANGEME" }, googleplus: { name: "Google+", - placeholder: "https://plus.google.com/CHANGEME", + placeholder: "https://plus.google.com/CHANGEME" }, linkedin: { name: "LinkedIn", - placeholder: "https://www.linkedin.com/company/CHANGEME", + placeholder: "https://www.linkedin.com/company/CHANGEME" }, pinterest: { name: "Pinterest", - placeholder: "https://www.pinterest.com/CHANGEME", + placeholder: "https://www.pinterest.com/CHANGEME" }, soundcloud: { name: "SoundCloud", - placeholder: "https://soundcloud.com/CHANGEME", + placeholder: "https://soundcloud.com/CHANGEME" } }.freeze diff --git a/app/helpers/cache_helper.rb b/app/helpers/cache_helper.rb index 69b2a1ac38..e16242b51d 100644 --- a/app/helpers/cache_helper.rb +++ b/app/helpers/cache_helper.rb @@ -1,5 +1,3 @@ -# encoding: utf-8 - # This is included to ApplicationController # Contains helper methods for cache handling module CacheHelper diff --git a/app/helpers/country_i18n_helper.rb b/app/helpers/country_i18n_helper.rb index f86b4168f1..d561558db7 100644 --- a/app/helpers/country_i18n_helper.rb +++ b/app/helpers/country_i18n_helper.rb @@ -4,6 +4,7 @@ module CountryI18nHelper def translate_country(country_code) country = ISO3166::Country[country_code] return country_code unless country + locale = I18n.locale.to_s.downcase [locale, locale.split('-').first].each do |variant| name = country.translations[variant] diff --git a/app/helpers/feature_flag_helper.rb b/app/helpers/feature_flag_helper.rb index 7f40bb82c7..82a92280cb 100644 --- a/app/helpers/feature_flag_helper.rb +++ b/app/helpers/feature_flag_helper.rb @@ -27,6 +27,7 @@ def feature_flags unless RequestStore.store[:feature_flags] raise FeatureFlagHelperNotInitialized.new("Feature flags helper not initialized! Call 'init' first.") end + RequestStore.store[:feature_flags] end diff --git a/app/helpers/listings_helper.rb b/app/helpers/listings_helper.rb index 01501b0415..87d3aac0ff 100644 --- a/app/helpers/listings_helper.rb +++ b/app/helpers/listings_helper.rb @@ -35,6 +35,7 @@ def format_listing_title(shape_tr_key, listing_title) def localized_category_label(category) return nil if category.nil? + return category.display_name(I18n.locale).capitalize end @@ -48,6 +49,7 @@ def localized_category_from_id(category_id) def localized_listing_type_label(listing_type_string) return nil if listing_type_string.nil? + return t("listings.show.#{listing_type_string}", :default => listing_type_string.capitalize) end diff --git a/app/helpers/payments_helper.rb b/app/helpers/payments_helper.rb index 0bc5cb96ea..f0146dc54a 100644 --- a/app/helpers/payments_helper.rb +++ b/app/helpers/payments_helper.rb @@ -46,10 +46,10 @@ module PaymentsHelper separator: "-" }, IE: { - account_number: {title: 'IBAN', format: 'IE29AIBK93115212345678', regexp: 'IE[0-9]{2}[A-Z0-9]{4}[0-9]{14}', test_regexp: 'IE'+TEST_IBAN }, + account_number: {title: 'IBAN', format: 'IE29AIBK93115212345678', regexp: 'IE[0-9]{2}[A-Z0-9]{4}[0-9]{14}', test_regexp: 'IE'+TEST_IBAN } }, IT: { - account_number: {title: 'IBAN', format: 'IT60X0542811101000000123456', regexp: 'IT[0-9]{2}[A-Z]{1}[0-9]{5}[0-9]{5}[A-Z0-9]{12}', test_regexp: 'IT'+TEST_IBAN }, + account_number: {title: 'IBAN', format: 'IT60X0542811101000000123456', regexp: 'IT[0-9]{2}[A-Z]{1}[0-9]{5}[0-9]{5}[A-Z0-9]{12}', test_regexp: 'IT'+TEST_IBAN } }, JP: { account_number: {format: '1234567', regexp: '[0-9]{6,8}', test_regexp: '[0-9]{6,8}' }, @@ -58,7 +58,7 @@ module PaymentsHelper separator: "" }, LU: { - account_number: {title: 'IBAN', format: 'LU280019400644750000', regexp: 'LU[0-9]{2}[0-9]{3}[A-Z0-9]{13}', test_regexp: 'LU'+TEST_IBAN }, + account_number: {title: 'IBAN', format: 'LU280019400644750000', regexp: 'LU[0-9]{2}[0-9]{3}[A-Z0-9]{13}', test_regexp: 'LU'+TEST_IBAN } }, MX: { account_number: {title: 'CLABE', format: '123456789012345678', regexp: '[0-9]{18}', test_regexp: '[0-9]{18}' } @@ -67,13 +67,13 @@ module PaymentsHelper account_number: {title: 'IBAN', format: 'NL39RABO0300065264', regexp: 'NL[0-9]{2}[A-Z]{4}[0-9]{10}', test_regexp: 'NL'+TEST_IBAN } }, NZ: { - account_number: {format: '11-0000-0000000-010', regexp: '[0-9]{2}\-[0-9]{4}\-[0-9]{7}\-[0-9]{2,3}', test_regexp: '[0-9]{2}\-[0-9]{4}\-[0-9]{7}\-[0-9]{2,3}' }, + account_number: {format: '11-0000-0000000-010', regexp: '[0-9]{2}\-[0-9]{4}\-[0-9]{7}\-[0-9]{2,3}', test_regexp: '[0-9]{2}\-[0-9]{4}\-[0-9]{7}\-[0-9]{2,3}' } }, NO: { - account_number: {title: 'IBAN', format: 'NO9386011117947', regexp: 'NO[0-9]{2}[0-9]{11}', test_regexp: 'NO'+TEST_IBAN }, + account_number: {title: 'IBAN', format: 'NO9386011117947', regexp: 'NO[0-9]{2}[0-9]{11}', test_regexp: 'NO'+TEST_IBAN } }, PT: { - account_number: {title: 'IBAN', format: 'PT50123443211234567890172', regexp: 'PT[0-9]{2}[0-9]{4}[0-9]{4}[0-9]{11}[0-9]{2}', test_regexp: 'PT'+TEST_IBAN }, + account_number: {title: 'IBAN', format: 'PT50123443211234567890172', regexp: 'PT[0-9]{2}[0-9]{4}[0-9]{4}[0-9]{11}[0-9]{2}', test_regexp: 'PT'+TEST_IBAN } }, SG: { account_number: {format: '123456789012', regexp: '[0-9]{6-12}', test_regexp: '[0-9]{6-12}' }, @@ -112,7 +112,7 @@ def stripe_default_data2 { stripe_test_mode: !!StripeService::API::Api.wrapper.test_mode?(@current_community.id), api_publishable_key: payment_settings.try(:api_publishable_key), - bank_rules: BANK_RULES, + bank_rules: BANK_RULES } end diff --git a/app/helpers/social_network_helper.rb b/app/helpers/social_network_helper.rb index 445a99202b..0f0c95c54e 100644 --- a/app/helpers/social_network_helper.rb +++ b/app/helpers/social_network_helper.rb @@ -8,11 +8,11 @@ def facebook_connect_in_use? end def google_connect_in_use? - @current_community && @current_community.google_connect_enabled? && @current_community.google_connect_id + @current_community&.google_connect_enabled? && @current_community&.google_connect_id end def linkedin_connect_in_use? - @current_community && @current_community.linkedin_connect_enabled? && @current_community.linkedin_connect_id + @current_community&.linkedin_connect_enabled? && @current_community&.linkedin_connect_id end end diff --git a/app/helpers/transaction_helper.rb b/app/helpers/transaction_helper.rb index ed8a17e977..c6f952ac44 100644 --- a/app/helpers/transaction_helper.rb +++ b/app/helpers/transaction_helper.rb @@ -210,23 +210,26 @@ def conversation_icon_and_status(status, is_author, other_party_name, waiting_fe # ] # } # } + # rubocop:disable Metrics/MethodLength def get_conversation_statuses(conversation, is_author) statuses = if conversation.listing && !conversation.status.eql?("free") status_hash = { - paid: ->() { { + paid: -> { { both: [ status_info(t("conversations.status.request_paid"), icon_classes: icon_for("paid")), delivery_status(conversation), paid_status(conversation) ] - } }, - preauthorized: ->() { { + } + }, + preauthorized: -> { { both: [ status_info(t("conversations.status.request_preauthorized"), icon_classes: icon_for("preauthorized")), preauthorized_status(conversation) ] - } }, - pending_ext: ->() { + } + }, + pending_ext: -> { ## This is so wrong place to call services... #TODO Deprecated call, update to use PaypalService::API:Api.payments.get_payment paypal_payment = PaypalService::Store::PaypalPayment.for_transaction(conversation.id) @@ -266,31 +269,35 @@ def get_conversation_statuses(conversation, is_author) } end }, - confirmed: ->() { { + confirmed: -> { { both: [ status_info(t("conversations.status.request_confirmed"), icon_classes: icon_for("confirmed")), feedback_status(conversation) ] - } }, - canceled: ->() { { + } + }, + canceled: -> { { both: [ status_info(t("conversations.status.request_canceled"), icon_classes: icon_for("canceled")), feedback_status(conversation) ] - } }, - rejected: ->() { { + } + }, + rejected: -> { { both: [ status_info(t("conversations.status.request_rejected"), icon_classes: icon_for(conversation.status)) ] - } }, - errored: ->() { { + } + }, + errored: -> { { author: [ status_info(t("conversations.status.payment_errored_author", starter_name: conversation.starter.name(conversation.community)), icon_classes: icon_for("errored")) ], starter: [ status_info(t("conversations.status.payment_errored_starter"), icon_classes: icon_for("errored")) ] - } } + } + } } Maybe(status_hash)[conversation.status.to_sym] @@ -303,6 +310,7 @@ def get_conversation_statuses(conversation, is_author) statuses.flatten.compact end + # rubocop:enable Metrics/MethodLength private diff --git a/app/indices/listing_index.rb b/app/indices/listing_index.rb index b52f832993..6b921f1c58 100644 --- a/app/indices/listing_index.rb +++ b/app/indices/listing_index.rb @@ -30,8 +30,8 @@ set_property :enable_star => true set_property :field_weights => { - :title => 10, - :category => 8, + :title => 10, + :category => 8, :description => 3 } diff --git a/app/jobs/export_transactions_job.rb b/app/jobs/export_transactions_job.rb index 9f3eb4ab0e..cc83f81e1e 100644 --- a/app/jobs/export_transactions_job.rb +++ b/app/jobs/export_transactions_job.rb @@ -13,7 +13,7 @@ def before(job) def perform community = Community.find(community_id) export_task = ExportTaskResult.find(export_task_id) - export_task.update_attributes(status: 'started') + export_task.update(status: 'started') conversations = Transaction.for_community_sorted_by_activity(community.id, 'desc', nil, nil, true) csv_rows = [] @@ -23,7 +23,7 @@ def perform filename = "#{marketplace_name}-transactions-#{Time.zone.today}-#{export_task.token}.csv" export_task.original_filename = filename export_task.original_extname = File.extname(filename).delete('.') - export_task.update_attributes(status: 'finished', file: FakeFileIO.new(filename, csv_content)) + export_task.update(status: 'finished', file: FakeFileIO.new(filename, csv_content)) end class FakeFileIO < StringIO diff --git a/app/jobs/handle_paypal_ipn_message_job.rb b/app/jobs/handle_paypal_ipn_message_job.rb index 9731b9e3f4..092a45c80e 100644 --- a/app/jobs/handle_paypal_ipn_message_job.rb +++ b/app/jobs/handle_paypal_ipn_message_job.rb @@ -22,7 +22,7 @@ def perform raw_msg.update_attribute(:status, :success) end - rescue => e + rescue StandardError => e raw_msg.update_attribute(:status, :errored) raise e #raise the exception ahead for airbrake reporting end diff --git a/app/jobs/notify_followers_job.rb b/app/jobs/notify_followers_job.rb index 72f23cdc55..939d86814d 100644 --- a/app/jobs/notify_followers_job.rb +++ b/app/jobs/notify_followers_job.rb @@ -14,6 +14,7 @@ def before(job) def perform return if !listing || listing.closed? || !author + followers_to_notify.map do |follower| MailCarrier.deliver_now(PersonMailer.new_listing_by_followed_person(listing, follower, community)) end diff --git a/app/jobs/stripe_payout_job.rb b/app/jobs/stripe_payout_job.rb index b7a3261826..edfde67e66 100644 --- a/app/jobs/stripe_payout_job.rb +++ b/app/jobs/stripe_payout_job.rb @@ -13,7 +13,7 @@ def before(job) def perform tx = Transaction.find(transaction_id) StripeService::API::Api.payments.payout(tx) - rescue => exception + rescue StandardError => exception params_to_airbrake = StripeService::Report.new(tx: tx, exception: exception).create_payout_failed error(self, exception, {stripe: params_to_airbrake}) raise diff --git a/app/jobs/transaction_automatically_confirmed_job.rb b/app/jobs/transaction_automatically_confirmed_job.rb index 7b4b434bb5..391e81c48c 100644 --- a/app/jobs/transaction_automatically_confirmed_job.rb +++ b/app/jobs/transaction_automatically_confirmed_job.rb @@ -15,7 +15,7 @@ def perform transaction = Transaction.find(conversation_id) community = Community.find(community_id) MailCarrier.deliver_now(PersonMailer.transaction_automatically_confirmed(transaction, community)) - rescue => ex + rescue StandardError => ex puts ex.message puts ex.backtrace.join("\n") end diff --git a/app/jobs/transaction_canceled_job.rb b/app/jobs/transaction_canceled_job.rb index 56fa625325..1af27f5d68 100644 --- a/app/jobs/transaction_canceled_job.rb +++ b/app/jobs/transaction_canceled_job.rb @@ -15,7 +15,7 @@ def perform transaction = Transaction.find(conversation_id) community = Community.find(community_id) MailCarrier.deliver_now(PersonMailer.transaction_confirmed(transaction, community)) - rescue => ex + rescue StandardError => ex puts ex.message puts ex.backtrace.join("\n") end diff --git a/app/mailers/community_mailer.rb b/app/mailers/community_mailer.rb index 1392852804..567136cbf7 100644 --- a/app/mailers/community_mailer.rb +++ b/app/mailers/community_mailer.rb @@ -1,6 +1,8 @@ +# rubocop:disable Style/MixinUsage include ApplicationHelper include ListingsHelper include TruncateHtmlHelper +# rubocop:enable Style/MixinUsage class CommunityMailer < ActionMailer::Base @@ -29,7 +31,7 @@ def self.deliver_community_updates listings: listings_to_send, unsubscribe_token: token )) - rescue => e + rescue StandardError => e # Catch the exception and continue sending emails puts "Error sending mail to #{person.confirmed_notification_emails} community updates: #{e.message}" ApplicationHelper.send_error_notification("Error sending mail to #{person.confirmed_notification_emails} community updates: #{e.message}", e.class) @@ -82,6 +84,7 @@ def community_updates(recipient:, community:, listings:, unsubscribe_token:) def time_difference_in_days(from_time, to_time = Time.now) return nil if from_time.nil? + from_time = from_time.to_time if from_time.respond_to?(:to_time) to_time = to_time.to_time if to_time.respond_to?(:to_time) distance_in_minutes = (((to_time - from_time).abs/60)/1440.0).round diff --git a/app/mailers/mail_view_test_data.rb b/app/mailers/mail_view_test_data.rb index b597c598ef..645dca5e43 100644 --- a/app/mailers/mail_view_test_data.rb +++ b/app/mailers/mail_view_test_data.rb @@ -19,6 +19,7 @@ def starter def member return @member unless @member.nil? + @member ||= FactoryGirl.build(:person) @member.emails.first.confirmation_token = "123456abcdef" @member diff --git a/app/mailers/person_mailer.rb b/app/mailers/person_mailer.rb index a59b16d467..7240304eef 100644 --- a/app/mailers/person_mailer.rb +++ b/app/mailers/person_mailer.rb @@ -1,8 +1,8 @@ -# encoding: utf-8 - +# rubocop:disable Style/MixinUsage include ApplicationHelper include ListingsHelper include TruncateHtmlHelper +# rubocop:enable Style/MixinUsage class PersonMailer < ActionMailer::Base include MailUtils @@ -115,7 +115,7 @@ def payment_settings_reminder(listing, recipient, community) end # Remind users of conversations that have not been accepted or rejected - def confirm_reminder(conversation, recipient, community, days_to_cancel) + def confirm_reminder(conversation, _, community, days_to_cancel) @email_type = "email_about_confirm_reminders" recipient = conversation.buyer set_up_layout_variables(recipient, community, @email_type) @@ -183,7 +183,7 @@ def new_listing_by_followed_person(listing, recipient, community) @no_recipient_name = true @author_name = PersonViewUtils.person_display_name(listing.author, community) @listing_url = listing_url(@url_params.merge({:id => listing.id})) - @translate_scope = [ :emails, :new_listing_by_followed_person ] + @translate_scope = [:emails, :new_listing_by_followed_person] premailer_mail(:to => recipient.confirmed_notification_emails_to, :from => community_specific_sender(community), :subject => t("emails.new_listing_by_followed_person.subject", @@ -352,7 +352,7 @@ def self.community_member_email_from_admin(sender, recipient, community, email_c content = "#{content_hello}
\n #{email_content}" begin MailCarrier.deliver_now(community_member_email(sender, recipient, subject, content, community)) - rescue => e + rescue StandardError => e # Catch the exception and continue sending the emails ApplicationHelper.send_error_notification("Error sending email to all the members of community #{community.full_name(email_locale)}: #{e.message}", e.class) end diff --git a/app/mailers/transaction_mailer.rb b/app/mailers/transaction_mailer.rb index 7a9c534868..a48fa220c3 100644 --- a/app/mailers/transaction_mailer.rb +++ b/app/mailers/transaction_mailer.rb @@ -5,9 +5,10 @@ # - transaction status changes # - reminders # - +# rubocop:disable Style/MixinUsage include ApplicationHelper include ListingsHelper +# rubocop:enable Style/MixinUsage class TransactionMailer < ActionMailer::Base include MailUtils @@ -115,7 +116,7 @@ def payment_receipt_to_seller(transaction, seller_model = nil, buyer_model = nil payer_full_name: buyer_model.name(community), payer_given_name: PersonViewUtils.person_display_name_for_type(buyer_model, "first_name_only"), gateway: transaction.payment_gateway, - community_name: community.name_with_separator(seller_model.locale), + community_name: community.name_with_separator(seller_model.locale) } } end @@ -164,7 +165,7 @@ def payment_receipt_to_buyer(transaction, seller_model = nil, buyer_model = nil, show_money_will_be_transferred_note: false, gateway: transaction.payment_gateway, community_name: community.name_with_separator(buyer_model.locale), - payment_buyer_service_fee: buyer_service_fee, + payment_buyer_service_fee: buyer_service_fee } } } diff --git a/app/models/category.rb b/app/models/category.rb index f21237201a..c438434921 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -44,7 +44,7 @@ def translation_attributes=(attributes) build_attrs = attributes.map { |locale, values| { locale: locale, values: values } } build_attrs.each do |translation| if existing_translation = translations.find_by_locale(translation[:locale]) - existing_translation.update_attributes(translation[:values]) + existing_translation.update(translation[:values]) else translations.build(translation[:values].merge({:locale => translation[:locale]})) end @@ -145,6 +145,7 @@ def with_all_children def icon_name return icon if ApplicationHelper.icon_specified?(icon) return parent.icon_name if parent + return "other" end diff --git a/app/models/community.rb b/app/models/community.rb index a3a811bc6b..503780c894 100644 --- a/app/models/community.rb +++ b/app/models/community.rb @@ -267,7 +267,7 @@ class Community < ApplicationRecord }, :default_style => :favicon, :convert_options => { - :favicon => "-depth 32 -strip", + :favicon => "-depth 32 -strip" }, :default_url => ->(_) { ActionController::Base.helpers.asset_path("favicon.ico") } @@ -472,7 +472,7 @@ def menu_link_attributes=(attributes) attributes.each_with_index do |(id, value), i| if menu_link = menu_links.find_by_id(id) - menu_link.update_attributes(value.merge(sort_priority: i)) + menu_link.update(value.merge(sort_priority: i)) ids << menu_link.id else menu_links.build(value.merge(sort_priority: i)) diff --git a/app/models/custom_field_values/dropdown_field_value.rb b/app/models/custom_field_values/dropdown_field_value.rb index 5d47cefbe3..2da5f5153b 100644 --- a/app/models/custom_field_values/dropdown_field_value.rb +++ b/app/models/custom_field_values/dropdown_field_value.rb @@ -27,7 +27,7 @@ class DropdownFieldValue < OptionFieldValue private def validate_selections - if question && question.for_person? + if question&.for_person? return true unless question.required? end unless custom_field_option_selections.size == 1 diff --git a/app/models/custom_fields/option_field.rb b/app/models/custom_fields/option_field.rb index 1c399d3d98..985eceb2a6 100644 --- a/app/models/custom_fields/option_field.rb +++ b/app/models/custom_fields/option_field.rb @@ -69,7 +69,7 @@ def option_attributes=(attributes) } diff.select { |d| d[:action] == :changed }.map { |added| added[:value] }.each { |changed| - options.where(id: changed[:id]).first.update_attributes(changed) + options.where(id: changed[:id]).first.update(changed) } end diff --git a/app/models/export_task_result.rb b/app/models/export_task_result.rb index 5c5793b89c..762d29c5aa 100644 --- a/app/models/export_task_result.rb +++ b/app/models/export_task_result.rb @@ -18,7 +18,7 @@ class ExportTaskResult < ApplicationRecord has_attached_file :file, s3_headers: lambda { |record| { 'Content-Type' => "text/#{record.original_extname}", - 'Content-Disposition' => "attachment; filename=#{record.original_filename}", + 'Content-Disposition' => "attachment; filename=#{record.original_filename}" } }, path: "file-exports/:class/:attachment/:id/:filename", diff --git a/app/models/follower_relationship.rb b/app/models/follower_relationship.rb index 2854356a40..ac8786fae9 100644 --- a/app/models/follower_relationship.rb +++ b/app/models/follower_relationship.rb @@ -25,6 +25,6 @@ class FollowerRelationship < ApplicationRecord validates :follower_id, :presence => true, :uniqueness => { :scope => :person_id }, - :exclusion => { :in => lambda { |x| [ x.person_id ] } } + :exclusion => { :in => lambda { |x| [x.person_id] } } end diff --git a/app/models/invitation.rb b/app/models/invitation.rb index eecaf5daea..475da5601f 100644 --- a/app/models/invitation.rb +++ b/app/models/invitation.rb @@ -49,6 +49,7 @@ def usable? def use_once! raise "Invitation is not usable" if not usable? + update_attribute(:usages_left, self.usages_left - 1) end @@ -56,6 +57,7 @@ def self.code_usable?(code, community=nil) invitation = Invitation.find_by_code(code.upcase) if code.present? if invitation.present? return false if community.present? && invitation.community_id != community.id + return invitation.usable? else return false @@ -65,6 +67,7 @@ def self.code_usable?(code, community=nil) def self.use_code_once(code) invitation = Invitation.find_by_code(code.upcase) if code.present? return false if invitation.blank? + invitation.use_once! return true end diff --git a/app/models/listing.rb b/app/models/listing.rb index 37b15c87e3..7b6697875b 100644 --- a/app/models/listing.rb +++ b/app/models/listing.rb @@ -1,4 +1,3 @@ -# encoding: utf-8 # == Schema Information # # Table name: listings @@ -171,7 +170,7 @@ def add_uuid end validates_length_of :description, :maximum => 5000, :allow_nil => true validates_presence_of :category - validates_inclusion_of :valid_until, :allow_nil => :true, :in => proc{ DateTime.now..DateTime.now + 7.months } + validates_inclusion_of :valid_until, :allow_nil => true, :in => proc{ DateTime.now..DateTime.now + 7.months } validates_numericality_of :price_cents, :only_integer => true, :greater_than_or_equal_to => 0, :message => "price must be numeric", :allow_nil => true # sets the time to midnight @@ -201,7 +200,7 @@ def temporary? def update_fields(params) update_attribute(:valid_until, nil) unless params[:valid_until] - update_attributes(params) + update(params) end def closed? diff --git a/app/models/listing/concerns/manage_availability_per_hour.rb b/app/models/listing/concerns/manage_availability_per_hour.rb index 9bae76f35b..09a16eaf9a 100644 --- a/app/models/listing/concerns/manage_availability_per_hour.rb +++ b/app/models/listing/concerns/manage_availability_per_hour.rb @@ -3,8 +3,10 @@ module ManageAvailabilityPerHour def working_hours_new_set(force_create: false) return if per_hour_ready + Listing::WorkingTimeSlot.week_days.keys.each do |week_day| next if ['sun', 'sat'].include?(week_day) + if force_create working_time_slots.create(week_day: week_day, from: '09:00', till: '17:00') update_column(:per_hour_ready, true) # rubocop:disable Rails/SkipsModelValidations diff --git a/app/models/listing_image.rb b/app/models/listing_image.rb index ae0164d547..cb8e189ba5 100644 --- a/app/models/listing_image.rb +++ b/app/models/listing_image.rb @@ -106,6 +106,7 @@ def crop_big # https://github.com/thoughtbot/paperclip/wiki/Extracting-image-dimensions def extract_dimensions return unless image_downloaded + tempfile = image.queued_for_write[:original] # Works with uploaded files and existing files diff --git a/app/models/listing_shape.rb b/app/models/listing_shape.rb index 9b91e9a309..e0d59c58be 100644 --- a/app/models/listing_shape.rb +++ b/app/models/listing_shape.rb @@ -45,7 +45,7 @@ class ListingShape < ApplicationRecord validates :availability, inclusion: AVAILABILITIES # Possibly :stock in the future def units - @_hash_units ||= listing_units.map(&:to_unit_hash) + @units ||= listing_units.map(&:to_unit_hash) end def self.create_with_opts(community:, opts:) @@ -72,7 +72,7 @@ def update_with_opts(opts) if new_units.present? new_units.each{ |unit| self.listing_units.build(ListingUnit.permitted_attributes(unit)) } end - self.update_attributes!(ListingShape.permitted_attributes(opts)) + self.update!(ListingShape.permitted_attributes(opts)) end self end @@ -89,7 +89,7 @@ def self.next_sort_priority(shapes) def self.uniq_name(shapes, name_source) blacklist = ['new', 'all'] source = name_source.to_url - base_name = source.present? ? source : DEFAULT_BASENAME + base_name = source.presence || DEFAULT_BASENAME current_name = base_name i = 1 diff --git a/app/models/location.rb b/app/models/location.rb index 813ad8fcb8..d9d186c526 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -36,7 +36,7 @@ def search_and_fill_latlng(address=nil, locale=APP_CONFIG.default_locale) end if address != nil && address != "" - url = URI.escape(geocoder+address) + url = CGI.escape(geocoder+address) resp = RestClient.get(url) result = JSON.parse(resp.body) diff --git a/app/models/marketplace_setup_steps.rb b/app/models/marketplace_setup_steps.rb index 56f4dec504..1b254c0d06 100644 --- a/app/models/marketplace_setup_steps.rb +++ b/app/models/marketplace_setup_steps.rb @@ -22,6 +22,6 @@ class MarketplaceSetupSteps < ApplicationRecord validates_presence_of(:community_id) def skip_payment - update_attributes(payment: true) + update(payment: true) end end diff --git a/app/models/menu_link.rb b/app/models/menu_link.rb index c75bcd3e16..0a97092cf4 100644 --- a/app/models/menu_link.rb +++ b/app/models/menu_link.rb @@ -32,7 +32,7 @@ class MenuLink < ApplicationRecord def translation_attributes=(attributes) attributes.each do |locale, value| if translation = translations.find_by_locale(locale) - translation.update_attributes(value) + translation.update(value) else translation = translations.build(value.merge(locale: locale)) end diff --git a/app/models/message.rb b/app/models/message.rb index 8016f32ccb..9338bf1bd6 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -36,7 +36,7 @@ def update_conversation_read_status conversation.update_attribute(:last_message_at, created_at) conversation.participations.each do |p| last_at = p.person.eql?(sender) ? :last_sent_at : :last_received_at - p.update_attributes({ :is_read => p.person.eql?(sender), last_at => created_at}) + p.update({ :is_read => p.person.eql?(sender), last_at => created_at}) end end end diff --git a/app/models/person.rb b/app/models/person.rb index 38f90c8651..5ef92992aa 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -84,9 +84,9 @@ class Person < ApplicationRecord :recoverable, :rememberable, :trackable, :omniauthable - attr_accessor :guid, :password2, :form_login, + attr_accessor :guid, :form_login, :form_given_name, :form_family_name, :form_password, - :form_password2, :form_email, :consent, + :form_password2, :form_email, :input_again, :send_notifications # Virtual attribute for authenticating by either username or email @@ -341,7 +341,7 @@ def given_name_or_username deprecator: MethodDeprecator.new def set_given_name(name) - update_attributes({:given_name => name }) + update({:given_name => name }) end def street_address @@ -379,7 +379,7 @@ def update_attributes(params) end def picture_from_url(url) - self.image = open(url) + self.image = open(url) # rubocop:disable Security/Open self.save end @@ -416,7 +416,7 @@ def set_default_preferences def password2 if new_record? - return form_password2 ? form_password2 : "" + return form_password2 || "" end end @@ -480,6 +480,7 @@ def should_receive?(email_type) # this is handled outside prefenrences so answer separately return confirmed_email && min_days_between_community_updates < 100000 end + confirmed_email && preferences && preferences[email_type] end @@ -587,6 +588,7 @@ def should_receive_community_updates_now? # return whether or not enought time has passed. The - 45.minutes is because the sending takes some time so we want # 1 day limit to match even if there's 23.55 minutes passed since last sending. return true if community_updates_last_sent_at.nil? + return community_updates_last_sent_at + min_days_between_community_updates.days - 45.minutes < Time.now end @@ -596,7 +598,7 @@ def should_receive_community_updates_now? def latest_pending_email_address(community=nil) pending_emails = Email.where(:person_id => id, :confirmed_at => nil).pluck(:address) - allowed_emails = if community && community.allowed_emails + allowed_emails = if community&.allowed_emails pending_emails.select do |e| community.email_allowed?(e) end diff --git a/app/models/person/concerns/delete_person.rb b/app/models/person/concerns/delete_person.rb index 2677f76db0..c3a8d8d258 100644 --- a/app/models/person/concerns/delete_person.rb +++ b/app/models/person/concerns/delete_person.rb @@ -10,7 +10,7 @@ def delete_user(id) return false else # Delete personal information - person.update_attributes( + person.update( given_name: nil, family_name: nil, display_name: nil, @@ -48,7 +48,7 @@ def delete_user(id) person.inverse_follower_relationships.destroy_all # Delete memberships - person.community_membership.update_attributes(status: "deleted_user") + person.community_membership.update(status: "deleted_user") # Delte auth tokens person.auth_tokens.destroy_all diff --git a/app/presenters/concerns/listing_availability_manage.rb b/app/presenters/concerns/listing_availability_manage.rb index fe4c305696..60d72c496c 100644 --- a/app/presenters/concerns/listing_availability_manage.rb +++ b/app/presenters/concerns/listing_availability_manage.rb @@ -85,7 +85,7 @@ def datepicker_per_day_or_night_setup(blocked_dates) localized_dates: datepicker_localized_dates, listing_quantity_selector: listing.quantity_selector, blocked_dates: blocked_dates.map { |d| d.to_i }, - end_date: booking_dates_end_midnight.to_i, + end_date: booking_dates_end_midnight.to_i } end @@ -99,6 +99,7 @@ def booking_per_hour_end_time def availability_per_hour_calculate_options_for_select return @availability_per_hour_raw_options_for_select if defined?(@availability_per_hour_raw_options_for_select) + result = {} current_day = nil start = nil @@ -139,6 +140,7 @@ def availability_per_hour_calculate_options_for_select def availability_per_hour_calculate_blocked_dates return @availability_per_hour_raw_blocked_dates if defined?(@availability_per_hour_raw_blocked_dates) + all_options = availability_per_hour_calculate_options_for_select result = [] start = nil @@ -187,7 +189,7 @@ def datepicker_per_hour_setup listing_quantity_selector: listing.quantity_selector, blocked_dates: availability_per_hour_blocked_dates.map { |d| date_to_time_utc(d).to_i }, end_date: booking_dates_end_midnight.to_i, - options_for_select: availability_per_hour_options_for_select_grouped_by_day, + options_for_select: availability_per_hour_options_for_select_grouped_by_day } end @@ -200,7 +202,7 @@ def working_hours_props }, marketplace: { uuid: @current_community.uuid_object.to_s, - marketplace_color1: CommonStylesHelper.marketplace_colors(@current_community)[:marketplace_color1], + marketplace_color1: CommonStylesHelper.marketplace_colors(@current_community)[:marketplace_color1] }, listing: working_time_slots, time_slot_options: time_slot_options, diff --git a/app/presenters/listing/list_presenter.rb b/app/presenters/listing/list_presenter.rb index d4d104c2a8..7395c962f5 100644 --- a/app/presenters/listing/list_presenter.rb +++ b/app/presenters/listing/list_presenter.rb @@ -24,6 +24,7 @@ def reset_search_path def statuses return @statuses if defined?(@statuses) + result = ['open', 'closed', 'expired'] result += [Listing::APPROVAL_PENDING, Listing::APPROVAL_REJECTED] if community.pre_approved_listings @statuses = result diff --git a/app/presenters/listing_presenter.rb b/app/presenters/listing_presenter.rb index 276006a2a2..7fcd26d5f1 100644 --- a/app/presenters/listing_presenter.rb +++ b/app/presenters/listing_presenter.rb @@ -80,6 +80,7 @@ def community_country_code def process return nil unless @listing.transaction_process_id + get_transaction_process(community_id: @current_community.id, transaction_process_id: @listing.transaction_process_id) end @@ -192,9 +193,9 @@ def commission paypal_minimum_transaction_fee: 0, seller_commission_in_use: false, stripe_commission: 0, - stripe_minimum_transaction_fee: 0, + stripe_minimum_transaction_fee: 0 } - when matches([:paypal]), matches([:stripe]), matches([ [:paypal, :stripe] ]) + when matches([:paypal]), matches([:stripe]), matches([[:paypal, :stripe]]) p_set = Maybe(payment_settings_api.get_active_by_gateway(community_id: @current_community.id, payment_gateway: payment_type)) .select {|res| res[:success]} .map {|res| res[:data]} @@ -214,7 +215,7 @@ def commission paypal_minimum_transaction_fee: Money.new(paypal_settings[:minimum_transaction_fee_cents], currency), seller_commission_in_use: p_set[:commission_type] != :none, stripe_commission: stripe_settings[:commission_from_seller], - stripe_minimum_transaction_fee: Money.new(stripe_settings[:minimum_transaction_fee_cents], currency), + stripe_minimum_transaction_fee: Money.new(stripe_settings[:minimum_transaction_fee_cents], currency) } else raise ArgumentError.new("Unknown payment_type, process combination: [#{payment_type}, #{process}]") diff --git a/app/services/admin/communities/footer_service.rb b/app/services/admin/communities/footer_service.rb index 7cd8a957a2..ebf32f77ff 100644 --- a/app/services/admin/communities/footer_service.rb +++ b/app/services/admin/communities/footer_service.rb @@ -24,14 +24,16 @@ def new_footer_menu_link end def update - community.update_attributes(footer_params) && + community.update(footer_params) && community.footer_menu_links.map(&:save).all? end def social_links return @social_links if defined?(@social_links) + SocialLink.social_provider_list.each do |provider| next if community.social_links.by_provider(provider).any? + community.social_links.build(provider: provider) end @social_links = community.social_links @@ -50,7 +52,7 @@ def footer_params :footer_theme, :footer_copyright, :footer_enabled, footer_menu_links_attributes: [ :id, :entity_type, :sort_priority, :_destroy, - translation_attributes: Hash[community.locales.collect { |item| [item.to_sym, [:title, :url]] } ] + translation_attributes: Hash[community.locales.collect { |item| [item.to_sym, [:title, :url]] }] ], social_links_attributes: [ :id, :provider, :url, :sort_priority, :enabled diff --git a/app/services/admin/communities/membership_service.rb b/app/services/admin/communities/membership_service.rb index 53837ce68d..f7795cc91c 100644 --- a/app/services/admin/communities/membership_service.rb +++ b/app/services/admin/communities/membership_service.rb @@ -30,14 +30,14 @@ def membership_current_user? end def ban - membership.update_attributes(status: "banned") - membership.update_attributes(admin: 0) if membership.admin == 1 + membership.update(status: "banned") + membership.update(admin: 0) if membership.admin == 1 community.close_listings_by_author(membership.person) membership end def unban - membership.update_attributes(status: "accepted") + membership.update(status: "accepted") membership end diff --git a/app/services/admin/onboarding_wizard.rb b/app/services/admin/onboarding_wizard.rb index c5d1ca4e99..c6320e4e19 100644 --- a/app/services/admin/onboarding_wizard.rb +++ b/app/services/admin/onboarding_wizard.rb @@ -28,6 +28,7 @@ class OnboardingWizard def initialize(community_id) raise ArgumentError("Missing mandatory community_id") unless community_id + @community_id = community_id end @@ -150,7 +151,7 @@ def init_setup_steps(community_id) invitation_created(setup_status, invitation), ].compact.map { |status| [status, true] }.to_h - m.update_attributes(updates) + m.update(updates) m end diff --git a/app/services/admin/person_custom_fields_service.rb b/app/services/admin/person_custom_fields_service.rb index e06740a9ec..9e5660048e 100644 --- a/app/services/admin/person_custom_fields_service.rb +++ b/app/services/admin/person_custom_fields_service.rb @@ -32,13 +32,13 @@ def create def update find_custom_field - custom_field.update_attributes(custom_field_params) + custom_field.update(custom_field_params) end def order sort_priorities = params[:order].map(&:to_i) resource_scope.each do |field| - field.update_attributes(sort_priority: sort_priorities.index(field.id)) + field.update(sort_priority: sort_priorities.index(field.id)) end end diff --git a/app/services/admin/settings_service.rb b/app/services/admin/settings_service.rb index 1a78f03ae7..34289e1bb5 100644 --- a/app/services/admin/settings_service.rb +++ b/app/services/admin/settings_service.rb @@ -9,7 +9,7 @@ def initialize(community:, params:) def update update_payment_settings update_configuration - community.update_attributes(settings_params) + community.update(settings_params) end private @@ -31,6 +31,7 @@ def settings_params ) end + # rubocop:disable Rails/SkipsModelValidations def update_payment_settings automatic_confirmation_after_days = params[:community][:automatic_confirmation_after_days] return unless automatic_confirmation_after_days @@ -41,6 +42,7 @@ def update_payment_settings stripe_settings = PaymentSettings.stripe.find_by(community_id: community.id) stripe_settings&.update_column(:confirmation_after_days, automatic_confirmation_after_days.to_i) end + # rubocop:enable Rails/SkipsModelValidations def update_configuration if FeatureFlagHelper.location_search_available diff --git a/app/services/admin/testimonials_service.rb b/app/services/admin/testimonials_service.rb index bd28b6ec2c..3a55007b74 100644 --- a/app/services/admin/testimonials_service.rb +++ b/app/services/admin/testimonials_service.rb @@ -14,6 +14,7 @@ def transactions def testimonials return @testimonials if defined?(@testimonials) + pages = transactions.total_pages tx_from = transactions.offset + 1 tx_to = pages > 1 ? (transactions.offset + transactions.length) : transactions.total_entries @@ -22,7 +23,7 @@ def testimonials page_count: transactions.map{ |tx| tx.testimonials.size }.sum, tx_total_pages: pages, tx_from: tx_from, - tx_to: tx_to, + tx_to: tx_to } end @@ -35,7 +36,7 @@ def update (params[:testimonial][:blocked].nil? || params[:testimonial][:blocked] == '0') testimonial.destroy && testimonial.tx.reload else - testimonial.update_attributes(testimonial_params) && + testimonial.update(testimonial_params) && testimonial.tx.reload end end @@ -88,6 +89,7 @@ def sorted_statuses def filtered_scope return @filtered_scope if defined?(@filtered_scope) + scope = transactions_scope tx_statuses = [] diff --git a/app/services/confirm_conversation.rb b/app/services/confirm_conversation.rb index 71b86f02f4..258f5e2fbd 100644 --- a/app/services/confirm_conversation.rb +++ b/app/services/confirm_conversation.rb @@ -29,9 +29,9 @@ def update_participation(feedback_given) @participation.update_attribute(:is_read, true) if @offerer.eql?(@user) if @transaction.author == @user - @transaction.update_attributes(author_skipped_feedback: true) unless feedback_given + @transaction.update(author_skipped_feedback: true) unless feedback_given else - @transaction.update_attributes(starter_skipped_feedback: true) unless feedback_given + @transaction.update(starter_skipped_feedback: true) unless feedback_given end end diff --git a/app/services/custom_landing_page/background_helper.rb b/app/services/custom_landing_page/background_helper.rb index 29e3156bbc..641825d7ac 100644 --- a/app/services/custom_landing_page/background_helper.rb +++ b/app/services/custom_landing_page/background_helper.rb @@ -35,7 +35,7 @@ def background_style_modifiers(s, second_wo_background) variation_modifiers = { 'single_column' => 'single-column', - 'multi_column' => 'multi-column', + 'multi_column' => 'multi-column' } variation_modifier = variation_modifiers[s['variation']] diff --git a/app/services/custom_landing_page/landing_page_store.rb b/app/services/custom_landing_page/landing_page_store.rb index 8ab31bb8aa..9dc59d822f 100644 --- a/app/services/custom_landing_page/landing_page_store.rb +++ b/app/services/custom_landing_page/landing_page_store.rb @@ -1,5 +1,3 @@ -# rubocop:disable ConstantName - module CustomLandingPage # Use appropriate LandingPageStore implementation diff --git a/app/services/custom_landing_page/landing_page_store_defaults.rb b/app/services/custom_landing_page/landing_page_store_defaults.rb index 92e106cdbd..3b3188734b 100644 --- a/app/services/custom_landing_page/landing_page_store_defaults.rb +++ b/app/services/custom_landing_page/landing_page_store_defaults.rb @@ -2,18 +2,18 @@ module CustomLandingPage module LandingPageStoreDefaults DEFAULT_PARAGRAPH_LINK_COLORS = { - "paragraph_link_color" => { "type" => "marketplace_data", "id" => "primary_color" }, + "paragraph_link_color" => { "type" => "marketplace_data", "id" => "primary_color" }, "paragraph_link_color_hover" => { "type" => "marketplace_data", "id" => "primary_color_darken" } } DEFAULT_SOCIAL_DATA = { "page" => { - "social_media_title" => { "type" => "marketplace_data", "id" => "social_media_title" }, + "social_media_title" => { "type" => "marketplace_data", "id" => "social_media_title" }, "social_media_description" => { "type" => "marketplace_data", "id" => "social_media_description" }, "meta_description" => { "type" => "marketplace_data", "id" => "meta_description" } } }.freeze DEFAULT_FOOTER_DATA = { - "logo" => { "type" => "marketplace_data", "id" => "logo" } + "logo" => { "type" => "marketplace_data", "id" => "logo" } }.freeze module_function diff --git a/app/services/custom_landing_page/marketplace_data_store.rb b/app/services/custom_landing_page/marketplace_data_store.rb index e46adeb8e7..cacffbb825 100644 --- a/app/services/custom_landing_page/marketplace_data_store.rb +++ b/app/services/custom_landing_page/marketplace_data_store.rb @@ -52,7 +52,7 @@ def marketplace_data(cid, locale) "keyword_search" end - color = primary_color.present? ? primary_color : DEFAULT_COLOR + color = primary_color.presence || DEFAULT_COLOR color_darken = ColorUtils.brightness(color, 85) slogan = split_long_words(seo_service.interpolate(slogan, locale)) diff --git a/app/services/discovery_client.rb b/app/services/discovery_client.rb index ae453948e7..4ed64133cf 100644 --- a/app/services/discovery_client.rb +++ b/app/services/discovery_client.rb @@ -2,7 +2,7 @@ APP_CONFIG.discovery_api_url, { # Listings - query_listings: "/discovery/listings/query", + query_listings: "/discovery/listings/query" }, [ diff --git a/app/services/email_service/ses/logger.rb b/app/services/email_service/ses/logger.rb index fa60dabc47..113d8f7602 100644 --- a/app/services/email_service/ses/logger.rb +++ b/app/services/email_service/ses/logger.rb @@ -31,7 +31,7 @@ def to_json_log_entry(type, method, params, request_id = nil) type: type, method: method, params: params, - request_id: request_id, + request_id: request_id }.to_json end end diff --git a/app/services/email_service/store/address.rb b/app/services/email_service/store/address.rb index 9ba2fbba57..c18edec778 100644 --- a/app/services/email_service/store/address.rb +++ b/app/services/email_service/store/address.rb @@ -58,7 +58,7 @@ def create(community_id:, address:) def set_verification_requested(community_id:, id:) Maybe(MarketplaceSenderEmail.where(community_id: community_id, id: id).first) - .update_attributes( + .update( verification_requested_at: Time.now, verification_status: :requested) .or_else(nil) @@ -80,7 +80,7 @@ def touch(ids:) def update(community_id:, id:, name:) Maybe(MarketplaceSenderEmail.where(community_id: community_id, id: id).first) - .update_attributes(name: name).or_else(nil) + .update(name: name).or_else(nil) end ## Privates diff --git a/app/services/feature_flag_service/store.rb b/app/services/feature_flag_service/store.rb index 491c70390b..8a35897177 100644 --- a/app/services/feature_flag_service/store.rb +++ b/app/services/feature_flag_service/store.rb @@ -120,7 +120,7 @@ def update_flags!(community_id, person_id, flags) FeatureFlagModel .where(community_id: community_id, person_id: person_id, feature: feature) .first_or_create - .update_attributes(enabled: enabled) + .update(enabled: enabled) } end end diff --git a/app/services/harmony_client.rb b/app/services/harmony_client.rb index 89502f29d4..dab838bc97 100644 --- a/app/services/harmony_client.rb +++ b/app/services/harmony_client.rb @@ -11,7 +11,7 @@ ServiceClient::Middleware::ParamEncoder.new, ServiceClient::Middleware::JwtAuthenticator.new( secret: APP_CONFIG.harmony_api_token_secret, - default_auth_context: ->(){ + default_auth_context: ->{ session_ctx = SessionContextStore.get { diff --git a/app/services/js_translations.rb b/app/services/js_translations.rb index db391cf7e2..0fa1a6d4e5 100644 --- a/app/services/js_translations.rb +++ b/app/services/js_translations.rb @@ -12,6 +12,7 @@ def load(keys) without_interpolation { keys.inject({}) do |memo, key| raise "Use only full keys, not keys scoped by partial: '#{key}'" if key.to_s.first == "." + memo[key] = I18n.t(key) memo end diff --git a/app/services/listing_index_service/api/listings.rb b/app/services/listing_index_service/api/listings.rb index 3a63510bf3..0881b935b7 100644 --- a/app/services/listing_index_service/api/listings.rb +++ b/app/services/listing_index_service/api/listings.rb @@ -28,6 +28,7 @@ def search(community_id:, search:, includes: [], engine: :sphinx, raise_errors: ) }.or_else { raise search_result.data if raise_errors + log_error(search_result, community_id) search_result } diff --git a/app/services/listing_index_service/search/converters.rb b/app/services/listing_index_service/search/converters.rb index 78c0f6bef2..c64c8b9826 100644 --- a/app/services/listing_index_service/search/converters.rb +++ b/app/services/listing_index_service/search/converters.rb @@ -28,7 +28,7 @@ def location_hash(l, includes) { latitude: m_location.latitude.or_else(nil), longitude: m_location.longitude.or_else(nil), - address: m_location.address.or_else(nil), + address: m_location.address.or_else(nil) } else {} @@ -47,7 +47,7 @@ def author_hash(l, includes) avatar: { thumb: l.author.image.present? ? l.author.image.url(:thumb) : nil }, - is_deleted: l.author.deleted?, + is_deleted: l.author.deleted? }.merge(num_of_reviews_hash(l, includes)) } else diff --git a/app/services/listing_index_service/search/sphinx_adapter.rb b/app/services/listing_index_service/search/sphinx_adapter.rb index acbe2b2c33..4cfbfbd9b2 100644 --- a/app/services/listing_index_service/search/sphinx_adapter.rb +++ b/app/services/listing_index_service/search/sphinx_adapter.rb @@ -67,7 +67,7 @@ def search_with_sphinx(community_id:, search:, included_models:, includes:) category_id: search[:categories], # array of accepted ids listing_shape_id: search[:listing_shape_id], price_cents: search[:price_cents], - listing_id: numeric_search_match_listing_ids, + listing_id: numeric_search_match_listing_ids }) selection_groups = search[:fields].select { |v| v[:type] == :selection_group } @@ -75,7 +75,7 @@ def search_with_sphinx(community_id:, search:, included_models:, includes:) with_all = { custom_dropdown_field_options: (grouped_by_operator[:or] || []).map { |v| v[:value] }, - custom_checkbox_field_options: (grouped_by_operator[:and] || []).flat_map { |v| v[:value] }, + custom_checkbox_field_options: (grouped_by_operator[:and] || []).flat_map { |v| v[:value] } } models = Listing.search( diff --git a/app/services/paypal_service/api/api.rb b/app/services/paypal_service/api/api.rb index a14415627e..3a7e1ae157 100644 --- a/app/services/paypal_service/api/api.rb +++ b/app/services/paypal_service/api/api.rb @@ -1,5 +1,3 @@ -# rubocop:disable ConstantName - module PaypalService module API Api = diff --git a/app/services/paypal_service/api/billing_agreements.rb b/app/services/paypal_service/api/billing_agreements.rb index 33e33bdd37..bc95b3bdcb 100644 --- a/app/services/paypal_service/api/billing_agreements.rb +++ b/app/services/paypal_service/api/billing_agreements.rb @@ -41,7 +41,7 @@ def charge_commission(community_id, person_id, info, force_sync: true) DataTypes.create_process_status({ process_token: proc_token[:process_token], completed: proc_token[:op_completed], - result: proc_token[:op_output], + result: proc_token[:op_output] })) else do_charge_commission(community_id, info, m_acc, admin_acc, payment) diff --git a/app/services/paypal_service/api/invnum.rb b/app/services/paypal_service/api/invnum.rb index c52dc6fbba..b5c6fb7314 100644 --- a/app/services/paypal_service/api/invnum.rb +++ b/app/services/paypal_service/api/invnum.rb @@ -8,6 +8,7 @@ module PaypalService::API::Invnum def create(community_id, transaction_id, type) raise ArgumentError.new("Illegal type: #{type} for invoice number.") unless VALID_TYPES.include? type + "#{community_id}-#{transaction_id}-#{type}" end diff --git a/app/services/paypal_service/api/lookup.rb b/app/services/paypal_service/api/lookup.rb index 402e943205..cbc326c28e 100644 --- a/app/services/paypal_service/api/lookup.rb +++ b/app/services/paypal_service/api/lookup.rb @@ -1,4 +1,3 @@ - # Various helping methods to lookup context (from DB) for paypal operations module PaypalService::API diff --git a/app/services/paypal_service/api/payments.rb b/app/services/paypal_service/api/payments.rb index 77dff69f1e..d4355cea78 100644 --- a/app/services/paypal_service/api/payments.rb +++ b/app/services/paypal_service/api/payments.rb @@ -289,7 +289,7 @@ def create_payment(token) error_policy: { codes_to_retry: ["10001", "x-timeout", "x-servererror"], try_max: 3, - finally: method(:handle_failed_create_payment).call(token), + finally: method(:handle_failed_create_payment).call(token) } ) do |ec_details| # Validate that the buyer accepted and we have a payer_id now @@ -363,7 +363,7 @@ def create_order_details(data) shipping_address_postal_code: :postal_code, shipping_address_state_or_province: :state_or_province, shipping_address_street1: :street1, - shipping_address_street2: :street2, + shipping_address_street2: :street2 }, data)) end @@ -404,7 +404,7 @@ def void_payment(community_id, transaction_id, payment, flow, m_acc, note = nil) # authorization connected to the payment but with auth # flow we have no order so void the authorization # directly. - transaction_id: payment[:order_id] ? payment[:order_id] : payment[:authorization_id], + transaction_id: payment[:order_id] || payment[:authorization_id], note: note }), error_policy: { @@ -414,7 +414,7 @@ def void_payment(community_id, transaction_id, payment, flow, m_acc, note = nil) ) do |void_res| with_success(community_id, transaction_id, MerchantData.create_get_transaction_details({ receiver_username: m_acc[:payer_id], - transaction_id: payment[:order_id] ? payment[:order_id] : payment[:authorization_id], + transaction_id: payment[:order_id] || payment[:authorization_id] })) do |payment_res| payment = PaymentStore.update( data: payment_res, diff --git a/app/services/paypal_service/api/request_wrapper.rb b/app/services/paypal_service/api/request_wrapper.rb index fcb088de52..56eeb9961d 100644 --- a/app/services/paypal_service/api/request_wrapper.rb +++ b/app/services/paypal_service/api/request_wrapper.rb @@ -16,9 +16,9 @@ def with_success(cid, txid, request, opts = { error_policy: {} }, &block) end def parse_policy(policy) - [ Maybe(policy[:codes_to_retry]).or_else([]), - Maybe(policy[:try_max]).or_else(1), - Maybe(policy[:finally]).or_else(method(:log_and_return)) ] + [Maybe(policy[:codes_to_retry]).or_else([]), + Maybe(policy[:try_max]).or_else(1), + Maybe(policy[:finally]).or_else(method(:log_and_return))] end def try_operation(retry_codes, try_max, &op) diff --git a/app/services/paypal_service/data_types/ipn.rb b/app/services/paypal_service/data_types/ipn.rb index 234640eeda..15c6415787 100644 --- a/app/services/paypal_service/data_types/ipn.rb +++ b/app/services/paypal_service/data_types/ipn.rb @@ -258,7 +258,7 @@ def msg_type(txn_type, payment_status, pending_reason, invoice_num) return :order_created elsif status == "pending" && txn_type == "merch_pmt" && inv_type == :commission return :commission_pending_ext - elsif status == "pending" && (reason == "paymentreview" || reason == "payment-review") + elsif status == "pending" && ["paymentreview", "payment-review"].include?(reason) return :payment_review elsif status == "pending" && reason == "authorization" return :authorization_created @@ -365,7 +365,7 @@ def to_payment_refunded(params) with_auth_total = p[:auth_amount] ? p.merge({ authorization_total: to_money(p[:auth_amount], p[:mc_currency]) }) : p - mc_fee = p[:mc_fee] ? p[:mc_fee] : 0 + mc_fee = p[:mc_fee] || 0 create_payment_refunded( with_auth_total.merge({ payment_total: to_money(p[:mc_gross], p[:mc_currency]), @@ -379,7 +379,7 @@ def to_payment_pending_ext(params) { txn_id: :pending_ext_id, auth_id: :authorization_id, - auth_exp: :authorization_expires_date, + auth_exp: :authorization_expires_date }, params ) @@ -442,7 +442,7 @@ def to_commission_paid(params) params ) - mc_fee = params[:mc_fee] ? params[:mc_fee] : 0 + mc_fee = params[:mc_fee] || 0 create_commission_paid( p.merge({ commission_total: to_money(params[:mc_gross], params[:mc_currency]), @@ -461,7 +461,7 @@ def to_commission_denied(params) params ) - mc_fee = params[:mc_fee] ? params[:mc_fee] : 0 + mc_fee = params[:mc_fee] || 0 create_commission_denied( p.merge({ commission_total: to_money(params[:mc_gross], params[:mc_currency]), @@ -491,7 +491,7 @@ def to_commission_pending_ext(params) def to_billing_agreement_created(params) p = HashUtils.rename_keys( { - mp_id: :billing_agreement_id, + mp_id: :billing_agreement_id }, params ) @@ -518,7 +518,7 @@ def to_authorization_expired(params) def to_payment_adjustment(params) p = HashUtils.rename_keys( { - parent_txn_id: :payment_id, + parent_txn_id: :payment_id }, params) diff --git a/app/services/paypal_service/data_types/merchant.rb b/app/services/paypal_service/data_types/merchant.rb index 506bc8672e..9e6fd31d4a 100644 --- a/app/services/paypal_service/data_types/merchant.rb +++ b/app/services/paypal_service/data_types/merchant.rb @@ -75,16 +75,12 @@ module Merchant [:method, const_value: :set_express_checkout_order], [:item_name, :mandatory, :string], [:item_quantity, :fixnum, default: 1], - [:require_shipping_address, :to_bool], [:item_price, :mandatory, :money], - # If specified, require_shipping_address must be true [:shipping_total, :optional], - # Must match item_price * item_quantity + shipping_total [:order_total, :mandatory, :money], - [:receiver_username, :mandatory, :string], [:success, :mandatory, :string], [:cancel, :mandatory, :string], @@ -103,16 +99,12 @@ module Merchant [:method, const_value: :set_express_checkout_authorization], [:item_name, :mandatory, :string], [:item_quantity, :fixnum, default: 1], - [:require_shipping_address, :to_bool], [:item_price, :mandatory, :money], - # If specified, require_shipping_address must be true [:shipping_total, :optional], - # Must match item_price * item_quantity + shipping_total [:order_total, :mandatory, :money], - [:receiver_username, :mandatory, :string], [:success, :mandatory, :string], [:cancel, :mandatory, :string], @@ -154,7 +146,6 @@ module Merchant [:authorization_date, :utc_str_to_time], [:payment_status, :mandatory, :string], [:pending_reason, :mandatory, :string], - # Reponse will have either order or authorization details depending upon payment status [:order_id, :string], [:order_total, :money], diff --git a/app/services/paypal_service/logger.rb b/app/services/paypal_service/logger.rb index daeff832a4..90b665f018 100644 --- a/app/services/paypal_service/logger.rb +++ b/app/services/paypal_service/logger.rb @@ -36,7 +36,7 @@ def to_json_log_entry(type, free, structured, request_id = nil) type: type, free: free, structured: structured, - request_id: request_id, + request_id: request_id }.to_json end end diff --git a/app/services/paypal_service/merchant.rb b/app/services/paypal_service/merchant.rb index 5d63ae8cc5..2e9086b92d 100644 --- a/app/services/paypal_service/merchant.rb +++ b/app/services/paypal_service/merchant.rb @@ -18,7 +18,7 @@ def initialize(config, logger, action_handlers = MERCHANT_ACTIONS, api_builder = username: config[:api_credentials][:username], password: config[:api_credentials][:password], signature: config[:api_credentials][:signature], - app_id: config[:api_credentials][:app_id], + app_id: config[:api_credentials][:app_id] } ) end diff --git a/app/services/paypal_service/merchant_actions.rb b/app/services/paypal_service/merchant_actions.rb index dadd6c127f..fca174ccff 100644 --- a/app/services/paypal_service/merchant_actions.rb +++ b/app/services/paypal_service/merchant_actions.rb @@ -71,7 +71,7 @@ def express_checkout_url(api, token) PaymentDetails: [{ OrderTotal: { value: "0.0" }, NotifyURL: hook_url(config[:ipn_hook]), - PaymentAction: PAYMENT_ACTIONS[:authorization], + PaymentAction: PAYMENT_ACTIONS[:authorization] }], BillingAgreementDetails: [{ BillingType: "ChannelInitiatedBilling", @@ -334,7 +334,7 @@ def express_checkout_url(api, token) { MsgSubID: req[:msg_sub_id], TransactionID: req[:order_id], - Amount: from_money(req[:authorization_total]), + Amount: from_money(req[:authorization_total]) } }, wrapper_method_name: :build_do_authorization, @@ -426,7 +426,7 @@ def express_checkout_url(api, token) get_transaction_details: PaypalAction.def_action( input_transformer: -> (req, _) { { - TransactionID: req[:transaction_id], + TransactionID: req[:transaction_id] } }, wrapper_method_name: :build_get_transaction_details, diff --git a/app/services/paypal_service/permissions.rb b/app/services/paypal_service/permissions.rb index 7bca6796c8..dff36605a1 100644 --- a/app/services/paypal_service/permissions.rb +++ b/app/services/paypal_service/permissions.rb @@ -15,7 +15,7 @@ def initialize(config, logger, action_handlers = PERMISSIONS_ACTIONS, api_builde username: config[:api_credentials][:username], password: config[:api_credentials][:password], signature: config[:api_credentials][:signature], - app_id: config[:api_credentials][:app_id], + app_id: config[:api_credentials][:app_id] } ) end diff --git a/app/services/paypal_service/permissions_actions.rb b/app/services/paypal_service/permissions_actions.rb index e0fb783f93..e820d41b53 100644 --- a/app/services/paypal_service/permissions_actions.rb +++ b/app/services/paypal_service/permissions_actions.rb @@ -42,7 +42,7 @@ module PermissionsActions input_transformer: -> (req) { { attributeList: { - attribute: [ "http://axschema.org/contact/email", "https://www.paypal.com/webapps/auth/schema/payerID" ] + attribute: ["http://axschema.org/contact/email", "https://www.paypal.com/webapps/auth/schema/payerID"] } } }, diff --git a/app/services/paypal_service/store/paypal_account.rb b/app/services/paypal_service/store/paypal_account.rb index 20b36377d4..4639d4757d 100644 --- a/app/services/paypal_service/store/paypal_account.rb +++ b/app/services/paypal_service/store/paypal_account.rb @@ -10,17 +10,14 @@ module PaypalService::Store::PaypalAccount [:community_id, :mandatory, :fixnum], [:person_id, :optional, :string], [:order_permission_paypal_username_to, :mandatory, :string], - # Optional [:order_permission_request_token, :string], [:active, one_of: [true, false, nil]], [:email, :string], [:payer_id, :string], - [:order_permission_verification_code, :string], [:order_permission_scope, :string], [:order_permission_onboarding_id, :string], - [:billing_agreement_billing_agreement_id, :string], [:billing_agreement_paypal_username_to, :string], [:billing_agreement_request_token, :string] @@ -269,8 +266,8 @@ def update_model(maybe_model, opts, find_params) account_model = maybe_model.get account_values = HashUtils.compact(FlattingHelper.select_paypal_account_values(entity)) - account_model.update_attributes(account_values) - account_model.order_permission.update_attributes(HashUtils.compact(FlattingHelper.select_order_permission_values(entity))) + account_model.update(account_values) + account_model.order_permission.update(HashUtils.compact(FlattingHelper.select_order_permission_values(entity))) account_model = update_or_create_billing_agreement(account_model, HashUtils.compact(FlattingHelper.select_billing_agreement_values(entity))) deactivate_other_accounts(account_model) if account_values[:active] @@ -291,7 +288,7 @@ def update_or_create_billing_agreement(account_model, opts) account_model.create_billing_agreement(opts) else # update - account_model.billing_agreement.update_attributes(opts) + account_model.billing_agreement.update(opts) end account_model end diff --git a/app/services/paypal_service/store/paypal_payment.rb b/app/services/paypal_service/store/paypal_payment.rb index f594c28d57..215ea31421 100644 --- a/app/services/paypal_service/store/paypal_payment.rb +++ b/app/services/paypal_service/store/paypal_payment.rb @@ -218,7 +218,7 @@ def update_payment!(payment, data) raise ArgumentError.new("No matching payment to update.") end - payment.update_attributes!(payment_update) + payment.update!(payment_update) from_model(payment.reload) end @@ -244,7 +244,7 @@ def update_payment!(payment, data) voided: 3, pending_ext: 3, completed: 4, - denied: 4, + denied: 4 } def valid_transition?(current_state, new_state) diff --git a/app/services/paypal_service/store/process_token.rb b/app/services/paypal_service/store/process_token.rb index de8179b708..86c30b72dc 100644 --- a/app/services/paypal_service/store/process_token.rb +++ b/app/services/paypal_service/store/process_token.rb @@ -26,7 +26,7 @@ def create(community_id:, transaction_id:, op_name:, op_input: []) def update_to_completed(process_token:, op_output:) ProcessTokenModel.where(process_token: process_token).first! - .update_attributes(op_completed: true, op_output: YAML.dump(op_output)) + .update(op_completed: true, op_output: YAML.dump(op_output)) end def get_by_transaction(community_id:, transaction_id:, op_name:) diff --git a/app/services/person/omniauth_service.rb b/app/services/person/omniauth_service.rb index 7961f09485..249b2e7306 100644 --- a/app/services/person/omniauth_service.rb +++ b/app/services/person/omniauth_service.rb @@ -44,7 +44,7 @@ def create_person :given_name => info.first_name, :family_name => info.last_name, :locale => I18n.locale, - :test_group_number => 1 + rand(4), + :test_group_number => rand(1..4), :password => Devise.friendly_token[0,20], community_id: community.id } @@ -169,11 +169,13 @@ def initialize(community:, provider:, uid:, email:) def person return @person if defined?(@person) + @person = person_by_uid || person_by_email || person_is_admin_by_uid || person_is_admin_by_email end def person_email_unconfirmed return @person_email_unconfirmed if defined?(@person_email_unconfirmed) + @person_email_unconfirmed = members.by_unconfirmed_email(email).first end diff --git a/app/services/person/settings_service.rb b/app/services/person/settings_service.rb index e8c45d7734..86d91dba2f 100644 --- a/app/services/person/settings_service.rb +++ b/app/services/person/settings_service.rb @@ -36,7 +36,7 @@ def has_person_custom_fields? end def new_person - @person ||= if params[:person] + @person ||= if params[:person] # rubocop:disable Naming/MemoizedInstanceVariableName Person.new(params[:person].slice(:given_name, :family_name, :email, :username).permit!) else Person.new() diff --git a/app/services/person/show_service.rb b/app/services/person/show_service.rb index 5ee78d9a5d..e2a56cfb0a 100644 --- a/app/services/person/show_service.rb +++ b/app/services/person/show_service.rb @@ -9,6 +9,7 @@ def initialize(community:, params:, current_user:) def person return @person if defined?(@person) + person = Person.find_by!(username: params[:username], community_id: community.id) @person = person.deleted? || person.banned? ? nil : person end @@ -39,6 +40,7 @@ def followed_people def listings return @listings if defined?(@listings) + include_closed = current_user == person && params[:show_closed] search = { author_id: person.id, @@ -71,11 +73,11 @@ def listings end def admin? - current_user && current_user.has_admin_rights?(community) + current_user&.has_admin_rights?(community) end def can_post_listing? - membership = person && person.community_membership + membership = person&.community_membership if membership if community.require_verification_to_post_listings membership.accepted? && membership.can_post_listings diff --git a/app/services/policy/listing_policy.rb b/app/services/policy/listing_policy.rb index c2cca2d749..37018afe31 100644 --- a/app/services/policy/listing_policy.rb +++ b/app/services/policy/listing_policy.rb @@ -56,6 +56,6 @@ def is_author? end def is_admin? - user && user.has_admin_rights?(community) + user&.has_admin_rights?(community) end end diff --git a/app/services/seo_service.rb b/app/services/seo_service.rb index 0818d172a0..17bf3e6296 100644 --- a/app/services/seo_service.rb +++ b/app/services/seo_service.rb @@ -57,6 +57,7 @@ def placeholder(section, locale = I18n.locale) def title(default_value, extra_mode = nil, locale = I18n.locale) return @title if defined?(@title) + @locale = locale custom_value = if mode == 'default' && extra_mode == :social @@ -72,6 +73,7 @@ def title(default_value, extra_mode = nil, locale = I18n.locale) def description(default_value, extra_mode = nil, locale = I18n.locale) return @description if defined?(@description) + @locale = locale custom_value = if mode == 'default' && extra_mode == :social @@ -153,7 +155,7 @@ def eval_single(variable, locale = I18n.locale) when 'listing_author' @listing ? PersonViewUtils.person_display_name(@listing.author, @community) : nil when 'listing_price' - if @listing && @listing.price + if @listing&.price if @listing.unit_type [ MoneyViewUtils.to_humanized(@listing.price), @@ -224,6 +226,6 @@ def customization_description(mode) def customization_value_or_default(feature) value = customization.send(feature) - value.present? ? value : placeholder(feature, locale) + value.presence || placeholder(feature, locale) end end diff --git a/app/services/stripe_service/api/accounts.rb b/app/services/stripe_service/api/accounts.rb index 997bae86a6..c437b6bd73 100644 --- a/app/services/stripe_service/api/accounts.rb +++ b/app/services/stripe_service/api/accounts.rb @@ -14,7 +14,7 @@ def create(community_id:, person_id:, body:) result = stripe_api.register_seller(community: community_id, account_info: body, metadata: metadata) data = body.merge(stripe_seller_id: result.id, community_id: community_id, person_id: person_id) Result::Success.new(stripe_accounts_store.create(opts: data)) - rescue => e + rescue StandardError => e allow_stripe_exceptions(e) end @@ -23,14 +23,14 @@ def create_bank_account(community_id:, person_id:, body:) result = stripe_api.create_bank_account(community: community_id, account_info: account.merge(body)) data = body.merge(stripe_bank_id: result.id) Result::Success.new(stripe_accounts_store.update_bank_account(community_id: community_id, person_id: person_id, opts: data)) - rescue => e + rescue StandardError => e allow_stripe_exceptions(e) end def create_customer(community_id:, person_id:, body:) data = { community_id: community_id, person_id: person_id} Result::Success.new(stripe_accounts_store.create_customer(opts: data)) - rescue => e + rescue StandardError => e allow_stripe_exceptions(e) end @@ -38,13 +38,13 @@ def update_account(community_id:, person_id:, attrs:) account = stripe_accounts_store.get(person_id: person_id, community_id: community_id).to_hash stripe_api.update_account(community: community_id, account_id: account[:stripe_seller_id], attrs: attrs) Result::Success.new(account) - rescue => e + rescue StandardError => e allow_stripe_exceptions(e) end def update_field(community_id:, person_id:, field:, value:) Result::Success.new(stripe_accounts_store.update_field(community_id: community_id, person_id: person_id, field: field, value: value)) - rescue => e + rescue StandardError => e allow_stripe_exceptions(e) end @@ -52,13 +52,13 @@ def send_verification(community_id:, person_id:, personal_id_number:, file:) account = stripe_accounts_store.get(community_id: community_id, person_id: person_id) stripe_api.send_verification(community: community_id, account_id: account[:stripe_seller_id], personal_id_number: personal_id_number, file_path: file) Result::Success.new(account) - rescue => e + rescue StandardError => e allow_stripe_exceptions(e) end def destroy(community_id:, person_id:) Result::Success.new(stripe_accounts_store.destroy(community_id: community_id, person_id: person_id)) - rescue => e + rescue StandardError => e allow_stripe_exceptions(e) end @@ -71,7 +71,7 @@ def delete_seller_account(community_id:, person_id: nil) else Result::Success.new() end - rescue => e + rescue StandardError => e allow_stripe_exceptions(e) end diff --git a/app/services/stripe_service/api/payments.rb b/app/services/stripe_service/api/payments.rb index 1c1f1951a3..54af029cf1 100644 --- a/app/services/stripe_service/api/payments.rb +++ b/app/services/stripe_service/api/payments.rb @@ -60,7 +60,7 @@ def create_preauth_payment(tx, gateway_fields) report.create_charge_success Result::Success.new(payment) - rescue => exception + rescue StandardError => exception params_to_airbrake = StripeService::Report.new(tx: tx, exception: exception).create_charge_failed exception.extend ParamsToAirbrake exception.params_to_airbrake = {stripe: params_to_airbrake} @@ -80,7 +80,7 @@ def cancel_preauth(tx, reason) ) payment = PaymentStore.update(transaction_id: tx.id, community_id: tx.community_id, data: {status: 'canceled'}) Result::Success.new(payment) - rescue => e + rescue StandardError => e Airbrake.notify(e) Result::Error.new(e.message) end @@ -100,7 +100,7 @@ def capture(tx) }) report.capture_charge_success Result::Success.new(payment) - rescue => exception + rescue StandardError => exception params_to_airbrake = StripeService::Report.new(tx: tx, exception: exception).capture_charge_failed exception.extend ParamsToAirbrake exception.params_to_airbrake = {stripe: params_to_airbrake} @@ -120,7 +120,7 @@ def payment_details(tx) commission: commission, real_fee: fee, subtotal: total - fee, - buyer_commission: buyer_commission, + buyer_commission: buyer_commission } end @@ -132,11 +132,11 @@ def payment_details(tx) payment[:real_fee] end { - payment_total: payment[:sum], - total_price: payment[:subtotal], - charged_commission: payment[:commission], + payment_total: payment[:sum], + total_price: payment[:subtotal], + charged_commission: payment[:commission], payment_gateway_fee: gateway_fee, - buyer_commission: payment[:buyer_commission] || 0 + buyer_commission: payment[:buyer_commission] || 0 } end diff --git a/app/services/stripe_service/api/stripe_api_wrapper.rb b/app/services/stripe_service/api/stripe_api_wrapper.rb index 8326ddaeab..16cc912463 100644 --- a/app/services/stripe_service/api/stripe_api_wrapper.rb +++ b/app/services/stripe_service/api/stripe_api_wrapper.rb @@ -1,8 +1,7 @@ class StripeService::API::StripeApiWrapper class << self - # rubocop:disable ClassVars - @@mutex ||= Mutex.new + @@mutex ||= Mutex.new # rubocop:disable ClassVars def payment_settings_for(community) PaymentSettings.where(community_id: community, payment_gateway: :stripe, payment_process: :preauthorize).first @@ -122,7 +121,7 @@ def register_seller(community:, account_info:, metadata: {}) type: 'custom', country: account_info[:address_country], email: account_info[:email], - account_token: account_info[:token], + account_token: account_info[:token] } if account_info[:address_country] == 'US' data[:requested_capabilities] = ['card_payments'] @@ -140,7 +139,7 @@ def check_balance(community:) with_stripe_payment_config(community) do |payment_settings| Stripe::Balance.retrieve end - rescue + rescue StandardError nil end @@ -152,8 +151,8 @@ def create_bank_account(community:, account_info:) external_account: { object: 'bank_account', account_number: account_info[:bank_account_number], - currency: account_info[:bank_currency], - country: account_info[:bank_country], + currency: account_info[:bank_currency], + country: account_info[:bank_country], account_holder_name: account_info[:bank_holder_name], account_holder_type: 'individual' }.merge(routing), @@ -272,7 +271,7 @@ def update_account(community:, account_id:, attrs:) end def empty_string_as_nil(value) - value.present? ? value : nil + value.presence end def get_charge(community:, charge_id:) diff --git a/app/services/stripe_service/report.rb b/app/services/stripe_service/report.rb index 65e6a25853..54fce3d1bb 100644 --- a/app/services/stripe_service/report.rb +++ b/app/services/stripe_service/report.rb @@ -13,7 +13,7 @@ def initialize(tx:, exception: nil) def capture_charge_start result = capture_charge.merge({ - "event": "stripe_call", + "event": "stripe_call" }) logger.info('capture_charge_start', nil, result) result @@ -39,7 +39,7 @@ def capture_charge_failed def create_charge_start result = create_charge.merge({ - "event": "stripe_call", + "event": "stripe_call" }) logger.info('create_charge_start', nil, result) result @@ -69,7 +69,7 @@ def create_charge_failed def create_payout_start result = create_payout.merge({ - "event": "stripe_call", + "event": "stripe_call" }) logger.info('create_payout_start', nil, result) result @@ -129,11 +129,13 @@ def create_payout def stripe_payment return @stripe_payment if defined?(@stripe_payment) + @stripe_payment = StripePayment.find_by(transaction_id: tx.id) end def stripe_account return @stripe_account if defined?(@stripe_account) + @stripe_account = StripeAccount.find_by(person: tx.author) end diff --git a/app/services/stripe_service/store/stripe_account.rb b/app/services/stripe_service/store/stripe_account.rb index 688d477623..5859afcb9c 100644 --- a/app/services/stripe_service/store/stripe_account.rb +++ b/app/services/stripe_service/store/stripe_account.rb @@ -8,7 +8,7 @@ module StripeService::Store::StripeAccount ALL_STRIPE_COUNTRIES = ["US", "GB", "AT", "BE", "CH", "DE", "DK", "ES", "FI", "FR", "IE", "IT", "LU", "NL", "NO", "PT", "SE", "CA", "SG", "HK", "JP", "BR", "MX", "AU", "NZ", "PR"] COUNTRIES = ALL_STRIPE_COUNTRIES & ::TransactionService::AvailableCurrencies::COUNTRY_SET_STRIPE_AND_PAYPAL - VALID_BANK_CURRENCIES = ["CHF", "DKK", "EUR", "GBP", "NOK", "SEK", "USD", "JPY", "AUD", "HKD", "SGD", "NZD", "BRL", "MXN", "CAD" ] + VALID_BANK_CURRENCIES = ["CHF", "DKK", "EUR", "GBP", "NOK", "SEK", "USD", "JPY", "AUD", "HKD", "SGD", "NZD", "BRL", "MXN", "CAD"] StripeAccountCreate = EntityUtils.define_builder( [:community_id, :mandatory, :fixnum], @@ -52,7 +52,7 @@ def create(opts:) entity = StripeAccountCreate.call(opts) account_model = StripeAccountModel.where(community_id: entity[:community_id], person_id: entity[:person_id]).first if account_model - account_model.update_attributes(entity) + account_model.update(entity) else account_model = StripeAccountModel.create!(entity) end @@ -67,18 +67,18 @@ def create_customer(opts:) def update_bank_account(community_id:, person_id:, opts:) find_params = { community_id: community_id, - person_id: person_id, + person_id: person_id } model = StripeAccountModel.where(find_params).first entity = StripeBankAccount.call(opts) - model.update_attributes(entity) + model.update(entity) from_model(model) end def update_field(community_id:, person_id:, field:, value:) find_params = { community_id: community_id, - person_id: person_id, + person_id: person_id } model = StripeAccountModel.where(find_params).first model.update(field => value) diff --git a/app/services/stripe_service/store/stripe_payment.rb b/app/services/stripe_service/store/stripe_payment.rb index 6cf1e87ad0..bb722d6d2d 100644 --- a/app/services/stripe_service/store/stripe_payment.rb +++ b/app/services/stripe_service/store/stripe_payment.rb @@ -70,7 +70,7 @@ def from_model(stripe_payment) commission: stripe_payment.commission, buyer_commission: stripe_payment.buyer_commission, subtotal: stripe_payment.subtotal, - real_fee: stripe_payment.real_fee, + real_fee: stripe_payment.real_fee })) StripePayment.call(hash) end @@ -88,7 +88,7 @@ def data_changed?(old_data, new_data) end def update_payment!(payment, data) - payment.update_attributes!(data) + payment.update!(data) from_model(payment.reload) end end diff --git a/app/services/transaction_service/available_currencies.rb b/app/services/transaction_service/available_currencies.rb index dd4c4ce946..56e0560416 100644 --- a/app/services/transaction_service/available_currencies.rb +++ b/app/services/transaction_service/available_currencies.rb @@ -124,7 +124,7 @@ module TransactionService::AvailableCurrencies "SGD" => :country_sets, "THB" => :country_sets, "TWD" => :country_sets, - "USD" => :country_sets, + "USD" => :country_sets } module_function diff --git a/app/services/transaction_service/order.rb b/app/services/transaction_service/order.rb index 85774a27ca..9f205d2200 100644 --- a/app/services/transaction_service/order.rb +++ b/app/services/transaction_service/order.rb @@ -10,10 +10,10 @@ def initialize(community:, tx_params:, listing:) def price_break_down_locals { - booking: is_booking?, + booking: is_booking?, quantity: quantity, start_on: tx_params[:start_on], - end_on: tx_params[:end_on], + end_on: tx_params[:end_on], duration: quantity, listing_price: listing.price, localized_unit_type: translate_unit_from_listing, @@ -23,8 +23,8 @@ def price_break_down_locals total: order_total, unit_type: listing.unit_type, start_time: tx_params[:start_time], - end_time: tx_params[:end_time], - per_hour: tx_params[:per_hour], + end_time: tx_params[:end_time], + per_hour: tx_params[:per_hour], buyer_fee: buyer_fee, paypal_in_use: paypal_in_use, stripe_in_use: stripe_in_use, @@ -53,6 +53,7 @@ def shipping_total def buyer_fee return @buyer_fee if defined?(@buyer_fee) + if stripe_in_use && !paypal_in_use commission = stripe_tx_settings[:commission_from_buyer] || 0 minimum_fee_cents = stripe_tx_settings[:minimum_buyer_transaction_fee_cents] || 0 diff --git a/app/services/transaction_service/process/preauthorize.rb b/app/services/transaction_service/process/preauthorize.rb index 04e75dc90f..3e76b9bed6 100644 --- a/app/services/transaction_service/process/preauthorize.rb +++ b/app/services/transaction_service/process/preauthorize.rb @@ -1,4 +1,3 @@ -# coding: utf-8 module TransactionService::Process Gateway = TransactionService::Gateway Worker = TransactionService::Worker diff --git a/app/services/transaction_service/store/payment_settings.rb b/app/services/transaction_service/store/payment_settings.rb index fd8c275b4f..4fa4898f1f 100644 --- a/app/services/transaction_service/store/payment_settings.rb +++ b/app/services/transaction_service/store/payment_settings.rb @@ -82,7 +82,7 @@ def update(opts) raise ArgumentError.new("Cannot find settings to update: cid: #{opts[:community_id]}, gateway: #{opts[:payment_gateway]}, process: #{opts[:payment_process]}") if model.nil? clean_or_encrypt_api_keys(model, settings) - model.update_attributes!(settings) + model.update!(settings) from_model(model) end @@ -107,21 +107,24 @@ def get_all_active(community_id:) def activate(community_id:, payment_gateway:, payment_process:) model = find(community_id, payment_gateway, payment_process) raise ArgumentError.new("Cannot find settings to activate: cid: #{community_id}, gateway: #{payment_gateway}, process: #{payment_process}") if model.nil? - model.update_attributes!(active: true) unless model.active + + model.update!(active: true) unless model.active from_model(model) end def api_verified(community_id:, payment_gateway:, payment_process:) model = find(community_id, payment_gateway, payment_process) raise ArgumentError.new("Cannot find settings to activate: cid: #{community_id}, gateway: #{payment_gateway}, process: #{payment_process}") if model.nil? - model.update_attributes!(api_verified: true) + + model.update!(api_verified: true) from_model(model) end def disable(community_id:, payment_gateway:, payment_process:) model = find(community_id, payment_gateway, payment_process) raise ArgumentError.new("Cannot find settings to disable: cid: #{community_id}, gateway: #{payment_gateway}, process: #{payment_process}") if model.nil? - model.update_attributes!(active: false) + + model.update!(active: false) from_model(model) end @@ -133,7 +136,8 @@ def from_model(model) .map { |hash| PaymentSettings.call(hash.merge({ commission_type: commission_type(hash) - })) } + })) + } .or_else(nil) end @@ -173,6 +177,7 @@ def encrypt_api_keys(settings) def encrypt_value(value, padding) raise "can not encrypt Stripe keys, add app_encryption_key to config/config.yml" if APP_CONFIG.app_encryption_key.nil? + cipher = OpenSSL::Cipher.new('AES-256-CBC') cipher.encrypt cipher.key = Digest::SHA256.digest(APP_CONFIG.app_encryption_key) diff --git a/app/services/transaction_service/store/process_token.rb b/app/services/transaction_service/store/process_token.rb index 5b934cebcb..03f9974311 100644 --- a/app/services/transaction_service/store/process_token.rb +++ b/app/services/transaction_service/store/process_token.rb @@ -26,7 +26,7 @@ def create(community_id:, transaction_id:, op_name:, op_input: []) def update_to_completed(process_token:, op_output:) by_process_token(process_token).first! - .update_attributes(op_completed: true, op_output: YAML.dump(op_output)) + .update(op_completed: true, op_output: YAML.dump(op_output)) end def get_by_transaction(community_id:, transaction_id:, op_name:) diff --git a/app/services/transaction_service/store/transaction.rb b/app/services/transaction_service/store/transaction.rb index e648e2d7f3..f495c17366 100644 --- a/app/services/transaction_service/store/transaction.rb +++ b/app/services/transaction_service/store/transaction.rb @@ -64,7 +64,7 @@ def upsert_shipping_address(community_id:, transaction_id:, addr:) if addr.is_a?(ActionController::Parameters) addr = addr.permit(:name, :street1, :street2, :postal_code, :city, :country_code, :state_or_province) end - address.update_attributes!(addr) + address.update!(addr) end end @@ -83,7 +83,7 @@ def update_booking_uuid(community_id:, transaction_id:, booking_uuid:) tx_model = TransactionModel.where(community_id: community_id, id: transaction_id).first if tx_model - tx_model.update_attributes(booking_uuid: UUIDUtils.raw(booking_uuid)) + tx_model.update(booking_uuid: UUIDUtils.raw(booking_uuid)) tx_model end end diff --git a/app/services/transaction_service/transaction.rb b/app/services/transaction_service/transaction.rb index 8700202dd2..e7630e31ab 100644 --- a/app/services/transaction_service/transaction.rb +++ b/app/services/transaction_service/transaction.rb @@ -20,7 +20,7 @@ class IllegalTransactionStateException < Exception GATEWAY_ADAPTERS = { paypal: TransactionService::Gateway::PaypalAdapter.new, stripe: TransactionService::Gateway::StripeAdapter.new, - none: TransactionService::Gateway::FreeAdapter.new, + none: TransactionService::Gateway::FreeAdapter.new } TX_PROCESSES = { diff --git a/app/services/transaction_service/validation.rb b/app/services/transaction_service/validation.rb index 3070456c01..c28101e279 100644 --- a/app/services/transaction_service/validation.rb +++ b/app/services/transaction_service/validation.rb @@ -3,6 +3,7 @@ module Validation IS_POSITIVE = ->(v) { return if v.nil? + unless v.positive? {code: :positive_integer, msg: "Value must be a positive integer"} end @@ -10,6 +11,7 @@ module Validation PARSE_DATE = ->(v) { return if v.nil? + begin TransactionViewUtils.parse_booking_date(v) rescue ArgumentError => e @@ -22,6 +24,7 @@ module Validation PARSE_DATETIME = ->(v) { return if v.nil? + begin TransactionViewUtils.parse_booking_datetime(v) rescue ArgumentError => e @@ -187,6 +190,7 @@ def validate_booking_timeslots(tx_params:, marketplace_uuid:, listing_uuid:, qua def validate_booking_per_hour_timeslots(listing:, tx_params:) return Result::Success.new(tx_params) unless tx_params[:per_hour] + booking = Booking.new(tx_params.slice(:start_time, :end_time, :per_hour)) if listing.working_hours_covers_booking?(booking) && listing.bookings.covers_another_booking(booking).empty? Result::Success.new(tx_params) diff --git a/app/services/transaction_type_creator.rb b/app/services/transaction_type_creator.rb index 65c237f5be..2c308384e8 100644 --- a/app/services/transaction_type_creator.rb +++ b/app/services/transaction_type_creator.rb @@ -82,68 +82,68 @@ class TransactionTypeCreator "Give" => { label: "Give", translation_key: "admin.transaction_types.give", - action_button_translation_key: "admin.transaction_types.default_action_button_labels.offer", + action_button_translation_key: "admin.transaction_types.default_action_button_labels.offer" }, "Inquiry" => { label: "Inquiry", translation_key: "admin.transaction_types.inquiry", - action_button_translation_key: "admin.transaction_types.default_action_button_labels.inquiry", + action_button_translation_key: "admin.transaction_types.default_action_button_labels.inquiry" }, "Lend" => { label: "Lend", translation_key: "admin.transaction_types.lend", - action_button_translation_key: "admin.transaction_types.default_action_button_labels.offer", + action_button_translation_key: "admin.transaction_types.default_action_button_labels.offer" }, "Rent" => { none: { label: "Rent", translation_key: "admin.transaction_types.rent_wo_online_payment", - action_button_translation_key: "admin.transaction_types.default_action_button_labels.rent", + action_button_translation_key: "admin.transaction_types.default_action_button_labels.rent" }, preauthorize: { label: "Rent", translation_key: "admin.transaction_types.rent_w_online_payment", - action_button_translation_key: "admin.transaction_types.default_action_button_labels.rent", - }, + action_button_translation_key: "admin.transaction_types.default_action_button_labels.rent" + } }, "Request" => { label: "Request", translation_key: "admin.transaction_types.request", - action_button_translation_key: "admin.transaction_types.default_action_button_labels.request", + action_button_translation_key: "admin.transaction_types.default_action_button_labels.request" }, "Sell" => { none: { label: "Sell", translation_key: "admin.transaction_types.sell_wo_online_payment", - action_button_translation_key: "admin.transaction_types.default_action_button_labels.sell", + action_button_translation_key: "admin.transaction_types.default_action_button_labels.sell" }, preauthorize: { label: "Sell", translation_key: "admin.transaction_types.sell_w_online_payment", - action_button_translation_key: "admin.transaction_types.default_action_button_labels.sell", - }, + action_button_translation_key: "admin.transaction_types.default_action_button_labels.sell" + } }, "Service" => { none: { label: "Service", translation_key: "admin.transaction_types.service_wo_online_payment", - action_button_translation_key: "admin.transaction_types.default_action_button_labels.offer", + action_button_translation_key: "admin.transaction_types.default_action_button_labels.offer" }, preauthorize: { label: "Service", translation_key: "admin.transaction_types.service_w_online_payment", - action_button_translation_key: "admin.transaction_types.default_action_button_labels.offer", - }, + action_button_translation_key: "admin.transaction_types.default_action_button_labels.offer" + } }, "ShareForFree" => { label: "Share for free", translation_key: "admin.transaction_types.share_for_free", - action_button_translation_key: "admin.transaction_types.default_action_button_labels.offer", + action_button_translation_key: "admin.transaction_types.default_action_button_labels.offer" }, "Swap" => { label: "Swap", translation_key: "admin.transaction_types.swap", - action_button_translation_key: "admin.transaction_types.default_action_button_labels.offer", + action_button_translation_key: "admin.transaction_types.default_action_button_labels.offer" } } @@ -153,7 +153,7 @@ class << self def create(community, marketplace_type) transaction_type = select_listing_shape_template(marketplace_type) enable_shipping = marketplace_type.or_else("product") == "product" - throw "Transaction type '#{transaction_type}' not available. Available types are: #{DEFAULTS.keys.join(', ')}" unless DEFAULTS.keys.include? transaction_type + throw "Transaction type '#{transaction_type}' not available. Available types are: #{DEFAULTS.keys.join(', ')}" unless DEFAULTS.key?(transaction_type) author_is_seller = transaction_type != "Request" transaction_processes = TransactionProcess.where(community_id: community.id, author_is_seller: author_is_seller) diff --git a/app/services/translation_service/store/translation.rb b/app/services/translation_service/store/translation.rb index ba1435a116..7c633b7f45 100644 --- a/app/services/translation_service/store/translation.rb +++ b/app/services/translation_service/store/translation.rb @@ -7,8 +7,6 @@ module TranslationService::Store::Translation [:locale, :mandatory, :string], [:translation]) - module_function - class CachedTranslationStore # Create translations @@ -145,15 +143,11 @@ def get_search_hash(community_id, translation_keys, locales) def fill_in_delta(translations_hash, translation_keys, locales, fallback_locale) keys = - if translation_keys.present? - translation_keys - else - translations_hash + translation_keys.presence || translations_hash .map { |translation| translation[:translation_key] } .uniq - end results = [] keys.each { |key| diff --git a/app/services/user_service/api/auth_tokens.rb b/app/services/user_service/api/auth_tokens.rb index 88c750c67a..da7633de90 100644 --- a/app/services/user_service/api/auth_tokens.rb +++ b/app/services/user_service/api/auth_tokens.rb @@ -11,6 +11,7 @@ def create_login_token(user_id) def use_token_for_login(token_string) return nil if token_string.blank? + if t = AuthToken.where(token: token_string).first t.last_use_attempt = Time.now # record the usage attempt if t.expires_at > Time.now && t.usages_left > 0 && t.token_type == "login" diff --git a/app/services/user_service/api/users.rb b/app/services/user_service/api/users.rb index 72547543ce..f3ba282f60 100644 --- a/app/services/user_service/api/users.rb +++ b/app/services/user_service/api/users.rb @@ -19,7 +19,7 @@ def create_user(user_hash, community_id, invitation_id = nil) password: user_hash[:password], username: username, locale: locale, - test_group_number: 1 + rand(4), + test_group_number: rand(1..4), community_id: community_id) email = Email.new(person: person, address: user_hash[:email].downcase, send_notifications: true, community_id: community_id) @@ -48,7 +48,7 @@ def create_user(user_hash, community_id, invitation_id = nil) Result::Success.new(user) end - rescue + rescue StandardError Result::Error.new("Failed to create a new user") end end @@ -118,6 +118,7 @@ def fetch_taken_usernames(base, community_id) def gen_free_name(base, reserved) (1..100000).reduce([base, ""]) do |(base_name, postfix), next_postfix| return (base_name + postfix) unless reserved.include?(base_name + postfix) || (base_name + postfix).length < 3 + [base_name, next_postfix.to_s] end end diff --git a/app/utils/entity_utils.rb b/app/utils/entity_utils.rb index 990cb7ba71..2104fbd8a4 100644 --- a/app/utils/entity_utils.rb +++ b/app/utils/entity_utils.rb @@ -32,6 +32,7 @@ def define_entity(*ks) # Turn active record model into a hash with string keys replaced with symbols def model_to_hash(model) return {} if model.nil? + HashUtils.symbolize_keys(model.attributes) end @@ -189,9 +190,9 @@ def model_to_hash(model) } def spec_category(k) - if VALIDATORS.keys.include?(k) + if VALIDATORS.key?(k) :validators - elsif TRANSFORMERS.keys.include?(k) + elsif TRANSFORMERS.key?(k) :transformers elsif k == :collection :collection @@ -235,6 +236,7 @@ def parse_specs(specs) specs.reduce({}) do |fs, full_field_spec| f_name, *spec = *full_field_spec raise ArgumentError.new("Field key must be a Symbol, was: '#{f_name}' (#{f_name.class.name})") unless f_name.is_a? Symbol + fs[f_name] = parse_spec(spec) fs end @@ -415,6 +417,7 @@ def with_result(specs:, data:, on_success:, on_failure:) data = data.to_unsafe_hash end raise(TypeError, "Expecting an input hash. You gave: #{data}") unless data.is_a? Hash + result = EntityUtils.transform_and_validate(specs, data) if result[:errors].empty? diff --git a/app/utils/json_utils.rb b/app/utils/json_utils.rb index 3bb852bcdb..81d5cbe31c 100644 --- a/app/utils/json_utils.rb +++ b/app/utils/json_utils.rb @@ -34,6 +34,6 @@ def collection_type(v) end def should_traverse?(type) - type == Hash || type == Array + [Hash, Array].include?(type) end end diff --git a/app/utils/marketplace_router.rb b/app/utils/marketplace_router.rb index af95959d2b..e7c1e8f878 100644 --- a/app/utils/marketplace_router.rb +++ b/app/utils/marketplace_router.rb @@ -51,15 +51,11 @@ module DataTypes :www_ident, # Accessed marketplace with WWW and subdomain, e.g. www.mymarketplace.sharetribe.com :hold, # Marketplace plan is on hold ]], - # Url [:url, :string, :optional], - # Named route [:route_name, :symbol, :optional], - [:status, :symbol, :mandatory], - # detailed error message to be rendered [:message, :optional] ) @@ -92,21 +88,21 @@ def create_other(opts) title: "Whoops, the %{community_name} marketplace no longer exists!", description: "Unfortunately the %{community_name} team has decided to close this platform, and it is no longer available.", cta: "Create your own online marketplace", - cta_url: "https://www.sharetribe.com/?utm_source=%{marketplace_ident}.sharetribe.com&utm_medium=redirect&utm_campaign=qc-manual-redirect", + cta_url: "https://www.sharetribe.com/?utm_source=%{marketplace_ident}.sharetribe.com&utm_medium=redirect&utm_campaign=qc-manual-redirect" }, deleted: { title: "Whoops, the %{community_name} marketplace no longer exists!", description: "Unfortunately the %{community_name} team has decided to close this platform, and it is no longer available.", cta: "Create your own online marketplace", - cta_url: "https://www.sharetribe.com/?utm_source=%{marketplace_ident}.sharetribe.com&utm_medium=redirect&utm_campaign=dl-manual-redirect", + cta_url: "https://www.sharetribe.com/?utm_source=%{marketplace_ident}.sharetribe.com&utm_medium=redirect&utm_campaign=dl-manual-redirect" }, hold: { title: "The %{community_name} marketplace is on hold.", description: "The %{community_name} team has decided to pause things and they will reopen this platform in the future", use_marketplace_logo: true - }, + } } module_function @@ -243,19 +239,19 @@ def perform_redirect(community:, plan:, request:, &block) } configs = { - app_domain: URLUtils.strip_port_from_host(APP_CONFIG.domain), + app_domain: URLUtils.strip_port_from_host(APP_CONFIG.domain) } reason = request.env[:redirect_reason] if reason target = MarketplaceRouter.redirect_target( - reason: reason, - request: MarketplaceRouter.request_hash(request), + reason: reason, + request: MarketplaceRouter.request_hash(request), community: MarketplaceRouter.community_hash(community, plan), - paths: paths, - configs: configs, - message: MarketplaceRouter.make_error_message(community, reason) + paths: paths, + configs: configs, + message: MarketplaceRouter.make_error_message(community, reason) ) block.call(target) @@ -272,7 +268,7 @@ def request_hash(request) host: request.host, protocol: (request.respond_to?(:protocol) ? request.protocol : "#{request.scheme}://"), fullpath: request.fullpath, - port_string: (request.respond_to?(:port_string) ? request.port_string : ":#{request.port}"), + port_string: (request.respond_to?(:port_string) ? request.port_string : ":#{request.port}") } end @@ -288,7 +284,7 @@ def community_hash(community, plan) deleted: c.deleted?, use_domain: c.use_domain?, closed: Maybe(plan)[:closed].or_else(false), - hold: Maybe(plan)[:hold].or_else(false), + hold: Maybe(plan)[:hold].or_else(false) } }.or_else(nil) end @@ -300,7 +296,7 @@ def make_error_message(community, reason) community_name = begin community.name(community.default_locale) - rescue + rescue StandardError ident end diff --git a/app/utils/mcc_codes.rb b/app/utils/mcc_codes.rb index 74b95bfb05..9b505a3904 100644 --- a/app/utils/mcc_codes.rb +++ b/app/utils/mcc_codes.rb @@ -1,325 +1,325 @@ module MccCodes CODES = - [ {:decription=>"A/C, Refrigeration Repair", :mcc=>"7623"}, - {:decription=>"Accounting/Bookkeeping Services", :mcc=>"8931"}, - {:decription=>"Advertising Services", :mcc=>"7311"}, - {:decription=>"Agricultural Cooperative", :mcc=>"0763"}, - {:decription=>"Airlines, Air Carriers", :mcc=>"4511"}, - {:decription=>"Airports, Flying Fields", :mcc=>"4582"}, - {:decription=>"Ambulance Services", :mcc=>"4119"}, - {:decription=>"Amusement Parks/Carnivals", :mcc=>"7996"}, - {:decription=>"Antique Reproductions", :mcc=>"5937"}, - {:decription=>"Antique Shops", :mcc=>"5932"}, - {:decription=>"Aquariums", :mcc=>"7998"}, - {:decription=>"Architectural/Surveying Services", :mcc=>"8911"}, - {:decription=>"Art Dealers and Galleries", :mcc=>"5971"}, - {:decription=>"Artists Supply and Craft Shops", :mcc=>"5970"}, - {:decription=>"Auto Body Repair Shops", :mcc=>"7531"}, - {:decription=>"Auto Paint Shops", :mcc=>"7535"}, - {:decription=>"Auto Service Shops", :mcc=>"7538"}, - {:decription=>"Auto and Home Supply Stores", :mcc=>"5531"}, - {:decription=>"Automated Cash Disburse", :mcc=>"6011"}, - {:decription=>"Automated Fuel Dispensers", :mcc=>"5542"}, - {:decription=>"Automobile Associations", :mcc=>"8675"}, - {:decription=>"Automotive Parts and Accessories Stores", :mcc=>"5533"}, - {:decription=>"Automotive Tire Stores", :mcc=>"5532"}, - {:decription=> - "Bail and Bond Payments (payment to the surety for the bond, not the actual bond paid to the government agency)", - :mcc=>"9223"}, - {:decription=>"Bakeries", :mcc=>"5462"}, - {:decription=>"Bands, Orchestras", :mcc=>"7929"}, - {:decription=>"Barber and Beauty Shops", :mcc=>"7230"}, - {:decription=>"Betting/Casino Gambling", :mcc=>"7995"}, - {:decription=>"Bicycle Shops", :mcc=>"5940"}, - {:decription=>"Billiard/Pool Establishments", :mcc=>"7932"}, - {:decription=>"Boat Dealers", :mcc=>"5551"}, - {:decription=>"Boat Rentals and Leases", :mcc=>"4457"}, - {:decription=>"Book Stores", :mcc=>"5942"}, - {:decription=>"Books, Periodicals, and Newspapers", :mcc=>"5192"}, - {:decription=>"Bowling Alleys", :mcc=>"7933"}, - {:decription=>"Bus Lines", :mcc=>"4131"}, - {:decription=>"Business/Secretarial Schools", :mcc=>"8244"}, - {:decription=>"Buying/Shopping Services", :mcc=>"7278"}, - {:decription=>"Cable, Satellite, and Other Pay Television and Radio", - :mcc=>"4899"}, - {:decription=>"Camera and Photographic Supply Stores", :mcc=>"5946"}, - {:decription=>"Candy, Nut, and Confectionery Stores", :mcc=>"5441"}, - {:decription=>"Car Rental Agencies", :mcc=>"7512"}, - {:decription=>"Car Washes", :mcc=>"7542"}, - {:decription=> - "Car and Truck Dealers (New & Used) Sales, Service, Repairs Parts and Leasing", - :mcc=>"5511"}, - {:decription=> - "Car and Truck Dealers (Used Only) Sales, Service, Repairs Parts and Leasing", - :mcc=>"5521"}, - {:decription=>"Carpentry Services", :mcc=>"1750"}, - {:decription=>"Carpet/Upholstery Cleaning", :mcc=>"7217"}, - {:decription=>"Caterers", :mcc=>"5811"}, - {:decription=>"Charitable and Social Service Organizations - Fundraising", - :mcc=>"8398"}, - {:decription=>"Chemicals and Allied Products (Not Elsewhere Classified)", - :mcc=>"5169"}, - {:decription=>"Chidrens and Infants Wear Stores", :mcc=>"5641"}, - {:decription=>"Child Care Services", :mcc=>"8351"}, - {:decription=>"Chiropodists, Podiatrists", :mcc=>"8049"}, - {:decription=>"Chiropractors", :mcc=>"8041"}, - {:decription=>"Cigar Stores and Stands", :mcc=>"5993"}, - {:decription=>"Civic, Social, Fraternal Associations", :mcc=>"8641"}, - {:decription=>"Cleaning and Maintenance", :mcc=>"7349"}, - {:decription=>"Clothing Rental", :mcc=>"7296"}, - {:decription=>"Colleges, Universities", :mcc=>"8220"}, - {:decription=>"Commercial Equipment (Not Elsewhere Classified)", - :mcc=>"5046"}, - {:decription=>"Commercial Footwear", :mcc=>"5139"}, - {:decription=>"Commercial Photography, Art and Graphics", :mcc=>"7333"}, - {:decription=>"Commuter Transport, Ferries", :mcc=>"4111"}, - {:decription=>"Computer Network Services", :mcc=>"4816"}, - {:decription=>"Computer Programming", :mcc=>"7372"}, - {:decription=>"Computer Repair", :mcc=>"7379"}, - {:decription=>"Computer Software Stores", :mcc=>"5734"}, - {:decription=>"Computers, Peripherals, and Software", :mcc=>"5045"}, - {:decription=>"Concrete Work Services", :mcc=>"1771"}, - {:decription=>"Construction Materials (Not Elsewhere Classified)", - :mcc=>"5039"}, - {:decription=>"Consulting, Public Relations", :mcc=>"7392"}, - {:decription=>"Correspondence Schools", :mcc=>"8241"}, - {:decription=>"Cosmetic Stores", :mcc=>"5977"}, - {:decription=>"Counseling Services", :mcc=>"7277"}, - {:decription=>"Country Clubs", :mcc=>"7997"}, - {:decription=>"Courier Services", :mcc=>"4215"}, - {:decription=> - "Court Costs, Including Alimony and Child Support - Courts of Law", - :mcc=>"9211"}, - {:decription=>"Credit Reporting Agencies", :mcc=>"7321"}, - {:decription=>"Cruise Lines", :mcc=>"4411"}, - {:decription=>"Dairy Products Stores", :mcc=>"5451"}, - {:decription=>"Dance Hall, Studios, Schools", :mcc=>"7911"}, - {:decription=>"Dating/Escort Services", :mcc=>"7273"}, - {:decription=>"Dentists, Orthodontists", :mcc=>"8021"}, - {:decription=>"Department Stores", :mcc=>"5311"}, - {:decription=>"Detective Agencies", :mcc=>"7393"}, - {:decription=>"Direct Marketing - Catalog Merchant", :mcc=>"5964"}, - {:decription=>"Direct Marketing - Combination Catalog and Retail Merchant", - :mcc=>"5965"}, - {:decription=>"Direct Marketing - Inbound Telemarketing", :mcc=>"5967"}, - {:decription=>"Direct Marketing - Insurance Services", :mcc=>"5960"}, - {:decription=>"Direct Marketing - Other", :mcc=>"5969"}, - {:decription=>"Direct Marketing - Outbound Telemarketing", :mcc=>"5966"}, - {:decription=>"Direct Marketing - Subscription", :mcc=>"5968"}, - {:decription=>"Direct Marketing - Travel", :mcc=>"5962"}, - {:decription=>"Discount Stores", :mcc=>"5310"}, - {:decription=>"Doctors", :mcc=>"8011"}, - {:decription=>"Door-To-Door Sales", :mcc=>"5963"}, - {:decription=>"Drapery, Window Covering, and Upholstery Stores", - :mcc=>"5714"}, - {:decription=>"Drinking Places", :mcc=>"5813"}, - {:decription=>"Drug Stores and Pharmacies", :mcc=>"5912"}, - {:decription=>"Drugs, Drug Proprietaries, and Druggist Sundries", - :mcc=>"5122"}, - {:decription=>"Dry Cleaners", :mcc=>"7216"}, - {:decription=>"Durable Goods (Not Elsewhere Classified)", :mcc=>"5099"}, - {:decription=>"Duty Free Stores", :mcc=>"5309"}, - {:decription=>"Eating Places, Restaurants", :mcc=>"5812"}, - {:decription=>"Educational Services", :mcc=>"8299"}, - {:decription=>"Electric Razor Stores", :mcc=>"5997"}, - {:decription=>"Electrical Parts and Equipment", :mcc=>"5065"}, - {:decription=>"Electrical Services", :mcc=>"1731"}, - {:decription=>"Electronics Repair Shops", :mcc=>"7622"}, - {:decription=>"Electronics Stores", :mcc=>"5732"}, - {:decription=>"Elementary, Secondary Schools", :mcc=>"8211"}, - {:decription=>"Employment/Temp Agencies", :mcc=>"7361"}, - {:decription=>"Equipment Rental", :mcc=>"7394"}, - {:decription=>"Exterminating Services", :mcc=>"7342"}, - {:decription=>"Family Clothing Stores", :mcc=>"5651"}, - {:decription=>"Fast Food Restaurants", :mcc=>"5814"}, - {:decription=>"Financial Institutions", :mcc=>"6012"}, - {:decription=>"Fines - Government Administrative Entities", :mcc=>"9222"}, - {:decription=>"Fireplace, Fireplace Screens, and Accessories Stores", - :mcc=>"5718"}, - {:decription=>"Floor Covering Stores", :mcc=>"5713"}, - {:decription=>"Florists", :mcc=>"5992"}, - {:decription=>"Florists Supplies, Nursery Stock, and Flowers", :mcc=>"5193"}, - {:decription=>"Freezer and Locker Meat Provisioners", :mcc=>"5422"}, - {:decription=>"Fuel Dealers (Non Automotive)", :mcc=>"5983"}, - {:decription=>"Funeral Services, Crematories", :mcc=>"7261"}, - {:decription=>"Furniture Repair, Refinishing", :mcc=>"7641"}, - {:decription=> - "Furniture, Home Furnishings, and Equipment Stores, Except Appliances", - :mcc=>"5712"}, - {:decription=>"Furriers and Fur Shops", :mcc=>"5681"}, - {:decription=>"General Services", :mcc=>"1520"}, - {:decription=>"Gift, Card, Novelty, and Souvenir Shops", :mcc=>"5947"}, - {:decription=>"Glass, Paint, and Wallpaper Stores", :mcc=>"5231"}, - {:decription=>"Glassware, Crystal Stores", :mcc=>"5950"}, - {:decription=>"Golf Courses - Public", :mcc=>"7992"}, - {:decription=>"Government Services (Not Elsewhere Classified)", :mcc=>"9399"}, - {:decription=>"Grocery Stores, Supermarkets", :mcc=>"5411"}, - {:decription=>"Hardware Stores", :mcc=>"5251"}, - {:decription=>"Hardware, Equipment, and Supplies", :mcc=>"5072"}, - {:decription=>"Health and Beauty Spas", :mcc=>"7298"}, - {:decription=>"Hearing Aids Sales and Supplies", :mcc=>"5975"}, - {:decription=>"Heating, Plumbing, A/C", :mcc=>"1711"}, - {:decription=>"Hobby, Toy, and Game Shops", :mcc=>"5945"}, - {:decription=>"Home Supply Warehouse Stores", :mcc=>"5200"}, - {:decription=>"Hospitals", :mcc=>"8062"}, - {:decription=>"Hotels, Motels, and Resorts", :mcc=>"7011"}, - {:decription=>"Household Appliance Stores", :mcc=>"5722"}, - {:decription=>"Industrial Supplies (Not Elsewhere Classified)", :mcc=>"5085"}, - {:decription=>"Information Retrieval Services", :mcc=>"7375"}, - {:decription=>"Insurance - Default", :mcc=>"6399"}, - {:decription=>"Insurance Underwriting, Premiums", :mcc=>"6300"}, - {:decription=>"Intra-Company Purchases", :mcc=>"9950"}, - {:decription=>"Jewelry Stores, Watches, Clocks, and Silverware Stores", - :mcc=>"5944"}, - {:decription=>"Landscaping Services", :mcc=>"0780"}, - {:decription=>"Laundries", :mcc=>"7211"}, - {:decription=>"Laundry, Cleaning Services", :mcc=>"7210"}, - {:decription=>"Legal Services, Attorneys", :mcc=>"8111"}, - {:decription=>"Luggage and Leather Goods Stores", :mcc=>"5948"}, - {:decription=>"Lumber, Building Materials Stores", :mcc=>"5211"}, - {:decription=>"Manual Cash Disburse", :mcc=>"6010"}, - {:decription=>"Marinas, Service and Supplies", :mcc=>"4468"}, - {:decription=>"Masonry, Stonework, and Plaster", :mcc=>"1740"}, - {:decription=>"Massage Parlors", :mcc=>"7297"}, - {:decription=>"Medical Services", :mcc=>"8099"}, - {:decription=>"Medical and Dental Labs", :mcc=>"8071"}, - {:decription=> - "Medical, Dental, Ophthalmic, and Hospital Equipment and Supplies", - :mcc=>"5047"}, - {:decription=>"Membership Organizations", :mcc=>"8699"}, - {:decription=>"Mens and Boys Clothing and Accessories Stores", :mcc=>"5611"}, - {:decription=>"Mens, Womens Clothing Stores", :mcc=>"5691"}, - {:decription=>"Metal Service Centers", :mcc=>"5051"}, - {:decription=>"Miscellaneous Apparel and Accessory Shops", :mcc=>"5699"}, - {:decription=>"Miscellaneous Auto Dealers", :mcc=>"5599"}, - {:decription=>"Miscellaneous Business Services", :mcc=>"7399"}, - {:decription=> - "Miscellaneous Food Stores - Convenience Stores and Specialty Markets", - :mcc=>"5499"}, - {:decription=>"Miscellaneous General Merchandise", :mcc=>"5399"}, - {:decription=>"Miscellaneous General Services", :mcc=>"7299"}, - {:decription=>"Miscellaneous Home Furnishing Specialty Stores", :mcc=>"5719"}, - {:decription=>"Miscellaneous Publishing and Printing", :mcc=>"2741"}, - {:decription=>"Miscellaneous Recreation Services", :mcc=>"7999"}, - {:decription=>"Miscellaneous Repair Shops", :mcc=>"7699"}, - {:decription=>"Miscellaneous Specialty Retail", :mcc=>"5999"}, - {:decription=>"Mobile Home Dealers", :mcc=>"5271"}, - {:decription=>"Motion Picture Theaters", :mcc=>"7832"}, - {:decription=> - "Motor Freight Carriers and Trucking - Local and Long Distance, Moving and Storage Companies, and Local Delivery Services", - :mcc=>"4214"}, - {:decription=>"Motor Homes Dealers", :mcc=>"5592"}, - {:decription=>"Motor Vehicle Supplies and New Parts", :mcc=>"5013"}, - {:decription=>"Motorcycle Shops and Dealers", :mcc=>"5571"}, - {:decription=>"Motorcycle Shops, Dealers", :mcc=>"5561"}, - {:decription=>"Music Stores-Musical Instruments, Pianos, and Sheet Music", - :mcc=>"5733"}, - {:decription=>"News Dealers and Newsstands", :mcc=>"5994"}, - {:decription=>"Non-FI, Money Orders", :mcc=>"6051"}, - {:decription=>"Non-FI, Stored Value Card Purchase/Load", :mcc=>"6540"}, - {:decription=>"Nondurable Goods (Not Elsewhere Classified)", :mcc=>"5199"}, - {:decription=>"Nurseries, Lawn and Garden Supply Stores", :mcc=>"5261"}, - {:decription=>"Nursing/Personal Care", :mcc=>"8050"}, - {:decription=>"Office and Commercial Furniture", :mcc=>"5021"}, - {:decription=>"Opticians, Eyeglasses", :mcc=>"8043"}, - {:decription=>"Optometrists, Ophthalmologist", :mcc=>"8042"}, - {:decription=>"Orthopedic Goods - Prosthetic Devices", :mcc=>"5976"}, - {:decription=>"Osteopaths", :mcc=>"8031"}, - {:decription=>"Package Stores-Beer, Wine, and Liquor", :mcc=>"5921"}, - {:decription=>"Paints, Varnishes, and Supplies", :mcc=>"5198"}, - {:decription=>"Parking Lots, Garages", :mcc=>"7523"}, - {:decription=>"Passenger Railways", :mcc=>"4112"}, - {:decription=>"Pawn Shops", :mcc=>"5933"}, - {:decription=>"Pet Shops, Pet Food, and Supplies", :mcc=>"5995"}, - {:decription=>"Petroleum and Petroleum Products", :mcc=>"5172"}, - {:decription=>"Photo Developing", :mcc=>"7395"}, - {:decription=>"Photographic Studios", :mcc=>"7221"}, - {:decription=>"Photographic, Photocopy, Microfilm Equipment, and Supplies", - :mcc=>"5044"}, - {:decription=>"Picture/Video Production", :mcc=>"7829"}, - {:decription=>"Piece Goods, Notions, and Other Dry Goods", :mcc=>"5131"}, - {:decription=>"Plumbing, Heating Equipment, and Supplies", :mcc=>"5074"}, - {:decription=>"Political Organizations", :mcc=>"8651"}, - {:decription=>"Postal Services - Government Only", :mcc=>"9402"}, - {:decription=>"Precious Stones and Metals, Watches and Jewelry", - :mcc=>"5094"}, - {:decription=>"Professional Services", :mcc=>"8999"}, - {:decription=> - "Public Warehousing and Storage - Farm Products, Refrigerated Goods, Household Goods, and Storage", - :mcc=>"4225"}, - {:decription=>"Quick Copy, Repro, and Blueprint", :mcc=>"7338"}, - {:decription=>"Railroads", :mcc=>"4011"}, - {:decription=>"Real Estate Agents and Managers - Rentals", :mcc=>"6513"}, - {:decription=>"Record Stores", :mcc=>"5735"}, - {:decription=>"Recreational Vehicle Rentals", :mcc=>"7519"}, - {:decription=>"Religious Goods Stores", :mcc=>"5973"}, - {:decription=>"Religious Organizations", :mcc=>"8661"}, - {:decription=>"Roofing/Siding, Sheet Metal", :mcc=>"1761"}, - {:decription=>"Secretarial Support Services", :mcc=>"7339"}, - {:decription=>"Security Brokers/Dealers", :mcc=>"6211"}, - {:decription=>"Service Stations", :mcc=>"5541"}, - {:decription=>"Sewing, Needlework, Fabric, and Piece Goods Stores", - :mcc=>"5949"}, - {:decription=>"Shoe Repair/Hat Cleaning", :mcc=>"7251"}, - {:decription=>"Shoe Stores", :mcc=>"5661"}, - {:decription=>"Small Appliance Repair", :mcc=>"7629"}, - {:decription=>"Snowmobile Dealers", :mcc=>"5598"}, - {:decription=>"Special Trade Services", :mcc=>"1799"}, - {:decription=>"Specialty Cleaning", :mcc=>"2842"}, - {:decription=>"Sporting Goods Stores", :mcc=>"5941"}, - {:decription=>"Sporting/Recreation Camps", :mcc=>"7032"}, - {:decription=>"Sports Clubs/Fields", :mcc=>"7941"}, - {:decription=>"Sports and Riding Apparel Stores", :mcc=>"5655"}, - {:decription=>"Stamp and Coin Stores", :mcc=>"5972"}, - {:decription=>"Stationary, Office Supplies, Printing and Writing Paper", - :mcc=>"5111"}, - {:decription=>"Stationery Stores, Office, and School Supply Stores", - :mcc=>"5943"}, - {:decription=>"Swimming Pools Sales", :mcc=>"5996"}, - {:decription=>"TUI Travel - Germany", :mcc=>"4723"}, - {:decription=>"Tailors, Alterations", :mcc=>"5697"}, - {:decription=>"Tax Payments - Government Agencies", :mcc=>"9311"}, - {:decription=>"Tax Preparation Services", :mcc=>"7276"}, - {:decription=>"Taxicabs/Limousines", :mcc=>"4121"}, - {:decription=>"Telecommunication Equipment and Telephone Sales", - :mcc=>"4812"}, - {:decription=>"Telecommunication Services", :mcc=>"4814"}, - {:decription=>"Telegraph Services", :mcc=>"4821"}, - {:decription=>"Tent and Awning Shops", :mcc=>"5998"}, - {:decription=>"Testing Laboratories", :mcc=>"8734"}, - {:decription=>"Theatrical Ticket Agencies", :mcc=>"7922"}, - {:decription=>"Timeshares", :mcc=>"7012"}, - {:decription=>"Tire Retreading and Repair", :mcc=>"7534"}, - {:decription=>"Tolls/Bridge Fees", :mcc=>"4784"}, - {:decription=>"Tourist Attractions and Exhibits", :mcc=>"7991"}, - {:decription=>"Towing Services", :mcc=>"7549"}, - {:decription=>"Trailer Parks, Campgrounds", :mcc=>"7033"}, - {:decription=>"Transportation Services (Not Elsewhere Classified)", - :mcc=>"4789"}, - {:decription=>"Travel Agencies, Tour Operators", :mcc=>"4722"}, - {:decription=>"Truck StopIteration", :mcc=>"7511"}, - {:decription=>"Truck/Utility Trailer Rentals", :mcc=>"7513"}, - {:decription=>"Typesetting, Plate Making, and Related Services", - :mcc=>"2791"}, - {:decription=>"Typewriter Stores", :mcc=>"5978"}, - {:decription=>"U.S. Federal Government Agencies or Departments", - :mcc=>"9405"}, - {:decription=>"Uniforms, Commercial Clothing", :mcc=>"5137"}, - {:decription=>"Used Merchandise and Secondhand Stores", :mcc=>"5931"}, - {:decription=>"Utilities", :mcc=>"4900"}, - {:decription=>"Variety Stores", :mcc=>"5331"}, - {:decription=>"Veterinary Services", :mcc=>"0742"}, - {:decription=>"Video Amusement Game Supplies", :mcc=>"7993"}, - {:decription=>"Video Game Arcades", :mcc=>"7994"}, - {:decription=>"Video Tape Rental Stores", :mcc=>"7841"}, - {:decription=>"Vocational/Trade Schools", :mcc=>"8249"}, - {:decription=>"Watch/Jewelry Repair", :mcc=>"7631"}, - {:decription=>"Welding Repair", :mcc=>"7692"}, - {:decription=>"Wholesale Clubs", :mcc=>"5300"}, - {:decription=>"Wig and Toupee Stores", :mcc=>"5698"}, - {:decription=>"Wires, Money Orders", :mcc=>"4829"}, - {:decription=>"Womens Accessory and Specialty Shops", :mcc=>"5631"}, - {:decription=>"Womens Ready-To-Wear Stores", :mcc=>"5621"}, - {:decription=>"Wrecking and Salvage Yards", :mcc=>"5935"}].freeze + [{:decription=>"A/C, Refrigeration Repair", :mcc=>"7623"}, + {:decription=>"Accounting/Bookkeeping Services", :mcc=>"8931"}, + {:decription=>"Advertising Services", :mcc=>"7311"}, + {:decription=>"Agricultural Cooperative", :mcc=>"0763"}, + {:decription=>"Airlines, Air Carriers", :mcc=>"4511"}, + {:decription=>"Airports, Flying Fields", :mcc=>"4582"}, + {:decription=>"Ambulance Services", :mcc=>"4119"}, + {:decription=>"Amusement Parks/Carnivals", :mcc=>"7996"}, + {:decription=>"Antique Reproductions", :mcc=>"5937"}, + {:decription=>"Antique Shops", :mcc=>"5932"}, + {:decription=>"Aquariums", :mcc=>"7998"}, + {:decription=>"Architectural/Surveying Services", :mcc=>"8911"}, + {:decription=>"Art Dealers and Galleries", :mcc=>"5971"}, + {:decription=>"Artists Supply and Craft Shops", :mcc=>"5970"}, + {:decription=>"Auto Body Repair Shops", :mcc=>"7531"}, + {:decription=>"Auto Paint Shops", :mcc=>"7535"}, + {:decription=>"Auto Service Shops", :mcc=>"7538"}, + {:decription=>"Auto and Home Supply Stores", :mcc=>"5531"}, + {:decription=>"Automated Cash Disburse", :mcc=>"6011"}, + {:decription=>"Automated Fuel Dispensers", :mcc=>"5542"}, + {:decription=>"Automobile Associations", :mcc=>"8675"}, + {:decription=>"Automotive Parts and Accessories Stores", :mcc=>"5533"}, + {:decription=>"Automotive Tire Stores", :mcc=>"5532"}, + {:decription => + "Bail and Bond Payments (payment to the surety for the bond, not the actual bond paid to the government agency)", + :mcc => "9223"}, + {:decription=>"Bakeries", :mcc=>"5462"}, + {:decription=>"Bands, Orchestras", :mcc=>"7929"}, + {:decription=>"Barber and Beauty Shops", :mcc=>"7230"}, + {:decription=>"Betting/Casino Gambling", :mcc=>"7995"}, + {:decription=>"Bicycle Shops", :mcc=>"5940"}, + {:decription=>"Billiard/Pool Establishments", :mcc=>"7932"}, + {:decription=>"Boat Dealers", :mcc=>"5551"}, + {:decription=>"Boat Rentals and Leases", :mcc=>"4457"}, + {:decription=>"Book Stores", :mcc=>"5942"}, + {:decription=>"Books, Periodicals, and Newspapers", :mcc=>"5192"}, + {:decription=>"Bowling Alleys", :mcc=>"7933"}, + {:decription=>"Bus Lines", :mcc=>"4131"}, + {:decription=>"Business/Secretarial Schools", :mcc=>"8244"}, + {:decription=>"Buying/Shopping Services", :mcc=>"7278"}, + {:decription => "Cable, Satellite, and Other Pay Television and Radio", + :mcc => "4899"}, + {:decription=>"Camera and Photographic Supply Stores", :mcc=>"5946"}, + {:decription=>"Candy, Nut, and Confectionery Stores", :mcc=>"5441"}, + {:decription=>"Car Rental Agencies", :mcc=>"7512"}, + {:decription=>"Car Washes", :mcc=>"7542"}, + {:decription => + "Car and Truck Dealers (New & Used) Sales, Service, Repairs Parts and Leasing", + :mcc => "5511"}, + {:decription => + "Car and Truck Dealers (Used Only) Sales, Service, Repairs Parts and Leasing", + :mcc => "5521"}, + {:decription=>"Carpentry Services", :mcc=>"1750"}, + {:decription=>"Carpet/Upholstery Cleaning", :mcc=>"7217"}, + {:decription=>"Caterers", :mcc=>"5811"}, + {:decription => "Charitable and Social Service Organizations - Fundraising", + :mcc => "8398"}, + {:decription => "Chemicals and Allied Products (Not Elsewhere Classified)", + :mcc => "5169"}, + {:decription=>"Chidrens and Infants Wear Stores", :mcc=>"5641"}, + {:decription=>"Child Care Services", :mcc=>"8351"}, + {:decription=>"Chiropodists, Podiatrists", :mcc=>"8049"}, + {:decription=>"Chiropractors", :mcc=>"8041"}, + {:decription=>"Cigar Stores and Stands", :mcc=>"5993"}, + {:decription=>"Civic, Social, Fraternal Associations", :mcc=>"8641"}, + {:decription=>"Cleaning and Maintenance", :mcc=>"7349"}, + {:decription=>"Clothing Rental", :mcc=>"7296"}, + {:decription=>"Colleges, Universities", :mcc=>"8220"}, + {:decription => "Commercial Equipment (Not Elsewhere Classified)", + :mcc => "5046"}, + {:decription=>"Commercial Footwear", :mcc=>"5139"}, + {:decription=>"Commercial Photography, Art and Graphics", :mcc=>"7333"}, + {:decription=>"Commuter Transport, Ferries", :mcc=>"4111"}, + {:decription=>"Computer Network Services", :mcc=>"4816"}, + {:decription=>"Computer Programming", :mcc=>"7372"}, + {:decription=>"Computer Repair", :mcc=>"7379"}, + {:decription=>"Computer Software Stores", :mcc=>"5734"}, + {:decription=>"Computers, Peripherals, and Software", :mcc=>"5045"}, + {:decription=>"Concrete Work Services", :mcc=>"1771"}, + {:decription => "Construction Materials (Not Elsewhere Classified)", + :mcc => "5039"}, + {:decription=>"Consulting, Public Relations", :mcc=>"7392"}, + {:decription=>"Correspondence Schools", :mcc=>"8241"}, + {:decription=>"Cosmetic Stores", :mcc=>"5977"}, + {:decription=>"Counseling Services", :mcc=>"7277"}, + {:decription=>"Country Clubs", :mcc=>"7997"}, + {:decription=>"Courier Services", :mcc=>"4215"}, + {:decription => + "Court Costs, Including Alimony and Child Support - Courts of Law", + :mcc => "9211"}, + {:decription=>"Credit Reporting Agencies", :mcc=>"7321"}, + {:decription=>"Cruise Lines", :mcc=>"4411"}, + {:decription=>"Dairy Products Stores", :mcc=>"5451"}, + {:decription=>"Dance Hall, Studios, Schools", :mcc=>"7911"}, + {:decription=>"Dating/Escort Services", :mcc=>"7273"}, + {:decription=>"Dentists, Orthodontists", :mcc=>"8021"}, + {:decription=>"Department Stores", :mcc=>"5311"}, + {:decription=>"Detective Agencies", :mcc=>"7393"}, + {:decription=>"Direct Marketing - Catalog Merchant", :mcc=>"5964"}, + {:decription => "Direct Marketing - Combination Catalog and Retail Merchant", + :mcc => "5965"}, + {:decription=>"Direct Marketing - Inbound Telemarketing", :mcc=>"5967"}, + {:decription=>"Direct Marketing - Insurance Services", :mcc=>"5960"}, + {:decription=>"Direct Marketing - Other", :mcc=>"5969"}, + {:decription=>"Direct Marketing - Outbound Telemarketing", :mcc=>"5966"}, + {:decription=>"Direct Marketing - Subscription", :mcc=>"5968"}, + {:decription=>"Direct Marketing - Travel", :mcc=>"5962"}, + {:decription=>"Discount Stores", :mcc=>"5310"}, + {:decription=>"Doctors", :mcc=>"8011"}, + {:decription=>"Door-To-Door Sales", :mcc=>"5963"}, + {:decription => "Drapery, Window Covering, and Upholstery Stores", + :mcc => "5714"}, + {:decription=>"Drinking Places", :mcc=>"5813"}, + {:decription=>"Drug Stores and Pharmacies", :mcc=>"5912"}, + {:decription => "Drugs, Drug Proprietaries, and Druggist Sundries", + :mcc => "5122"}, + {:decription=>"Dry Cleaners", :mcc=>"7216"}, + {:decription=>"Durable Goods (Not Elsewhere Classified)", :mcc=>"5099"}, + {:decription=>"Duty Free Stores", :mcc=>"5309"}, + {:decription=>"Eating Places, Restaurants", :mcc=>"5812"}, + {:decription=>"Educational Services", :mcc=>"8299"}, + {:decription=>"Electric Razor Stores", :mcc=>"5997"}, + {:decription=>"Electrical Parts and Equipment", :mcc=>"5065"}, + {:decription=>"Electrical Services", :mcc=>"1731"}, + {:decription=>"Electronics Repair Shops", :mcc=>"7622"}, + {:decription=>"Electronics Stores", :mcc=>"5732"}, + {:decription=>"Elementary, Secondary Schools", :mcc=>"8211"}, + {:decription=>"Employment/Temp Agencies", :mcc=>"7361"}, + {:decription=>"Equipment Rental", :mcc=>"7394"}, + {:decription=>"Exterminating Services", :mcc=>"7342"}, + {:decription=>"Family Clothing Stores", :mcc=>"5651"}, + {:decription=>"Fast Food Restaurants", :mcc=>"5814"}, + {:decription=>"Financial Institutions", :mcc=>"6012"}, + {:decription=>"Fines - Government Administrative Entities", :mcc=>"9222"}, + {:decription => "Fireplace, Fireplace Screens, and Accessories Stores", + :mcc => "5718"}, + {:decription=>"Floor Covering Stores", :mcc=>"5713"}, + {:decription=>"Florists", :mcc=>"5992"}, + {:decription=>"Florists Supplies, Nursery Stock, and Flowers", :mcc=>"5193"}, + {:decription=>"Freezer and Locker Meat Provisioners", :mcc=>"5422"}, + {:decription=>"Fuel Dealers (Non Automotive)", :mcc=>"5983"}, + {:decription=>"Funeral Services, Crematories", :mcc=>"7261"}, + {:decription=>"Furniture Repair, Refinishing", :mcc=>"7641"}, + {:decription => + "Furniture, Home Furnishings, and Equipment Stores, Except Appliances", + :mcc => "5712"}, + {:decription=>"Furriers and Fur Shops", :mcc=>"5681"}, + {:decription=>"General Services", :mcc=>"1520"}, + {:decription=>"Gift, Card, Novelty, and Souvenir Shops", :mcc=>"5947"}, + {:decription=>"Glass, Paint, and Wallpaper Stores", :mcc=>"5231"}, + {:decription=>"Glassware, Crystal Stores", :mcc=>"5950"}, + {:decription=>"Golf Courses - Public", :mcc=>"7992"}, + {:decription=>"Government Services (Not Elsewhere Classified)", :mcc=>"9399"}, + {:decription=>"Grocery Stores, Supermarkets", :mcc=>"5411"}, + {:decription=>"Hardware Stores", :mcc=>"5251"}, + {:decription=>"Hardware, Equipment, and Supplies", :mcc=>"5072"}, + {:decription=>"Health and Beauty Spas", :mcc=>"7298"}, + {:decription=>"Hearing Aids Sales and Supplies", :mcc=>"5975"}, + {:decription=>"Heating, Plumbing, A/C", :mcc=>"1711"}, + {:decription=>"Hobby, Toy, and Game Shops", :mcc=>"5945"}, + {:decription=>"Home Supply Warehouse Stores", :mcc=>"5200"}, + {:decription=>"Hospitals", :mcc=>"8062"}, + {:decription=>"Hotels, Motels, and Resorts", :mcc=>"7011"}, + {:decription=>"Household Appliance Stores", :mcc=>"5722"}, + {:decription=>"Industrial Supplies (Not Elsewhere Classified)", :mcc=>"5085"}, + {:decription=>"Information Retrieval Services", :mcc=>"7375"}, + {:decription=>"Insurance - Default", :mcc=>"6399"}, + {:decription=>"Insurance Underwriting, Premiums", :mcc=>"6300"}, + {:decription=>"Intra-Company Purchases", :mcc=>"9950"}, + {:decription => "Jewelry Stores, Watches, Clocks, and Silverware Stores", + :mcc => "5944"}, + {:decription=>"Landscaping Services", :mcc=>"0780"}, + {:decription=>"Laundries", :mcc=>"7211"}, + {:decription=>"Laundry, Cleaning Services", :mcc=>"7210"}, + {:decription=>"Legal Services, Attorneys", :mcc=>"8111"}, + {:decription=>"Luggage and Leather Goods Stores", :mcc=>"5948"}, + {:decription=>"Lumber, Building Materials Stores", :mcc=>"5211"}, + {:decription=>"Manual Cash Disburse", :mcc=>"6010"}, + {:decription=>"Marinas, Service and Supplies", :mcc=>"4468"}, + {:decription=>"Masonry, Stonework, and Plaster", :mcc=>"1740"}, + {:decription=>"Massage Parlors", :mcc=>"7297"}, + {:decription=>"Medical Services", :mcc=>"8099"}, + {:decription=>"Medical and Dental Labs", :mcc=>"8071"}, + {:decription => + "Medical, Dental, Ophthalmic, and Hospital Equipment and Supplies", + :mcc => "5047"}, + {:decription=>"Membership Organizations", :mcc=>"8699"}, + {:decription=>"Mens and Boys Clothing and Accessories Stores", :mcc=>"5611"}, + {:decription=>"Mens, Womens Clothing Stores", :mcc=>"5691"}, + {:decription=>"Metal Service Centers", :mcc=>"5051"}, + {:decription=>"Miscellaneous Apparel and Accessory Shops", :mcc=>"5699"}, + {:decription=>"Miscellaneous Auto Dealers", :mcc=>"5599"}, + {:decription=>"Miscellaneous Business Services", :mcc=>"7399"}, + {:decription => + "Miscellaneous Food Stores - Convenience Stores and Specialty Markets", + :mcc => "5499"}, + {:decription=>"Miscellaneous General Merchandise", :mcc=>"5399"}, + {:decription=>"Miscellaneous General Services", :mcc=>"7299"}, + {:decription=>"Miscellaneous Home Furnishing Specialty Stores", :mcc=>"5719"}, + {:decription=>"Miscellaneous Publishing and Printing", :mcc=>"2741"}, + {:decription=>"Miscellaneous Recreation Services", :mcc=>"7999"}, + {:decription=>"Miscellaneous Repair Shops", :mcc=>"7699"}, + {:decription=>"Miscellaneous Specialty Retail", :mcc=>"5999"}, + {:decription=>"Mobile Home Dealers", :mcc=>"5271"}, + {:decription=>"Motion Picture Theaters", :mcc=>"7832"}, + {:decription => + "Motor Freight Carriers and Trucking - Local and Long Distance, Moving and Storage Companies, and Local Delivery Services", + :mcc => "4214"}, + {:decription=>"Motor Homes Dealers", :mcc=>"5592"}, + {:decription=>"Motor Vehicle Supplies and New Parts", :mcc=>"5013"}, + {:decription=>"Motorcycle Shops and Dealers", :mcc=>"5571"}, + {:decription=>"Motorcycle Shops, Dealers", :mcc=>"5561"}, + {:decription => "Music Stores-Musical Instruments, Pianos, and Sheet Music", + :mcc => "5733"}, + {:decription=>"News Dealers and Newsstands", :mcc=>"5994"}, + {:decription=>"Non-FI, Money Orders", :mcc=>"6051"}, + {:decription=>"Non-FI, Stored Value Card Purchase/Load", :mcc=>"6540"}, + {:decription=>"Nondurable Goods (Not Elsewhere Classified)", :mcc=>"5199"}, + {:decription=>"Nurseries, Lawn and Garden Supply Stores", :mcc=>"5261"}, + {:decription=>"Nursing/Personal Care", :mcc=>"8050"}, + {:decription=>"Office and Commercial Furniture", :mcc=>"5021"}, + {:decription=>"Opticians, Eyeglasses", :mcc=>"8043"}, + {:decription=>"Optometrists, Ophthalmologist", :mcc=>"8042"}, + {:decription=>"Orthopedic Goods - Prosthetic Devices", :mcc=>"5976"}, + {:decription=>"Osteopaths", :mcc=>"8031"}, + {:decription=>"Package Stores-Beer, Wine, and Liquor", :mcc=>"5921"}, + {:decription=>"Paints, Varnishes, and Supplies", :mcc=>"5198"}, + {:decription=>"Parking Lots, Garages", :mcc=>"7523"}, + {:decription=>"Passenger Railways", :mcc=>"4112"}, + {:decription=>"Pawn Shops", :mcc=>"5933"}, + {:decription=>"Pet Shops, Pet Food, and Supplies", :mcc=>"5995"}, + {:decription=>"Petroleum and Petroleum Products", :mcc=>"5172"}, + {:decription=>"Photo Developing", :mcc=>"7395"}, + {:decription=>"Photographic Studios", :mcc=>"7221"}, + {:decription => "Photographic, Photocopy, Microfilm Equipment, and Supplies", + :mcc => "5044"}, + {:decription=>"Picture/Video Production", :mcc=>"7829"}, + {:decription=>"Piece Goods, Notions, and Other Dry Goods", :mcc=>"5131"}, + {:decription=>"Plumbing, Heating Equipment, and Supplies", :mcc=>"5074"}, + {:decription=>"Political Organizations", :mcc=>"8651"}, + {:decription=>"Postal Services - Government Only", :mcc=>"9402"}, + {:decription => "Precious Stones and Metals, Watches and Jewelry", + :mcc => "5094"}, + {:decription=>"Professional Services", :mcc=>"8999"}, + {:decription => + "Public Warehousing and Storage - Farm Products, Refrigerated Goods, Household Goods, and Storage", + :mcc => "4225"}, + {:decription=>"Quick Copy, Repro, and Blueprint", :mcc=>"7338"}, + {:decription=>"Railroads", :mcc=>"4011"}, + {:decription=>"Real Estate Agents and Managers - Rentals", :mcc=>"6513"}, + {:decription=>"Record Stores", :mcc=>"5735"}, + {:decription=>"Recreational Vehicle Rentals", :mcc=>"7519"}, + {:decription=>"Religious Goods Stores", :mcc=>"5973"}, + {:decription=>"Religious Organizations", :mcc=>"8661"}, + {:decription=>"Roofing/Siding, Sheet Metal", :mcc=>"1761"}, + {:decription=>"Secretarial Support Services", :mcc=>"7339"}, + {:decription=>"Security Brokers/Dealers", :mcc=>"6211"}, + {:decription=>"Service Stations", :mcc=>"5541"}, + {:decription => "Sewing, Needlework, Fabric, and Piece Goods Stores", + :mcc => "5949"}, + {:decription=>"Shoe Repair/Hat Cleaning", :mcc=>"7251"}, + {:decription=>"Shoe Stores", :mcc=>"5661"}, + {:decription=>"Small Appliance Repair", :mcc=>"7629"}, + {:decription=>"Snowmobile Dealers", :mcc=>"5598"}, + {:decription=>"Special Trade Services", :mcc=>"1799"}, + {:decription=>"Specialty Cleaning", :mcc=>"2842"}, + {:decription=>"Sporting Goods Stores", :mcc=>"5941"}, + {:decription=>"Sporting/Recreation Camps", :mcc=>"7032"}, + {:decription=>"Sports Clubs/Fields", :mcc=>"7941"}, + {:decription=>"Sports and Riding Apparel Stores", :mcc=>"5655"}, + {:decription=>"Stamp and Coin Stores", :mcc=>"5972"}, + {:decription => "Stationary, Office Supplies, Printing and Writing Paper", + :mcc => "5111"}, + {:decription => "Stationery Stores, Office, and School Supply Stores", + :mcc => "5943"}, + {:decription=>"Swimming Pools Sales", :mcc=>"5996"}, + {:decription=>"TUI Travel - Germany", :mcc=>"4723"}, + {:decription=>"Tailors, Alterations", :mcc=>"5697"}, + {:decription=>"Tax Payments - Government Agencies", :mcc=>"9311"}, + {:decription=>"Tax Preparation Services", :mcc=>"7276"}, + {:decription=>"Taxicabs/Limousines", :mcc=>"4121"}, + {:decription => "Telecommunication Equipment and Telephone Sales", + :mcc => "4812"}, + {:decription=>"Telecommunication Services", :mcc=>"4814"}, + {:decription=>"Telegraph Services", :mcc=>"4821"}, + {:decription=>"Tent and Awning Shops", :mcc=>"5998"}, + {:decription=>"Testing Laboratories", :mcc=>"8734"}, + {:decription=>"Theatrical Ticket Agencies", :mcc=>"7922"}, + {:decription=>"Timeshares", :mcc=>"7012"}, + {:decription=>"Tire Retreading and Repair", :mcc=>"7534"}, + {:decription=>"Tolls/Bridge Fees", :mcc=>"4784"}, + {:decription=>"Tourist Attractions and Exhibits", :mcc=>"7991"}, + {:decription=>"Towing Services", :mcc=>"7549"}, + {:decription=>"Trailer Parks, Campgrounds", :mcc=>"7033"}, + {:decription => "Transportation Services (Not Elsewhere Classified)", + :mcc => "4789"}, + {:decription=>"Travel Agencies, Tour Operators", :mcc=>"4722"}, + {:decription=>"Truck StopIteration", :mcc=>"7511"}, + {:decription=>"Truck/Utility Trailer Rentals", :mcc=>"7513"}, + {:decription => "Typesetting, Plate Making, and Related Services", + :mcc => "2791"}, + {:decription=>"Typewriter Stores", :mcc=>"5978"}, + {:decription => "U.S. Federal Government Agencies or Departments", + :mcc => "9405"}, + {:decription=>"Uniforms, Commercial Clothing", :mcc=>"5137"}, + {:decription=>"Used Merchandise and Secondhand Stores", :mcc=>"5931"}, + {:decription=>"Utilities", :mcc=>"4900"}, + {:decription=>"Variety Stores", :mcc=>"5331"}, + {:decription=>"Veterinary Services", :mcc=>"0742"}, + {:decription=>"Video Amusement Game Supplies", :mcc=>"7993"}, + {:decription=>"Video Game Arcades", :mcc=>"7994"}, + {:decription=>"Video Tape Rental Stores", :mcc=>"7841"}, + {:decription=>"Vocational/Trade Schools", :mcc=>"8249"}, + {:decription=>"Watch/Jewelry Repair", :mcc=>"7631"}, + {:decription=>"Welding Repair", :mcc=>"7692"}, + {:decription=>"Wholesale Clubs", :mcc=>"5300"}, + {:decription=>"Wig and Toupee Stores", :mcc=>"5698"}, + {:decription=>"Wires, Money Orders", :mcc=>"4829"}, + {:decription=>"Womens Accessory and Specialty Shops", :mcc=>"5631"}, + {:decription=>"Womens Ready-To-Wear Stores", :mcc=>"5621"}, + {:decription=>"Wrecking and Salvage Yards", :mcc=>"5935"}].freeze end diff --git a/app/utils/service_client/middleware/jwt_authenticator.rb b/app/utils/service_client/middleware/jwt_authenticator.rb index 713d2bde53..a312c41c5c 100644 --- a/app/utils/service_client/middleware/jwt_authenticator.rb +++ b/app/utils/service_client/middleware/jwt_authenticator.rb @@ -1,7 +1,7 @@ module ServiceClient module Middleware - IDENTITY = ->() {} + IDENTITY = -> {} AuthContext = EntityUtils.define_builder( [:marketplace_id, :uuid, :mandatory], diff --git a/app/utils/service_client/middleware/logger.rb b/app/utils/service_client/middleware/logger.rb index 520737ae19..a8ce5a15d4 100644 --- a/app/utils/service_client/middleware/logger.rb +++ b/app/utils/service_client/middleware/logger.rb @@ -35,7 +35,7 @@ def enter_log(ctx) def leave_log(ctx) { req: ctx.fetch(:req).except(:body), - res: ctx.fetch(:res).except(:body), + res: ctx.fetch(:res).except(:body) }.merge(timing(ctx)) end @@ -43,7 +43,7 @@ def error_log(ctx) { req: ctx.fetch(:req).except(:body), res: Maybe(ctx)[:res].except(:body).or_nil, - error_class: ctx[:error].class.to_s, + error_class: ctx[:error].class.to_s }.merge(timing(ctx)) end diff --git a/app/utils/service_client/middleware/timing.rb b/app/utils/service_client/middleware/timing.rb index 1e920a5a45..ec7f12655d 100644 --- a/app/utils/service_client/middleware/timing.rb +++ b/app/utils/service_client/middleware/timing.rb @@ -13,7 +13,7 @@ module Middleware class Timing < MiddlewareBase def initialize(now = nil) - @now = now || ->() { Time.now } + @now = now || -> { Time.now } end def enter(ctx) diff --git a/app/view_utils/category_view_utils.rb b/app/view_utils/category_view_utils.rb index 8775041a73..96bbbf19b7 100644 --- a/app/view_utils/category_view_utils.rb +++ b/app/view_utils/category_view_utils.rb @@ -60,11 +60,11 @@ def embed_shape(ids, shapes) def pick_category_translation(category_translations, locale, all_locales) prio = translation_preferences(locale, all_locales) - category_translations.sort { |a, b| + category_translations.min { |a, b| a_prio = prio[a[:locale]] b_prio = prio[b[:locale]] sort_num_or_nil(a_prio, b_prio) - }.first[:name] + }[:name] end def translation_preferences(preferred, all) diff --git a/app/view_utils/icon_map.rb b/app/view_utils/icon_map.rb index 2fdfe1178a..c3cd8d2190 100644 --- a/app/view_utils/icon_map.rb +++ b/app/view_utils/icon_map.rb @@ -1,4 +1,3 @@ -# coding: utf-8 ICON_MAP = { "ss-pika" => { @@ -8,10 +7,10 @@ "thumbnails" => "ss-thumbnails", "grid" => "ss-thumbnails", "new_listing" => "ss-addfile", - "search" => "ss-search", + "search" => "ss-search", "list" => "ss-list", "home" => "ss-home", - "community" =>"ss-usergroup", + "community" => "ss-usergroup", "help" => "ss-help", "admin" => "ss-wrench", "directup" => "ss-directup", @@ -175,11 +174,11 @@ "thumbnails" => "icon-th", "new_listing" => "icon-plus-sign-alt", - "search" => "icon-search", + "search" => "icon-search", "list" => "icon-reorder", "home" => "icon-home", - "community" =>"icon-group", + "community" => "icon-group", "help" => "icon-question-sign", "admin" => "icon-wrench", diff --git a/app/view_utils/intercom_helper.rb b/app/view_utils/intercom_helper.rb index e709829c84..54648af597 100644 --- a/app/view_utils/intercom_helper.rb +++ b/app/view_utils/intercom_helper.rb @@ -1,4 +1,3 @@ -# coding: utf-8 module IntercomHelper # Copied from diff --git a/app/view_utils/listing_shape_data_types.rb b/app/view_utils/listing_shape_data_types.rb index ef9294c412..d2aa7288ad 100644 --- a/app/view_utils/listing_shape_data_types.rb +++ b/app/view_utils/listing_shape_data_types.rb @@ -14,6 +14,7 @@ module ListingShapeDataTypes FORM_TRANSLATION = ->(h) { return if h.nil? + unless h.all? { |(k, v)| k.is_a?(String) && v.is_a?(String) } {code: :form_translation_hash_format, msg: "Value must be a hash of { locale => translations }" } end diff --git a/app/view_utils/listing_shape_helper.rb b/app/view_utils/listing_shape_helper.rb index 3d9edcd49e..2d00014860 100644 --- a/app/view_utils/listing_shape_helper.rb +++ b/app/view_utils/listing_shape_helper.rb @@ -1,4 +1,3 @@ - module ListingShapeHelper diff --git a/app/view_utils/listing_shape_templates.rb b/app/view_utils/listing_shape_templates.rb index 4de1792702..d1478fc0c4 100644 --- a/app/view_utils/listing_shape_templates.rb +++ b/app/view_utils/listing_shape_templates.rb @@ -101,7 +101,7 @@ def all price_enabled: false, shipping_enabled: false, online_payments: false, - template: :announcement, + template: :announcement, author_is_seller: true, units: [] }, diff --git a/app/view_utils/listing_view_utils.rb b/app/view_utils/listing_view_utils.rb index 6a944665a2..cbc781528a 100644 --- a/app/view_utils/listing_view_utils.rb +++ b/app/view_utils/listing_view_utils.rb @@ -88,11 +88,13 @@ def shipping_info(shipping_type, shipping_price, shipping_price_additional) def youtube_video_ids(text) return [] unless text.present? && text.is_a?(String) + text.scan(/https?:\/\/\S+/).map { |l| youtube_video_id(l) }.compact end def youtube_video_id(link) return nil unless link.present? && link.is_a?(String) + pattern = /^.*(?:(?:youtu\.be\/|youtu.*v\/|youtu.*embed\/)|youtu.*(?:\?v=|\&v=))([^#\&\?]*).*/ Maybe(pattern.match(link))[1].or_else(nil) end diff --git a/app/view_utils/manage_availability_helper.rb b/app/view_utils/manage_availability_helper.rb index 99bb78a26d..107fe129cc 100644 --- a/app/view_utils/manage_availability_helper.rb +++ b/app/view_utils/manage_availability_helper.rb @@ -12,12 +12,12 @@ def availability_props(community:, listing:) }, marketplace: { uuid: community.uuid_object.to_s, - marketplace_color1: CommonStylesHelper.marketplace_colors(community)[:marketplace_color1], + marketplace_color1: CommonStylesHelper.marketplace_colors(community)[:marketplace_color1] }, listing: { uuid: listing.uuid_object.to_s, title: listing.title, - image_url: path_to_listing_image(listing), + image_url: path_to_listing_image(listing) } } end diff --git a/app/view_utils/marketplace_helper.rb b/app/view_utils/marketplace_helper.rb index 27c6e941c0..4464598ad9 100644 --- a/app/view_utils/marketplace_helper.rb +++ b/app/view_utils/marketplace_helper.rb @@ -3,7 +3,7 @@ module MarketplaceHelper def google_maps_key(cid) community_key = Community.where(id: cid).pluck(:google_maps_key).first - community_key ? community_key : APP_CONFIG.google_maps_key + community_key || APP_CONFIG.google_maps_key end def style_customizations_map(community) @@ -16,12 +16,12 @@ def style_customizations_map(community) slogancolor: slogan_color, descriptioncolor: description_color, image_map: { - cover_photo: community.stable_image_url(:cover_photo, :hd_header), - small_cover_photo: community.stable_image_url(:small_cover_photo, :hd_header), - wide_logo_lowres: community.stable_image_url(:wide_logo, :header), - wide_logo_highres: community.stable_image_url(:wide_logo, :header_highres), - square_logo_lowres: community.stable_image_url(:logo, :header_icon), - square_logo_highres: community.stable_image_url(:logo, :header_icon_highres), + cover_photo: community.stable_image_url(:cover_photo, :hd_header), + small_cover_photo: community.stable_image_url(:small_cover_photo, :hd_header), + wide_logo_lowres: community.stable_image_url(:wide_logo, :header), + wide_logo_highres: community.stable_image_url(:wide_logo, :header_highres), + square_logo_lowres: community.stable_image_url(:logo, :header_icon), + square_logo_highres: community.stable_image_url(:logo, :header_icon_highres) } } end diff --git a/app/view_utils/new_layout_view_utils.rb b/app/view_utils/new_layout_view_utils.rb index c2ab2d67c4..0e21bab9f8 100644 --- a/app/view_utils/new_layout_view_utils.rb +++ b/app/view_utils/new_layout_view_utils.rb @@ -36,8 +36,8 @@ def experimental_features { manage_searchpage: { title: t("admin.communities.new_layout.searchpage"), - name: :searchpage_v1, - }, + name: :searchpage_v1 + } } end @@ -55,7 +55,8 @@ def features(community_id, person_id, private_community, clp_enabled) enabled_for_community: community_flags.include?(f[:name]), required_for_user: flag_required?(f, person_flags), required_for_community: flag_required?(f, community_flags) - })} + }) + } end # Takes a map of features diff --git a/app/view_utils/path_helpers.rb b/app/view_utils/path_helpers.rb index ccb53f04f1..25288c8496 100644 --- a/app/view_utils/path_helpers.rb +++ b/app/view_utils/path_helpers.rb @@ -64,7 +64,7 @@ def landing_page_path(community_id:, logged_in:, locale_param:, default_locale:, end def paths - @_url_helpers ||= Rails.application.routes.url_helpers + @_url_helpers ||= Rails.application.routes.url_helpers # rubocop:disable Naming/MemoizedInstanceVariableName end # Path for locale change diff --git a/app/view_utils/paypal_country_helper.rb b/app/view_utils/paypal_country_helper.rb index 4bc079eed3..9115632b83 100644 --- a/app/view_utils/paypal_country_helper.rb +++ b/app/view_utils/paypal_country_helper.rb @@ -1,4 +1,3 @@ - # # Specify all country specific PayPal instruction texts / link in this module # @@ -17,7 +16,7 @@ module PaypalCountryHelper "au" => "https://www.paypal.com/au/webapps/mpp/paypal-seller-fees", "no" => "https://www.paypal.com/no/webapps/mpp/paypal-fees", "nz" => "https://www.paypal.com/nz/webapps/mpp/paypal-fees", - "jp" => "https://www.paypal.com/jp/webapps/mpp/paypal-fees", + "jp" => "https://www.paypal.com/jp/webapps/mpp/paypal-fees" } FEE_URL.default = "https://www.paypal.com/cgi-bin/marketingweb?cmd=_display-xborder-fees-outside" @@ -34,13 +33,13 @@ module PaypalCountryHelper "br" => "https://www.paypal.com/br/webapps/mpp/home", "no" => "https://www.paypal.com/no/webapps/mpp/home", "nz" => "https://www.paypal.com/nz/webapps/mpp/home", - "jp" => "https://www.paypal.com/jp/webapps/mpp/home", + "jp" => "https://www.paypal.com/jp/webapps/mpp/home" } POPUP_URL.default = "https://www.paypal.com/webapps/mpp/paypal-popup" CREATE_ACCOUNT_URL = { - "au" => "https://www.paypal.com/au/webapps/mpp/account-selection", + "au" => "https://www.paypal.com/au/webapps/mpp/account-selection" } CREATE_ACCOUNT_URL.default = "https://www.paypal.com/%{country_code}/webapps/mpp/home" @@ -53,13 +52,13 @@ module PaypalCountryHelper UPGRADE_ACCOUNT_URL.default = "https://www.paypal.com/%{country_code}/upgrade" RECEIVE_FUNDS_INFO_LABEL_TR_KEY = { - "au" => "paypal_accounts.paypal_receive_funds_info_label_australia_only", + "au" => "paypal_accounts.paypal_receive_funds_info_label_australia_only" } RECEIVE_FUNDS_INFO_LABEL_TR_KEY.default = "paypal_accounts.paypal_receive_funds_info_label" RECEIVE_FUNDS_INFO_TR_KEY = { - "au" => "paypal_accounts.paypal_receive_funds_info_australia_only", + "au" => "paypal_accounts.paypal_receive_funds_info_australia_only" } RECEIVE_FUNDS_INFO_TR_KEY.default = "paypal_accounts.paypal_receive_funds_info" diff --git a/app/view_utils/search_page_helper.rb b/app/view_utils/search_page_helper.rb index 260547f209..f4383dc409 100644 --- a/app/view_utils/search_page_helper.rb +++ b/app/view_utils/search_page_helper.rb @@ -32,8 +32,8 @@ def searchpage_props(page:, per_page:, bootstrapped_data:, notifications_to_reac locale_param: locale_param, current_path: current_path, landing_page: landing_page, - host_with_port: host_with_port, - }), + host_with_port: host_with_port + }) } end @@ -45,10 +45,10 @@ def parse_filters_from_params(params) { dropdowns: dropdown_field_options_for_search(params), checkboxes: checkbox_field_options_for_search(params), - numeric: numeric_field_options_for_search(params), + numeric: numeric_field_options_for_search(params) }.reject { |_, value| # all means the filter doesn't need to be included - value == "all" || value == ["all"] + value == "all" || value == ["all"] # rubocop:disable Style/MultipleComparison } end diff --git a/app/view_utils/stripe_helper.rb b/app/view_utils/stripe_helper.rb index e215cde14c..2a7a095e23 100644 --- a/app/view_utils/stripe_helper.rb +++ b/app/view_utils/stripe_helper.rb @@ -54,6 +54,7 @@ def user_stripe_active?(community_id, person_id) def publishable_key(community_id) return nil unless StripeHelper.stripe_active?(community_id) + payment_settings = TransactionService::API::Api.settings.get_active_by_gateway(community_id: community_id, payment_gateway: :stripe).maybe.get payment_settings[:api_publishable_key] end diff --git a/app/view_utils/topbar_helper.rb b/app/view_utils/topbar_helper.rb index 62939b89ba..6f32c1ebe0 100644 --- a/app/view_utils/topbar_helper.rb +++ b/app/view_utils/topbar_helper.rb @@ -17,7 +17,7 @@ def topbar_props(community:, path_after_locale_change:, user: nil, search_placeh search_path_string = PathHelpers.search_url({ community_id: community.id, opts: { - only_path: true, + only_path: true } }) @@ -39,7 +39,7 @@ def topbar_props(community:, path_after_locale_change:, user: nil, search_placeh }, search: landing_page ? nil : { search_placeholder: search_placeholder, - mode: main_search.to_s, + mode: main_search.to_s }, search_path: search_path_string, menu: { @@ -51,11 +51,11 @@ def topbar_props(community:, path_after_locale_change:, user: nil, search_placeh avatar: { image: avatar_image, givenName: given_name, - familyName: family_name, - }, + familyName: family_name + } }, newListingButton: { - text: I18n.t("homepage.index.post_new_listing"), + text: I18n.t("homepage.index.post_new_listing") }, i18n: { locale: I18n.locale, @@ -67,7 +67,7 @@ def topbar_props(community:, path_after_locale_change:, user: nil, search_placeh }, user: { loggedInUsername: user&.username, - isAdmin: user&.has_admin_rights?(community) || false, + isAdmin: user&.has_admin_rights?(community) || false }, unReadMessagesCount: InboxService.notification_count(user&.id, community.id) } @@ -151,7 +151,7 @@ def missing_profile_image_path end def paths - @_url_herlpers ||= Rails.application.routes.url_helpers + @_url_herlpers ||= Rails.application.routes.url_helpers # rubocop:disable Naming/MemoizedInstanceVariableName end def link_external?(url, host_with_port) diff --git a/app/view_utils/translation_service_helper.rb b/app/view_utils/translation_service_helper.rb index 8de1040b65..4e681fc094 100644 --- a/app/view_utils/translation_service_helper.rb +++ b/app/view_utils/translation_service_helper.rb @@ -127,7 +127,7 @@ def form_value_to_translation_hashes(form) def translation_hashes_to_tr_key!(hash, community_id, tr_key = nil) TranslationService::API::Api.translations.create( community_id, - [ { translation_key: tr_key, translations: hash} ] + [{ translation_key: tr_key, translations: hash}] ).data.first[:translation_key] end end diff --git a/bin/bundle b/bin/bundle index 66e9889e8b..f19acf5b5c 100755 --- a/bin/bundle +++ b/bin/bundle @@ -1,3 +1,3 @@ #!/usr/bin/env ruby -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) load Gem.bin_path('bundler', 'bundle') diff --git a/custom_plan.rb b/custom_plan.rb index 145e8800f3..7d452f04b3 100644 --- a/custom_plan.rb +++ b/custom_plan.rb @@ -1,6 +1,6 @@ require 'zeus/rails' -require File.expand_path('../test/helper_modules', __FILE__) +require File.expand_path('test/helper_modules', __dir__) class CustomPlan < Zeus::Rails diff --git a/features/step_definitions/admin_custom_field_steps.rb b/features/step_definitions/admin_custom_field_steps.rb index 84c586fef6..d52b6d1ee8 100644 --- a/features/step_definitions/admin_custom_field_steps.rb +++ b/features/step_definitions/admin_custom_field_steps.rb @@ -160,7 +160,7 @@ def find_custom_field_by_name(field_name) @custom_field = FactoryGirl.build(:custom_dropdown_field, { :community_id => current_community.id, :names => [CustomFieldName.create(:value => name, :locale => "en")], - :category_custom_fields => [FactoryGirl.build(:category_custom_field, :category => find_category_by_name(category_name), :custom_field => @custom_field)], + :category_custom_fields => [FactoryGirl.build(:category_custom_field, :category => find_category_by_name(category_name), :custom_field => @custom_field)] }) @custom_field.save end diff --git a/features/step_definitions/admin_look_and_feel_steps.rb b/features/step_definitions/admin_look_and_feel_steps.rb index 3b3791e92c..714c4706ca 100644 --- a/features/step_definitions/admin_look_and_feel_steps.rb +++ b/features/step_definitions/admin_look_and_feel_steps.rb @@ -20,7 +20,7 @@ def hexToRgb(hex) end Given(/^community "(.*?)" has default browse view "(.*?)"$/) do |community, browse_view| - Community.where(ident: community).first.update_attributes(default_browse_view: browse_view) + Community.where(ident: community).first.update(default_browse_view: browse_view) end When(/^I change the default browse view to "(.*?)"$/) do |browse_view| @@ -35,7 +35,7 @@ def hexToRgb(hex) end Given(/^community "(.*?)" has name display type "(.*?)"$/) do |community, name_display_type| - Community.where(ident: community).first.update_attributes(name_display_type: name_display_type) + Community.where(ident: community).first.update(name_display_type: name_display_type) end When(/^I change the name display type to "(.*?)"$/) do |name_display_type| diff --git a/features/step_definitions/community_steps.rb b/features/step_definitions/community_steps.rb index 020512cf7a..6fb6318cd2 100644 --- a/features/step_definitions/community_steps.rb +++ b/features/step_definitions/community_steps.rb @@ -16,7 +16,7 @@ def save_name_and_action(community_id, groups) @hash_community = FactoryGirl.create(:community, :ident => ident, :settings => {"locales" => ["en", "fi"]}) attributes_to_update = hash.except('community') - @hash_community.update_attributes(attributes_to_update) unless attributes_to_update.empty? + @hash_community.update(attributes_to_update) unless attributes_to_update.empty? end end @@ -28,7 +28,7 @@ def save_name_and_action(community_id, groups) #here is expected that the first community is the test community where the subdomain is pointing by default community = Community.first - community.update_attributes({:settings => { "locales" => @locales }}) + community.update({:settings => { "locales" => @locales }}) community.locales.each do |locale| unless community.community_customizations.find_by_locale(locale) community.community_customizations.create(:locale => locale, :name => "Sharetribe") @@ -91,7 +91,7 @@ def save_name_and_action(community_id, groups) end Given /^community "(.*?)" is private$/ do |community_ident| - Community.where(ident: community_ident).first.update_attributes({:private => true}) + Community.where(ident: community_ident).first.update({:private => true}) end Given /^this community is private$/ do @@ -135,8 +135,8 @@ def save_name_and_action(community_id, groups) listing_shapes.hashes.map do |hash| name_tr_key, action_button_tr_key = save_name_and_action(current_community.id, [ - {translations: [ {locale: 'fi', translation: hash['fi']}, {locale: 'en', translation: hash['en']} ]}, - {translations: [ {locale: 'fi', translation: (hash['button'] || 'Action')}, {locale: 'en', translation: (hash['button'] || 'Action')} ]} + {translations: [{locale: 'fi', translation: hash['fi']}, {locale: 'en', translation: hash['en']}]}, + {translations: [{locale: 'fi', translation: (hash['button'] || 'Action')}, {locale: 'en', translation: (hash['button'] || 'Action')}]} ]) ListingShape.create_with_opts( @@ -148,7 +148,7 @@ def save_name_and_action(community_id, groups) action_button_tr_key: action_button_tr_key, transaction_process_id: process_id, basename: hash['en'], - units: [ {unit_type: 'hour', quantity_selector: 'number', kind: 'time'} ] + units: [{unit_type: 'hour', quantity_selector: 'number', kind: 'time'}] } ) end @@ -157,7 +157,7 @@ def save_name_and_action(community_id, groups) end Given /^listing publishing date is shown in community "(.*?)"$/ do |community_ident| - Community.where(ident: community_ident).first.update_attributes({:show_listing_publishing_date => true}) + Community.where(ident: community_ident).first.update({:show_listing_publishing_date => true}) end Given /^current community requires users to be verified to post listings$/ do diff --git a/features/step_definitions/conversation_steps.rb b/features/step_definitions/conversation_steps.rb index 7a12077af8..3a369ba6bc 100644 --- a/features/step_definitions/conversation_steps.rb +++ b/features/step_definitions/conversation_steps.rb @@ -95,7 +95,7 @@ def create_paid_transaction(community, listing, starter, message, payment_gatewa last_transition_at: Time.current, commission_from_seller: settings.commission_from_seller, minimum_commission_cents: 100, - minimum_commission_currency: 'EUR', + minimum_commission_currency: 'EUR' } if booking tx_attributes.merge!( diff --git a/features/step_definitions/email_steps.rb b/features/step_definitions/email_steps.rb index 724e30c8c1..7f44e53228 100644 --- a/features/step_definitions/email_steps.rb +++ b/features/step_definitions/email_steps.rb @@ -36,7 +36,7 @@ @hash_email = FactoryGirl.create(:email, :person => person) attributes_to_update = hash.except('person') - @hash_email.update_attributes(attributes_to_update) unless attributes_to_update.empty? + @hash_email.update(attributes_to_update) unless attributes_to_update.empty? @hash_email # Save @@ -69,7 +69,7 @@ def current_email_address # Replace with your a way to find your current email. e.g @current_user.email # last_email_address will return the last email address used by email spec to find an email. # Note that last_email_address will be reset after each Scenario. - last_email_address || (@logged_in_user && @logged_in_user.confirmed_notification_email_addresses.last) || Thread.current[:latest_used_random_email] || "example@example.com" + last_email_address || (@logged_in_user&.confirmed_notification_email_addresses&.last) || Thread.current[:latest_used_random_email] || "example@example.com" end def open_email_for_current_user diff --git a/features/step_definitions/listing_shape_steps.rb b/features/step_definitions/listing_shape_steps.rb index e9298dced9..2493836e4c 100644 --- a/features/step_definitions/listing_shape_steps.rb +++ b/features/step_definitions/listing_shape_steps.rb @@ -13,7 +13,7 @@ availability: 'booking', name_translation: 'Offering Services', button_translation: 'Request Services', - unit_types: [ 'hour' ] + unit_types: ['hour'] ) end @@ -25,7 +25,7 @@ availability: 'booking', name_translation: 'Offering Services', button_translation: 'Request Services', - unit_types: [ 'hour', 'day', 'night', 'week', 'month' ], + unit_types: ['hour', 'day', 'night', 'week', 'month'], custom_unit_types: ['person', 'kg'] ) end @@ -59,8 +59,8 @@ def create_listing_shape(community:, name:, availability:, name_translation:, bu cached_translations = TranslationService::API::Api.translations.create( community.id, [ - { translations: [ { locale: "en", translation: name_translation }] }, - { translations: [ { locale: "en", translation: button_translation }] } + { translations: [{ locale: "en", translation: name_translation }] }, + { translations: [{ locale: "en", translation: button_translation }] } ] ) name_tr_key, action_button_tr_key = cached_translations[:data].map { |translation| translation[:translation_key] } @@ -86,7 +86,7 @@ def create_listing_shape(community:, name:, availability:, name_translation:, bu # quantity_selector 'number' # kind 'time' def create_unit_types(listing_shape, unit_types) - unit_types && unit_types.each do |unit_type| + unit_types&.each do |unit_type| FactoryGirl.create(:listing_unit, listing_shape_id: listing_shape.id, unit_type: unit_type) end end @@ -96,12 +96,12 @@ def create_unit_types(listing_shape, unit_types) # unit_type 'custom' # kind 'quantity' def create_custom_unit_types(community, listing_shape, unit_types) - unit_types && unit_types.each do |unit_type_name| + unit_types&.each do |unit_type_name| cached_translations = TranslationService::API::Api.translations.create( community.id, [ - { translations: [ { locale: "en", translation: unit_type_name }] }, - { translations: [ { locale: "en", translation: "sel #{unit_type_name}" }] } + { translations: [{ locale: "en", translation: unit_type_name }] }, + { translations: [{ locale: "en", translation: "sel #{unit_type_name}" }] } ] ) name_tr_key, selector_tr_key = cached_translations[:data].map { |translation| translation[:translation_key] } diff --git a/features/step_definitions/listing_steps.rb b/features/step_definitions/listing_steps.rb index c1b1aa79ba..67fa6d67ce 100644 --- a/features/step_definitions/listing_steps.rb +++ b/features/step_definitions/listing_steps.rb @@ -209,7 +209,7 @@ end Given(/^that listing availability is booking$/) do - @listing.update_attributes(availability: :booking, quantity_selector: 'number') + @listing.update(availability: :booking, quantity_selector: 'number') end Given(/^that listing has default working hours$/) do diff --git a/features/step_definitions/onboarding_steps.rb b/features/step_definitions/onboarding_steps.rb index e60bcecc22..270e45ce08 100644 --- a/features/step_definitions/onboarding_steps.rb +++ b/features/step_definitions/onboarding_steps.rb @@ -1,5 +1,3 @@ -# coding: utf-8 - Then("I dismiss the onboarding wizard") do onboarding_wizard = FeatureTests::Section::OnboardingWizard onboarding_wizard.dismiss_dialog diff --git a/features/step_definitions/paypal_steps.rb b/features/step_definitions/paypal_steps.rb index ce13c72ddc..8ae8976941 100644 --- a/features/step_definitions/paypal_steps.rb +++ b/features/step_definitions/paypal_steps.rb @@ -1,5 +1,3 @@ -# coding: utf-8 - Then("I expect transaction with PayPal test to pass") do navigation = FeatureTests::Navigation data = FeatureTests::Data diff --git a/features/step_definitions/stripe_steps.rb b/features/step_definitions/stripe_steps.rb index 5d43097c82..6e7997489a 100644 --- a/features/step_definitions/stripe_steps.rb +++ b/features/step_definitions/stripe_steps.rb @@ -1,5 +1,3 @@ -# coding: utf-8 - Then("I expect transaction with Stripe test to pass") do unless ENV['REAL_STRIPE'] module FakeStripe diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index 3a49f46d28..3ade94b1bf 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -61,7 +61,7 @@ def force_override_model_id(id, model_instance, model_class, associated_model_cl first_name: 'Jackie', last_name: 'Brownie' }, - :extra =>{ + :extra => { :raw_info => { :first_name => "Jackie", :last_name => "Brownie", @@ -88,7 +88,7 @@ def force_override_model_id(id, model_instance, model_class, associated_model_cl membership_created_at = hash['membership_created_at'] person_opts = defaults.merge({ - username: hash['person'], + username: hash['person'] }).merge(hash.except('person', 'membership_created_at', 'community')) @hash_person, @hash_session = Person.find_by(username: username) || FactoryGirl.create(:person, person_opts) @@ -107,7 +107,7 @@ def force_override_model_id(id, model_instance, model_class, associated_model_cl @hash_person.save! end - @hash_person.update_attributes({:preferences => { "email_about_new_comments_to_own_listing" => "true", "email_about_new_messages" => "true" }}) + @hash_person.update({:preferences => { "email_about_new_comments_to_own_listing" => "true", "email_about_new_messages" => "true" }}) cm = CommunityMembership.find_by_person_id_and_community_id(@hash_person.id, community.id) || CommunityMembership.create(:community_id => community.id, :person_id => @hash_person.id, @@ -116,7 +116,7 @@ def force_override_model_id(id, model_instance, model_class, associated_model_cl cm.update_attribute(:created_at, membership_created_at) if membership_created_at && !membership_created_at.empty? attributes_to_update = hash.except('person','person_id', 'locale', 'membership_created_at', 'community') - @hash_person.update_attributes(attributes_to_update) unless attributes_to_update.empty? + @hash_person.update(attributes_to_update) unless attributes_to_update.empty? @hash_person.set_default_preferences if hash['locale'] @hash_person.locale = hash['locale'] @@ -225,7 +225,7 @@ def force_override_model_id(id, model_instance, model_class, associated_model_cl Given(/^"(.*?)" follows everyone$/) do |person| person = Person.find_by(username: person) - person.followed_people = Person.all - [ person ] + person.followed_people = Person.all - [person] end Then(/^I should see (\d+) user profile links$/) do |count| diff --git a/features/step_definitions/web_steps.rb b/features/step_definitions/web_steps.rb index ba44dff129..eaca38758f 100644 --- a/features/step_definitions/web_steps.rb +++ b/features/step_definitions/web_steps.rb @@ -13,6 +13,7 @@ def fill_in_first(locator, options={}) # Highly inspired by Capybara's fill_in implementation # https://github.com/jnicklas/capybara/blob/80befdad73c791eeaea50a7cbe23f04a445a24bc/lib/capybara/node/actions.rb#L50 raise "Must pass a hash containing 'with'" if not options.is_a?(Hash) or not options.has_key?(:with) + with = options.delete(:with) first(:fillable_field, locator, options).set(with) end @@ -21,6 +22,7 @@ def fill_in_nth(locator, n, options={}) # Highly inspired by Capybara's fill_in implementation # https://github.com/jnicklas/capybara/blob/80befdad73c791eeaea50a7cbe23f04a445a24bc/lib/capybara/node/actions.rb#L50 raise "Must pass a hash containing 'with'" if not options.is_a?(Hash) or not options.has_key?(:with) + with = options.delete(:with) results = all(:fillable_field, locator, options) if results.size >= n diff --git a/features/support/env.rb b/features/support/env.rb index 8724cef6f4..55f7fad380 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -5,8 +5,8 @@ # files. require 'rubygems' -require File.expand_path('../../../test/helper_modules', __FILE__) -include TestHelpers +require File.expand_path('../../test/helper_modules', __dir__) +include TestHelpers # rubocop:disable Style/MixinUsage # Require RSpec expectations, so that we can use them in Cucumber features require 'rspec/expectations' diff --git a/features/support/env.rb.database_cleanup.rb b/features/support/env.rb.database_cleanup.rb index 67e955dcb7..32de8fefb4 100644 --- a/features/support/env.rb.database_cleanup.rb +++ b/features/support/env.rb.database_cleanup.rb @@ -7,8 +7,8 @@ # is already defined require 'rubygems' -require File.expand_path('../../../test/helper_modules', __FILE__) -include TestHelpers +require File.expand_path('../../test/helper_modules', __dir__) +include TestHelpers # rubocop:disable Style/MixinUsage require 'database_cleaner' diff --git a/features/support/feature_tests/action/paypal.rb b/features/support/feature_tests/action/paypal.rb index 18f7a7b591..e5de684f4e 100644 --- a/features/support/feature_tests/action/paypal.rb +++ b/features/support/feature_tests/action/paypal.rb @@ -1,4 +1,3 @@ -# coding: utf-8 module FeatureTests module Action module Paypal diff --git a/features/support/feature_tests/action/stripe.rb b/features/support/feature_tests/action/stripe.rb index e47fa51324..773e4455ac 100644 --- a/features/support/feature_tests/action/stripe.rb +++ b/features/support/feature_tests/action/stripe.rb @@ -1,4 +1,3 @@ -# coding: utf-8 module FeatureTests module Action module Stripe diff --git a/features/support/formatter.rb b/features/support/formatter.rb index 20f28d85b5..8a1832268c 100644 --- a/features/support/formatter.rb +++ b/features/support/formatter.rb @@ -1,5 +1,3 @@ -# encoding: utf-8 - require 'fileutils' require 'cucumber/formatter/console' require 'cucumber/formatter/io' @@ -169,6 +167,7 @@ def before_step_result(keyword, step_match, multiline_arg, status, exception, so def step_name(keyword, step_match, status, source_indent, background, file_colon_line) return if @hide_this_step + source_indent = nil unless @options[:source] name_to_report = format_step(keyword, step_match, status, source_indent) @@ -190,6 +189,7 @@ def doc_string(string) def exception(exception, status) return if @hide_this_step + print_messages buffer_print_exception(exception, status, @indent) end @@ -215,12 +215,14 @@ def after_multiline_arg(multiline_arg) def before_table_row(table_row) return if !@table || @hide_this_step + @col_index = 0 buffer_print ' |'.indent(@indent-2) end def after_table_row(table_row) return if !@table || @hide_this_step + print_table_row_messages buffer_puts if table_row.exception && !@exceptions.include?(table_row.exception) @@ -230,11 +232,13 @@ def after_table_row(table_row) def after_table_cell(cell) return unless @table + @col_index += 1 end def table_cell_value(value, status) return if !@table || @hide_this_step + status ||= @status || :passed width = @table.col_width(@col_index) cell_text = escape_cell(value.to_s || '') diff --git a/features/support/omniauth.rb b/features/support/omniauth.rb index b65327dac4..3be6a99521 100644 --- a/features/support/omniauth.rb +++ b/features/support/omniauth.rb @@ -109,7 +109,7 @@ def oauth_google_data hd: 'ithouse.lv', email: 'john@ithouse.lv', iat: 1474618935, - exp: 1474622535, + exp: 1474622535 }, raw_info: { kind: 'plus#personOpenIdConnect', @@ -123,7 +123,7 @@ def oauth_google_data email: 'john@ithouse.lv', email_verified: 'true', locale: 'lv', - hd: 'ithouse.lv', + hd: 'ithouse.lv' } } } @@ -131,145 +131,145 @@ def oauth_google_data # rubocop:disable Metrics/MethodLength def oauth_linkedin_data - {"provider"=>"linkedin", - "uid"=>"50k-SSSS99", - "info"=> - {"email"=>"devel@example.com", - "first_name"=>"Tony", - "last_name"=>"Testmen", - "picture_url"=> + {"provider" => "linkedin", + "uid" => "50k-SSSS99", + "info" => + {"email" => "devel@example.com", + "first_name" => "Tony", + "last_name" => "Testmen", + "picture_url" => "https://media.licdn.com/dms/image/C5603AQEK2H8SiE59Jw/profile-displayphoto-shrink_800_800/0?e=1553126400&v=beta&t=9Zg8_GZwAKl_Za2CF5IgC-gD2XvHjupCm_8wqdQjvVk"}, - "credentials"=> - {"token"=> + "credentials" => + {"token" => "12345678-DGT50OyLxmjzY9SssMxeBSEpDC2R25vr68hVy3HwRcU5jDmLhg2UKsPDWBCoQo9XyE4BG84xFNLZ3RDUzAoEJLVGBAxh99cLWjSc9ghODpIwfv3A6rLn4yx3Cs1IR2L9ofWtOoXmUVWoKfM2Mj4Bj_OHoVzt47wCxWQfq1gL28Ro8IP4qMrheWCr2TzX1QHHs0XdhytStcos3C_D6XmhhpFTMaHL5W06ej7eIn5dJJIr_xNu-u7LtgDTU0h3v0wMlkmcXFKnY_iZZ3SldyLJs-6E00YonU6unhuxLz5Zzj2hEZ1gNVEgEvQqCS6EDTiNfUTfu1PBIYPIqqqqQQQQ", - "expires_at"=>1552727705, - "expires"=>true}, - "extra"=> - {"raw_info"=> - {"firstName"=> - {"localized"=>{"en_US"=>"Tony"}, - "preferredLocale"=>{"country"=>"US", "language"=>"en"}}, - "lastName"=> - {"localized"=>{"en_US"=>"Testmen"}, - "preferredLocale"=>{"country"=>"US", "language"=>"en"}}, - "profilePicture"=> - {"displayImage"=>"urn:li:digitalmediaAsset:C5603AQEK2H8SiE59Jw", - "displayImage~"=> - {"elements"=> - [{"artifact"=> + "expires_at" => 1552727705, + "expires" => true}, + "extra" => + {"raw_info" => + {"firstName" => + {"localized" => {"en_US"=>"Tony"}, + "preferredLocale" => {"country"=>"US", "language"=>"en"}}, + "lastName" => + {"localized" => {"en_US"=>"Testmen"}, + "preferredLocale" => {"country"=>"US", "language"=>"en"}}, + "profilePicture" => + {"displayImage" => "urn:li:digitalmediaAsset:C5603AQEK2H8SiE59Jw", + "displayImage~" => + {"elements" => + [{"artifact" => "urn:li:digitalmediaMediaArtifact:(urn:li:digitalmediaAsset:C5603AQEK2H8SiE59Jw,urn:li:digitalmediaMediaArtifactClass:profile-displayphoto-shrink_100_100)", - "authorizationMethod"=>"PUBLIC", - "data"=> - {"com.linkedin.digitalmedia.mediaartifact.StillImage"=> - {"storageSize"=>{"width"=>100, "height"=>100}, - "storageAspectRatio"=> - {"widthAspect"=>1.0, - "heightAspect"=>1.0, - "formatted"=>"1.00:1.00"}, - "mediaType"=>"image/jpeg", - "rawCodecSpec"=>{"name"=>"jpeg", "type"=>"image"}, - "displaySize"=>{"uom"=>"PX", "width"=>100.0, "height"=>100.0}, - "displayAspectRatio"=> - {"widthAspect"=>1.0, - "heightAspect"=>1.0, - "formatted"=>"1.00:1.00"}}}, - "identifiers"=> - [{"identifier"=> + "authorizationMethod" => "PUBLIC", + "data" => + {"com.linkedin.digitalmedia.mediaartifact.StillImage" => + {"storageSize" => {"width"=>100, "height"=>100}, + "storageAspectRatio" => + {"widthAspect" => 1.0, + "heightAspect" => 1.0, + "formatted" => "1.00:1.00"}, + "mediaType" => "image/jpeg", + "rawCodecSpec" => {"name"=>"jpeg", "type"=>"image"}, + "displaySize" => {"uom"=>"PX", "width"=>100.0, "height"=>100.0}, + "displayAspectRatio" => + {"widthAspect" => 1.0, + "heightAspect" => 1.0, + "formatted" => "1.00:1.00"}}}, + "identifiers" => + [{"identifier" => "https://media.licdn.com/dms/image/C5603AQEK2H8SiE59Jw/profile-displayphoto-shrink_100_100/0?e=1553126400&v=beta&t=eHikoEd4N3NbHu90XtlQD8VM6oX9guudosWLpjD1XjA", - "file"=> + "file" => "urn:li:digitalmediaFile:(urn:li:digitalmediaAsset:C5603AQEK2H8SiE59Jw,urn:li:digitalmediaMediaArtifactClass:profile-displayphoto-shrink_100_100,0)", - "index"=>0, - "mediaType"=>"image/jpeg", - "identifierType"=>"EXTERNAL_URL", - "identifierExpiresInSeconds"=>1553126400}]}, - {"artifact"=> + "index" => 0, + "mediaType" => "image/jpeg", + "identifierType" => "EXTERNAL_URL", + "identifierExpiresInSeconds" => 1553126400}]}, + {"artifact" => "urn:li:digitalmediaMediaArtifact:(urn:li:digitalmediaAsset:C5603AQEK2H8SiE59Jw,urn:li:digitalmediaMediaArtifactClass:profile-displayphoto-shrink_200_200)", - "authorizationMethod"=>"PUBLIC", - "data"=> - {"com.linkedin.digitalmedia.mediaartifact.StillImage"=> - {"storageSize"=>{"width"=>200, "height"=>200}, - "storageAspectRatio"=> - {"widthAspect"=>1.0, - "heightAspect"=>1.0, - "formatted"=>"1.00:1.00"}, - "mediaType"=>"image/jpeg", - "rawCodecSpec"=>{"name"=>"jpeg", "type"=>"image"}, - "displaySize"=>{"uom"=>"PX", "width"=>200.0, "height"=>200.0}, - "displayAspectRatio"=> - {"widthAspect"=>1.0, - "heightAspect"=>1.0, - "formatted"=>"1.00:1.00"}}}, - "identifiers"=> - [{"identifier"=> + "authorizationMethod" => "PUBLIC", + "data" => + {"com.linkedin.digitalmedia.mediaartifact.StillImage" => + {"storageSize" => {"width"=>200, "height"=>200}, + "storageAspectRatio" => + {"widthAspect" => 1.0, + "heightAspect" => 1.0, + "formatted" => "1.00:1.00"}, + "mediaType" => "image/jpeg", + "rawCodecSpec" => {"name"=>"jpeg", "type"=>"image"}, + "displaySize" => {"uom"=>"PX", "width"=>200.0, "height"=>200.0}, + "displayAspectRatio" => + {"widthAspect" => 1.0, + "heightAspect" => 1.0, + "formatted" => "1.00:1.00"}}}, + "identifiers" => + [{"identifier" => "https://media.licdn.com/dms/image/C5603AQEK2H8SiE59Jw/profile-displayphoto-shrink_200_200/0?e=1553126400&v=beta&t=S7WhbAux-oy5a4nUt_p46xRCO-o25PHAExFVG2R8FDE", - "file"=> + "file" => "urn:li:digitalmediaFile:(urn:li:digitalmediaAsset:C5603AQEK2H8SiE59Jw,urn:li:digitalmediaMediaArtifactClass:profile-displayphoto-shrink_200_200,0)", - "index"=>0, - "mediaType"=>"image/jpeg", - "identifierType"=>"EXTERNAL_URL", - "identifierExpiresInSeconds"=>1553126400}]}, - {"artifact"=> + "index" => 0, + "mediaType" => "image/jpeg", + "identifierType" => "EXTERNAL_URL", + "identifierExpiresInSeconds" => 1553126400}]}, + {"artifact" => "urn:li:digitalmediaMediaArtifact:(urn:li:digitalmediaAsset:C5603AQEK2H8SiE59Jw,urn:li:digitalmediaMediaArtifactClass:profile-displayphoto-shrink_400_400)", - "authorizationMethod"=>"PUBLIC", - "data"=> - {"com.linkedin.digitalmedia.mediaartifact.StillImage"=> - {"storageSize"=>{"width"=>400, "height"=>400}, - "storageAspectRatio"=> - {"widthAspect"=>1.0, - "heightAspect"=>1.0, - "formatted"=>"1.00:1.00"}, - "mediaType"=>"image/jpeg", - "rawCodecSpec"=>{"name"=>"jpeg", "type"=>"image"}, - "displaySize"=>{"uom"=>"PX", "width"=>400.0, "height"=>400.0}, - "displayAspectRatio"=> - {"widthAspect"=>1.0, - "heightAspect"=>1.0, - "formatted"=>"1.00:1.00"}}}, - "identifiers"=> - [{"identifier"=> + "authorizationMethod" => "PUBLIC", + "data" => + {"com.linkedin.digitalmedia.mediaartifact.StillImage" => + {"storageSize" => {"width"=>400, "height"=>400}, + "storageAspectRatio" => + {"widthAspect" => 1.0, + "heightAspect" => 1.0, + "formatted" => "1.00:1.00"}, + "mediaType" => "image/jpeg", + "rawCodecSpec" => {"name"=>"jpeg", "type"=>"image"}, + "displaySize" => {"uom"=>"PX", "width"=>400.0, "height"=>400.0}, + "displayAspectRatio" => + {"widthAspect" => 1.0, + "heightAspect" => 1.0, + "formatted" => "1.00:1.00"}}}, + "identifiers" => + [{"identifier" => "https://media.licdn.com/dms/image/C5603AQEK2H8SiE59Jw/profile-displayphoto-shrink_400_400/0?e=1553126400&v=beta&t=o7XXBfFBhd2Y_Tufd1Y4EjndAxrxSDg6MUmpEdMByS0", - "file"=> + "file" => "urn:li:digitalmediaFile:(urn:li:digitalmediaAsset:C5603AQEK2H8SiE59Jw,urn:li:digitalmediaMediaArtifactClass:profile-displayphoto-shrink_400_400,0)", - "index"=>0, - "mediaType"=>"image/jpeg", - "identifierType"=>"EXTERNAL_URL", - "identifierExpiresInSeconds"=>1553126400}]}, - {"artifact"=> + "index" => 0, + "mediaType" => "image/jpeg", + "identifierType" => "EXTERNAL_URL", + "identifierExpiresInSeconds" => 1553126400}]}, + {"artifact" => "urn:li:digitalmediaMediaArtifact:(urn:li:digitalmediaAsset:C5603AQEK2H8SiE59Jw,urn:li:digitalmediaMediaArtifactClass:profile-displayphoto-shrink_800_800)", - "authorizationMethod"=>"PUBLIC", - "data"=> - {"com.linkedin.digitalmedia.mediaartifact.StillImage"=> - {"storageSize"=>{"width"=>800, "height"=>800}, - "storageAspectRatio"=> - {"widthAspect"=>1.0, - "heightAspect"=>1.0, - "formatted"=>"1.00:1.00"}, - "mediaType"=>"image/jpeg", - "rawCodecSpec"=>{"name"=>"jpeg", "type"=>"image"}, - "displaySize"=>{"uom"=>"PX", "width"=>800.0, "height"=>800.0}, - "displayAspectRatio"=> - {"widthAspect"=>1.0, - "heightAspect"=>1.0, - "formatted"=>"1.00:1.00"}}}, - "identifiers"=> - [{"identifier"=> + "authorizationMethod" => "PUBLIC", + "data" => + {"com.linkedin.digitalmedia.mediaartifact.StillImage" => + {"storageSize" => {"width"=>800, "height"=>800}, + "storageAspectRatio" => + {"widthAspect" => 1.0, + "heightAspect" => 1.0, + "formatted" => "1.00:1.00"}, + "mediaType" => "image/jpeg", + "rawCodecSpec" => {"name"=>"jpeg", "type"=>"image"}, + "displaySize" => {"uom"=>"PX", "width"=>800.0, "height"=>800.0}, + "displayAspectRatio" => + {"widthAspect" => 1.0, + "heightAspect" => 1.0, + "formatted" => "1.00:1.00"}}}, + "identifiers" => + [{"identifier" => "https://media.licdn.com/dms/image/C5603AQEK2H8SiE59Jw/profile-displayphoto-shrink_800_800/0?e=1553126400&v=beta&t=9Zg8_GZwAKl_Za2CF5IgC-gD2XvHjupCm_8wqdQjvVk", - "file"=> + "file" => "urn:li:digitalmediaFile:(urn:li:digitalmediaAsset:C5603AQEK2H8SiE59Jw,urn:li:digitalmediaMediaArtifactClass:profile-displayphoto-shrink_800_800,0)", - "index"=>0, - "mediaType"=>"image/jpeg", - "identifierType"=>"EXTERNAL_URL", - "identifierExpiresInSeconds"=>1553126400}]}], - "paging"=>{"count"=>10, "start"=>0, "links"=>[]}}}, - "id"=>"50k-SSSS99"}}} + "index" => 0, + "mediaType" => "image/jpeg", + "identifierType" => "EXTERNAL_URL", + "identifierExpiresInSeconds" => 1553126400}]}], + "paging" => {"count"=>10, "start"=>0, "links"=>[]}}}, + "id" => "50k-SSSS99"}}} end def stub_linkedin_image_request stub_request(:get, "https://media.licdn.com/dms/image/C5603AQEK2H8SiE59Jw/profile-displayphoto-shrink_800_800/0?e=1553126400&t=9Zg8_GZwAKl_Za2CF5IgC-gD2XvHjupCm_8wqdQjvVk&v=beta") .with( headers: { - 'Accept'=>'*/*', - 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', - 'User-Agent'=>'Ruby' + 'Accept' => '*/*', + 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent' => 'Ruby' }) .to_return(status: 200, body: png_image, headers: {'Content-Type'=>'image/png'}) end @@ -277,9 +277,9 @@ def stub_linkedin_image_request def stub_google_image_request stub_request(:get, "https://lh3.googleusercontent.com/-BILLeKNfUNs/AAAAAAAAAAI/AAAAAAAAAAA/bk9ax13dM2E/photo.jpg") .with( headers: { - 'Accept'=>'*/*', - 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', - 'User-Agent'=>'Ruby', + 'Accept' => '*/*', + 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent' => 'Ruby' }) .to_return(status: 200, body: png_image, headers: {'Content-Type'=>'image/png'}) end diff --git a/features/support/rename.rb b/features/support/rename.rb index 1724d44994..ad1689d610 100644 --- a/features/support/rename.rb +++ b/features/support/rename.rb @@ -114,7 +114,7 @@ def step_name(keyword, step_match, status, source_indent, background, file_colon # %Q{/^there is (item|favor|housing) (offer|request) with title "([^"]*)"(?: from "([^"]*)")?(?: and with share type "([^"]*)")?(?: and with price "([^"]*)")?$/} => :rename1, # %Q{/^there is rideshare (offer|request) from "([^"]*)" to "([^"]*)" by "([^"]*)"$/} => :rename_rideshare }.select do |source, replace_method| - step_match && step_match.step_definition && step_match.step_definition.regexp_source == source + step_match&.step_definition && step_match.step_definition.regexp_source == source end.each do |source, replace_method| search = "#{keyword}#{step_match.format_args}" replace = self.send replace_method, *[keyword, step_match.args].flatten diff --git a/features/support/warden.rb b/features/support/warden.rb index 83c133fbec..01cb2e4cbc 100644 --- a/features/support/warden.rb +++ b/features/support/warden.rb @@ -1,5 +1,5 @@ # gives us the login_as(@user) method when request object is not present -include Warden::Test::Helpers +include Warden::Test::Helpers # rubocop:disable Style/MixinUsage Warden.test_mode! After do |scenario| diff --git a/features/support/world.rb b/features/support/world.rb index 93758503dd..11f7ef5850 100644 --- a/features/support/world.rb +++ b/features/support/world.rb @@ -1,5 +1,5 @@ require 'cucumber/rspec/doubles' -require File.expand_path('../../../test/helper_modules', __FILE__) +require File.expand_path('../../test/helper_modules', __dir__) World(TestHelpers) World(Rack::Test::Methods) diff --git a/lib/services/paypal_service/test_logger.rb b/lib/services/paypal_service/test_logger.rb index 7b942551b7..0077f83132 100644 --- a/lib/services/paypal_service/test_logger.rb +++ b/lib/services/paypal_service/test_logger.rb @@ -1,6 +1,6 @@ module PaypalService class TestLogger - def method_missing(m, *args, &block) + def method_missing(m, *args, &block) # rubocop:disable Style/MissingRespondToMissing # Do nothing end end diff --git a/lib/services/paypal_service/test_merchant.rb b/lib/services/paypal_service/test_merchant.rb index 6d2642a2c7..bca4eff471 100644 --- a/lib/services/paypal_service/test_merchant.rb +++ b/lib/services/paypal_service/test_merchant.rb @@ -96,7 +96,7 @@ def authorize_payment(order_id, authorization_total) authorization_total: authorization_total, authorization_id: auth_id, payment_status: "pending", - pending_reason: "authorization", + pending_reason: "authorization" }) @payments_by_order_id[order_id] = auth_payment diff --git a/lib/sharetribe_logger.rb b/lib/sharetribe_logger.rb index 6ebc0f3cd3..a16e4e0444 100644 --- a/lib/sharetribe_logger.rb +++ b/lib/sharetribe_logger.rb @@ -32,6 +32,7 @@ def add_metadata(new_data) if unknown_keys.present? raise ArgumentError.new("Unknown metadata keys: #{unknown_keys}") end + @metadata = @metadata.merge(new_data.slice(*@metadata_keys)) end @@ -46,7 +47,7 @@ def to_hash(msg, type, structured) tag: @tag, free: msg, type: type, - structured: structured, + structured: structured }) end diff --git a/lib/sharetribe_middleware.rb b/lib/sharetribe_middleware.rb index 9dbb620ba3..185cd693ac 100644 --- a/lib/sharetribe_middleware.rb +++ b/lib/sharetribe_middleware.rb @@ -1,6 +1,6 @@ -require File.expand_path('../rack_middleware/custom_cookie_renamer', __FILE__) -require File.expand_path('../rack_middleware/enforce_ssl', __FILE__) -require File.expand_path('../rack_middleware/health_check', __FILE__) -require File.expand_path('../rack_middleware/marketplace_lookup', __FILE__) -require File.expand_path('../rack_middleware/robots_generator', __FILE__) -require File.expand_path('../rack_middleware/session_context_middleware', __FILE__) +require File.expand_path('rack_middleware/custom_cookie_renamer', __dir__) +require File.expand_path('rack_middleware/enforce_ssl', __dir__) +require File.expand_path('rack_middleware/health_check', __dir__) +require File.expand_path('rack_middleware/marketplace_lookup', __dir__) +require File.expand_path('rack_middleware/robots_generator', __dir__) +require File.expand_path('rack_middleware/session_context_middleware', __dir__) diff --git a/lib/tasks/auto_annotate_models.rake b/lib/tasks/auto_annotate_models.rake index f85503d5bf..9cc07a0c6f 100644 --- a/lib/tasks/auto_annotate_models.rake +++ b/lib/tasks/auto_annotate_models.rake @@ -6,27 +6,27 @@ if Rails.env.development? # You can override any of these by setting an environment variable of the # same name. Annotate.set_defaults({ - 'position_in_routes' => "before", - 'position_in_class' => "before", - 'position_in_test' => "before", - 'position_in_fixture' => "before", - 'position_in_factory' => "before", - 'show_indexes' => "true", - 'simple_indexes' => "false", - 'model_dir' => "app/models", - 'include_version' => "false", - 'require' => "", - 'exclude_tests' => "false", - 'exclude_fixtures' => "false", - 'exclude_factories' => "false", + 'position_in_routes' => "before", + 'position_in_class' => "before", + 'position_in_test' => "before", + 'position_in_fixture' => "before", + 'position_in_factory' => "before", + 'show_indexes' => "true", + 'simple_indexes' => "false", + 'model_dir' => "app/models", + 'include_version' => "false", + 'require' => "", + 'exclude_tests' => "false", + 'exclude_fixtures' => "false", + 'exclude_factories' => "false", 'ignore_model_sub_dir' => "false", - 'skip_on_db_migrate' => "false", - 'format_bare' => "true", - 'format_rdoc' => "false", - 'format_markdown' => "false", - 'sort' => "false", - 'force' => "false", - 'trace' => "false", + 'skip_on_db_migrate' => "false", + 'format_bare' => "true", + 'format_rdoc' => "false", + 'format_markdown' => "false", + 'sort' => "false", + 'force' => "false", + 'trace' => "false" }) end diff --git a/lib/tasks/cs_extract.rake b/lib/tasks/cs_extract.rake index f4834929aa..17ca6f491c 100644 --- a/lib/tasks/cs_extract.rake +++ b/lib/tasks/cs_extract.rake @@ -21,30 +21,30 @@ namespace :sharetribe do def default_variable_hash { - "link" => "#000000", - "link2" => "#000000", - "slogancolor" => "#000000", - "descriptioncolor" => "#000000", - "cover-photo-url" => "\"default-cover-photo\"", - "small-cover-photo-url" => "\"default-small-cover-photo\"", - "wide-logo-lowres-url" => "\"default-wide-logo-lowres\"", - "wide-logo-highres-url" => "\"default-wide-logo-highres\"", - "square-logo-lowres-url" => "\"default-square-logo-lowres\"", + "link" => "#000000", + "link2" => "#000000", + "slogancolor" => "#000000", + "descriptioncolor" => "#000000", + "cover-photo-url" => "\"default-cover-photo\"", + "small-cover-photo-url" => "\"default-small-cover-photo\"", + "wide-logo-lowres-url" => "\"default-wide-logo-lowres\"", + "wide-logo-highres-url" => "\"default-wide-logo-highres\"", + "square-logo-lowres-url" => "\"default-square-logo-lowres\"", "square-logo-highres-url" => "\"default-square-logo-highres\"" } end def custom_variable_hash { - "link" => "##{CUSTOM_COLOR1}", - "link2" => "##{CUSTOM_COLOR2}", - "slogancolor" => "##{CUSTOM_COLOR3}", - "descriptioncolor" => "##{CUSTOM_COLOR4}", - "cover-photo-url" => "\"cover-photo\"", - "small-cover-photo-url" => "\"small-cover-photo\"", - "wide-logo-lowres-url" => "\"wide-logo-lowres\"", - "wide-logo-highres-url" => "\"wide-logo-highres\"", - "square-logo-lowres-url" => "\"square-logo-lowres\"", + "link" => "##{CUSTOM_COLOR1}", + "link2" => "##{CUSTOM_COLOR2}", + "slogancolor" => "##{CUSTOM_COLOR3}", + "descriptioncolor" => "##{CUSTOM_COLOR4}", + "cover-photo-url" => "\"cover-photo\"", + "small-cover-photo-url" => "\"small-cover-photo\"", + "wide-logo-lowres-url" => "\"wide-logo-lowres\"", + "wide-logo-highres-url" => "\"wide-logo-highres\"", + "square-logo-lowres-url" => "\"square-logo-lowres\"", "square-logo-highres-url" => "\"square-logo-highres\"" } end diff --git a/lib/tasks/cucumber.rake b/lib/tasks/cucumber.rake index 5f33d50e7c..9a19e771a2 100644 --- a/lib/tasks/cucumber.rake +++ b/lib/tasks/cucumber.rake @@ -46,7 +46,7 @@ begin task :default => :cucumber task :features => :cucumber do - STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***" + warn "*** The 'features' task is deprecated. See rake -T cucumber ***" end # In case we don't have ActiveRecord, append a no-op task that we can depend upon. diff --git a/lib/tasks/sharetribe.rake b/lib/tasks/sharetribe.rake index e9cd706147..be8fc0b42a 100644 --- a/lib/tasks/sharetribe.rake +++ b/lib/tasks/sharetribe.rake @@ -47,6 +47,7 @@ namespace :sharetribe do if community_ident.blank? raise 'Invalid marketplace ident.' end + community = Community.find_by!(ident: community_ident) PersonPhoneCopyist.copy_community(community) end @@ -57,6 +58,7 @@ namespace :sharetribe do if community_ident.blank? raise 'Invalid marketplace ident.' end + community = Community.find_by!(ident: community_ident) community.person_custom_fields.phone_number.destroy_all end diff --git a/lib/tasks/sharetribe_data_deletion.rake b/lib/tasks/sharetribe_data_deletion.rake index 39a368b25b..8703030bae 100644 --- a/lib/tasks/sharetribe_data_deletion.rake +++ b/lib/tasks/sharetribe_data_deletion.rake @@ -39,7 +39,7 @@ namespace :sharetribe do AND mp.expires_at IS NOT NULL -- To be extra safe AND mp.expires_at < '#{date}' -- Change to desired value ORDER BY 2; -SQL + SQL r = ActiveRecord::Base.connection.execute(query) r.map { |row| row[0] } end @@ -65,7 +65,7 @@ SQL AND mt.expires_at IS NOT NULL -- To be extra safe AND mt.expires_at < '#{date}' -- Change to desired value ORDER BY 2; -SQL + SQL r = ActiveRecord::Base.connection.execute(query) r.map { |row| row[0] } end @@ -115,7 +115,7 @@ SQL DELETE FROM marketplace_plans WHERE community_id = #{id}; DELETE FROM marketplace_trials WHERE community_id = #{id}; -SQL + SQL sql.split(/;/).map { |q| q.strip }.reject { |q| q.empty? } end @@ -228,7 +228,7 @@ SQL DELETE FROM payment_settings WHERE community_id = #{id}; DELETE FROM community_social_logos WHERE community_id = #{id}; -SQL + SQL sql.split(/;/).map { |q| q.strip }.reject { |q| q.empty? } end @@ -329,7 +329,7 @@ SQL ListingImage.where(listing_id: listing_id).delete_all Listing.find(listing_id).destroy - rescue => e + rescue StandardError => e puts "Destroy listing failed for #{listing_id}: #{e.message}" end end @@ -341,7 +341,7 @@ SQL deleted_count += 1 Person.find(person_id).destroy - rescue => e + rescue StandardError => e puts "Destroy person failed for #{person_id}: #{e.message}" end end diff --git a/script/rails b/script/rails index f8da2cffd4..f653fc8deb 100755 --- a/script/rails +++ b/script/rails @@ -1,6 +1,6 @@ #!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. -APP_PATH = File.expand_path('../../config/application', __FILE__) -require File.expand_path('../../config/boot', __FILE__) +APP_PATH = File.expand_path('../config/application', __dir__) +require File.expand_path('../config/boot', __dir__) require 'rails/commands' diff --git a/spec/controllers/admin/communities/footer_controller_spec.rb b/spec/controllers/admin/communities/footer_controller_spec.rb index 5987d2b84a..f7086a9903 100644 --- a/spec/controllers/admin/communities/footer_controller_spec.rb +++ b/spec/controllers/admin/communities/footer_controller_spec.rb @@ -23,67 +23,67 @@ describe "#update" do it 'works' do - params = {"community"=> - {"footer_theme"=>"light", - "footer_enabled"=>1, - "footer_menu_links_attributes"=> - {"0"=> - {"id"=>"", - "entity_type"=>"for_footer", - "sort_priority"=>"0", - "_destroy"=>"false", - "translation_attributes"=> + params = {"community" => + {"footer_theme" => "light", + "footer_enabled" => 1, + "footer_menu_links_attributes" => + {"0" => + {"id" => "", + "entity_type" => "for_footer", + "sort_priority" => "0", + "_destroy" => "false", + "translation_attributes" => {"en"=>{"title"=>"ccc", "url"=>"http://example.com"}}}}, - "footer_copyright"=>"Sample", - "social_links_attributes"=> - {"0"=> - {"id"=>"", - "sort_priority"=>"0", - "provider"=>"youtube", - "enabled"=>"1", - "url"=>"hoho"}, - "1"=> - {"id"=>"", - "sort_priority"=>"1", - "provider"=>"facebook", - "enabled"=>"0", - "url"=>""}, - "2"=> - {"id"=>"", - "sort_priority"=>"2", - "provider"=>"twitter", - "enabled"=>"0", - "url"=>""}, - "3"=> - {"id"=>"", - "sort_priority"=>"3", - "provider"=>"instagram", - "enabled"=>"0", - "url"=>""}, - "4"=> - {"id"=>"", - "sort_priority"=>"4", - "provider"=>"googleplus", - "enabled"=>"0", - "url"=>""}, - "5"=> - {"id"=>"", - "sort_priority"=>"5", - "provider"=>"linkedin", - "enabled"=>"0", - "url"=>""}, - "6"=> - {"id"=>"", - "sort_priority"=>"6", - "provider"=>"pinterest", - "enabled"=>"0", - "url"=>""}, - "7"=> - {"id"=>"", - "sort_priority"=>"7", - "provider"=>"soundcloud", - "enabled"=>"0", - "url"=>""} + "footer_copyright" => "Sample", + "social_links_attributes" => + {"0" => + {"id" => "", + "sort_priority" => "0", + "provider" => "youtube", + "enabled" => "1", + "url" => "hoho"}, + "1" => + {"id" => "", + "sort_priority" => "1", + "provider" => "facebook", + "enabled" => "0", + "url" => ""}, + "2" => + {"id" => "", + "sort_priority" => "2", + "provider" => "twitter", + "enabled" => "0", + "url" => ""}, + "3" => + {"id" => "", + "sort_priority" => "3", + "provider" => "instagram", + "enabled" => "0", + "url" => ""}, + "4" => + {"id" => "", + "sort_priority" => "4", + "provider" => "googleplus", + "enabled" => "0", + "url" => ""}, + "5" => + {"id" => "", + "sort_priority" => "5", + "provider" => "linkedin", + "enabled" => "0", + "url" => ""}, + "6" => + {"id" => "", + "sort_priority" => "6", + "provider" => "pinterest", + "enabled" => "0", + "url" => ""}, + "7" => + {"id" => "", + "sort_priority" => "7", + "provider" => "soundcloud", + "enabled" => "0", + "url" => ""} } } diff --git a/spec/controllers/admin/communities/topbar_controller_spec.rb b/spec/controllers/admin/communities/topbar_controller_spec.rb index ba8c29cb0a..5ea15151a8 100644 --- a/spec/controllers/admin/communities/topbar_controller_spec.rb +++ b/spec/controllers/admin/communities/topbar_controller_spec.rb @@ -22,7 +22,7 @@ text_en = "Modified en" translations_group = [{ translation_key: "homepage.index.post_new_listing", - translations: [{ locale: "en", translation: text_en }, { locale: "fi", translation: text_fi } ] + translations: [{ locale: "en", translation: text_en }, { locale: "fi", translation: text_fi }] }] RequestStore.store[:clp_enabled] = false diff --git a/spec/controllers/admin/communities_controller_spec.rb b/spec/controllers/admin/communities_controller_spec.rb index 0efc3a50b5..5fff1d2565 100644 --- a/spec/controllers/admin/communities_controller_spec.rb +++ b/spec/controllers/admin/communities_controller_spec.rb @@ -159,7 +159,7 @@ community_customizations_attributes: { id: community_customization.id, social_media_title: 'Hard Pill to Swallow', - social_media_description: 'I think I will buy the red car, or I will lease the blue one.', + social_media_description: 'I think I will buy the red car, or I will lease the blue one.' } } } diff --git a/spec/controllers/admin/community_seo_settings_controller_spec.rb b/spec/controllers/admin/community_seo_settings_controller_spec.rb index 0a62349352..f1b916411b 100644 --- a/spec/controllers/admin/community_seo_settings_controller_spec.rb +++ b/spec/controllers/admin/community_seo_settings_controller_spec.rb @@ -22,7 +22,7 @@ search_meta_title: "Modified EN search title", search_meta_description: "Modified EN search description", listing_meta_title: "Modified EN listing title", listing_meta_description: "Modified EN listing description", profile_meta_title: "Modified EN profile title", profile_meta_description: "Modified EN profile description", - category_meta_title: "Modified EN category title", category_meta_description: "Modified EN category description", + category_meta_title: "Modified EN category title", category_meta_description: "Modified EN category description" } } } diff --git a/spec/controllers/communities_controller_spec.rb b/spec/controllers/communities_controller_spec.rb index 829286e86b..12d915b5ef 100644 --- a/spec/controllers/communities_controller_spec.rb +++ b/spec/controllers/communities_controller_spec.rb @@ -127,7 +127,7 @@ marketplace_name: 'Pearl', marketplace_type: 'product', marketplace_country: 'FI', - marketplace_language: 'en', + marketplace_language: 'en' } end subject { post :create, params: params } diff --git a/spec/controllers/int_api/listings_controller_spec.rb b/spec/controllers/int_api/listings_controller_spec.rb index b38c0c1c8e..3f34ed87f6 100644 --- a/spec/controllers/int_api/listings_controller_spec.rb +++ b/spec/controllers/int_api/listings_controller_spec.rb @@ -43,7 +43,7 @@ expect(listing.working_time_slots.count).to eq 0 working_time_slot = JSON.parse(response.body)["working_time_slots"].first expect(working_time_slot["errors"]).to eq({ - "from"=>["\"Start time\" must be less than \"End time\""], "till"=>["\"Start time\" must be less than \"End time\""] + "from" => ["\"Start time\" must be less than \"End time\""], "till"=>["\"Start time\" must be less than \"End time\""] }) end end diff --git a/spec/controllers/int_api/marketplaces_controller_spec.rb b/spec/controllers/int_api/marketplaces_controller_spec.rb index aeebe7e285..ca390093df 100644 --- a/spec/controllers/int_api/marketplaces_controller_spec.rb +++ b/spec/controllers/int_api/marketplaces_controller_spec.rb @@ -1,5 +1,3 @@ -# encoding: utf-8 - require 'spec_helper' # Override the API with test API diff --git a/spec/controllers/listing_images_controller_spec.rb b/spec/controllers/listing_images_controller_spec.rb index 4ae6fe43c4..6c2d3890d9 100644 --- a/spec/controllers/listing_images_controller_spec.rb +++ b/spec/controllers/listing_images_controller_spec.rb @@ -1,5 +1,3 @@ -# encoding: utf-8 - # == Schema Information # # Table name: listing_images diff --git a/spec/controllers/listings_controller_spec.rb b/spec/controllers/listings_controller_spec.rb index 7f1055c186..dddc2ce150 100644 --- a/spec/controllers/listings_controller_spec.rb +++ b/spec/controllers/listings_controller_spec.rb @@ -1,4 +1,3 @@ -# encoding: utf-8 # == Schema Information # # Table name: listings @@ -411,21 +410,21 @@ def create_shape(community_id, type, process, translations = [], categories = [] valid_until = Time.current + 3.months ActionMailer::Base.deliveries = [] post :create, params: { - "listing"=>{ - "title"=>"Mock-Duck and Chard Pie served with Oscar Meyer Squash", - "price"=>"100", - "shipping_price"=>"0", - "shipping_price_additional"=>"0", - "delivery_methods"=>["pickup"], - "description"=>"", - "valid_until(1i)"=>valid_until.year, - "valid_until(2i)"=>valid_until.month, - "valid_until(3i)"=>valid_until.day, - "origin"=>"", - "origin_loc_attributes"=>{"address"=>"", "google_address"=>"", "latitude"=>"", "longitude"=>""}, - "category_id"=>"1", - "listing_shape_id"=>sell_shape[:id], - "unit"=> {:unit_type=>"unit", :kind=>"quantity"}.to_json + "listing" => { + "title" => "Mock-Duck and Chard Pie served with Oscar Meyer Squash", + "price" => "100", + "shipping_price" => "0", + "shipping_price_additional" => "0", + "delivery_methods" => ["pickup"], + "description" => "", + "valid_until(1i)" => valid_until.year, + "valid_until(2i)" => valid_until.month, + "valid_until(3i)" => valid_until.day, + "origin" => "", + "origin_loc_attributes" => {"address"=>"", "google_address"=>"", "latitude"=>"", "longitude"=>""}, + "category_id" => "1", + "listing_shape_id" => sell_shape[:id], + "unit" => {:unit_type=>"unit", :kind=>"quantity"}.to_json } } listing = assigns(:listing) diff --git a/spec/jobs/handle_paypal_ipn_message_job_spec.rb b/spec/jobs/handle_paypal_ipn_message_job_spec.rb index f43509f9f7..cf9f29d11e 100644 --- a/spec/jobs/handle_paypal_ipn_message_job_spec.rb +++ b/spec/jobs/handle_paypal_ipn_message_job_spec.rb @@ -14,50 +14,50 @@ context '#perform' do it 'IPN message - commission denied' do body = { - "mp_custom"=>"", - "mc_gross"=>"50", - "invoice"=>"#{community.id}-#{transaction.id}-commission", - "mp_currency"=>"USD", - "protection_eligibility"=>"Ineligible", - "item_number1"=>"0", - "payer_id"=>"EX3M7RJJ7ZZZZ", - "tax"=>"0", - "payment_date"=>"06:30:30 Oct 27, 2017 PDT", - "mp_id"=>"B-3Y387433BA753ZZZZ", - "payment_status"=>"Denied", - "charset"=>"windows-1252", - "mc_shipping"=>"0", - "mc_handling"=>"0", - "first_name"=>"Yosaton", - "mp_status"=>"0", - "notify_version"=>"3.8", - "custom"=>"", - "payer_status"=>"verified", - "business"=>"nicolas@example.com", - "num_cart_items"=>"1", - "mc_handling1"=>"0", - "verify_sign"=>"AESWI3GOfTYxKEwR5JMr8czKZUNdAmmdH4DvHAk5Ho8YBr1SUtSTZZZZ", - "payer_email"=>"y.smith@example.com", - "mc_shipping1"=>"0", - "tax1"=>"0", - "txn_id"=>"4N811936LY433ZZZZ", - "payment_type"=>"instant", - "last_name"=>"Smith", - "mp_desc"=>"Grant Trezure permission to charge a transaction fee.", - "item_name1"=>"Commission payment for Christmas Tree", - "receiver_email"=>"nicolas@example.com", - "mp_cycle_start"=>"15", - "quantity1"=>"1", - "receiver_id"=>"8WAHAZYS5ZZZZ", - "txn_type"=>"merch_pmt", - "mc_gross_1"=>"50", - "mc_currency"=>"JPY", - "residence_country"=>"US", - "transaction_subject"=>"Marketplace vetterview took this commission from transaction regarding Christmas Tree", - "payment_gross"=>"", - "ipn_track_id"=>"22d763a05cccc", - "controller"=>"paypal_ipn", - "action"=>"ipn_hook" + "mp_custom" => "", + "mc_gross" => "50", + "invoice" => "#{community.id}-#{transaction.id}-commission", + "mp_currency" => "USD", + "protection_eligibility" => "Ineligible", + "item_number1" => "0", + "payer_id" => "EX3M7RJJ7ZZZZ", + "tax" => "0", + "payment_date" => "06:30:30 Oct 27, 2017 PDT", + "mp_id" => "B-3Y387433BA753ZZZZ", + "payment_status" => "Denied", + "charset" => "windows-1252", + "mc_shipping" => "0", + "mc_handling" => "0", + "first_name" => "Yosaton", + "mp_status" => "0", + "notify_version" => "3.8", + "custom" => "", + "payer_status" => "verified", + "business" => "nicolas@example.com", + "num_cart_items" => "1", + "mc_handling1" => "0", + "verify_sign" => "AESWI3GOfTYxKEwR5JMr8czKZUNdAmmdH4DvHAk5Ho8YBr1SUtSTZZZZ", + "payer_email" => "y.smith@example.com", + "mc_shipping1" => "0", + "tax1" => "0", + "txn_id" => "4N811936LY433ZZZZ", + "payment_type" => "instant", + "last_name" => "Smith", + "mp_desc" => "Grant Trezure permission to charge a transaction fee.", + "item_name1" => "Commission payment for Christmas Tree", + "receiver_email" => "nicolas@example.com", + "mp_cycle_start" => "15", + "quantity1" => "1", + "receiver_id" => "8WAHAZYS5ZZZZ", + "txn_type" => "merch_pmt", + "mc_gross_1" => "50", + "mc_currency" => "JPY", + "residence_country" => "US", + "transaction_subject" => "Marketplace vetterview took this commission from transaction regarding Christmas Tree", + "payment_gross" => "", + "ipn_track_id" => "22d763a05cccc", + "controller" => "paypal_ipn", + "action" => "ipn_hook" } paypal_ipn_message = FactoryGirl.create(:paypal_ipn_message, body: body, status: 'errored') paypal_payment = FactoryGirl.create(:paypal_payment, @@ -77,26 +77,26 @@ it 'IPN message - adjustment' do body = { - "txn_type"=>"adjustment", - "payment_date"=>"22:41:28 Nov 20, 2017 PST", - "payment_gross"=>"-400.00", - "mc_currency"=>"USD", - "verify_sign"=>"Asm02AZo2GgXAq5vuJQw4xf2prDoA1AFaUqo9ytiIepWaLb.XyPciM1q", - "payer_status"=>"verified", - "payer_email"=>"thesubmarine@example.com", - "txn_id"=>"4JJ10040D4671ZZZZ", - "parent_txn_id"=>"1SS87354FT252ZZZZ", - "payer_id"=>"LCLFGUWLCZZZZ", - "invoice"=>"#{community.id}-#{transaction.id}-payment", - "reason_code"=>"chargeback_settlement", - "payment_status"=>"Completed", - "payment_fee"=>"-20.00", - "mc_gross"=>"-400.00", - "charset"=>"windows-1252", - "notify_version"=>"3.8", - "ipn_track_id"=>"efc01da41aaaa", - "controller"=>"paypal_ipn", - "action"=>"ipn_hook", + "txn_type" => "adjustment", + "payment_date" => "22:41:28 Nov 20, 2017 PST", + "payment_gross" => "-400.00", + "mc_currency" => "USD", + "verify_sign" => "Asm02AZo2GgXAq5vuJQw4xf2prDoA1AFaUqo9ytiIepWaLb.XyPciM1q", + "payer_status" => "verified", + "payer_email" => "thesubmarine@example.com", + "txn_id" => "4JJ10040D4671ZZZZ", + "parent_txn_id" => "1SS87354FT252ZZZZ", + "payer_id" => "LCLFGUWLCZZZZ", + "invoice" => "#{community.id}-#{transaction.id}-payment", + "reason_code" => "chargeback_settlement", + "payment_status" => "Completed", + "payment_fee" => "-20.00", + "mc_gross" => "-400.00", + "charset" => "windows-1252", + "notify_version" => "3.8", + "ipn_track_id" => "efc01da41aaaa", + "controller" => "paypal_ipn", + "action" => "ipn_hook" } paypal_ipn_message = FactoryGirl.create(:paypal_ipn_message, body: body, status: 'errored') paypal_payment = FactoryGirl.create(:paypal_payment, @@ -120,54 +120,54 @@ it 'IPN message - commission pending' do body = { - "mp_custom"=>"", - "mc_gross"=>"14.24", - "invoice"=>"#{community.id}-#{transaction.id}-commission", - "mp_currency"=>"EUR", - "protection_eligibility"=>"Ineligible", - "item_number1"=>"0", - "tax"=>"0.00", - "payer_id"=>"VRQ77S93WZZZZ", - "payment_date"=>"04:55:19 Nov 22, 2017 PST", - "mp_id"=>"B-92E30987Y6745ZZZZ", - "payment_status"=>"Pending", - "charset"=>"windows-1252", - "mc_shipping"=>"0.00", - "mc_handling"=>"0.00", - "first_name"=>"Christophe", - "mp_status"=>"0", - "mc_fee"=>"0.73", - "notify_version"=>"3.8", - "custom"=>"", - "payer_status"=>"unverified", - "business"=>"morgane.regnier@example.com", - "num_cart_items"=>"1", - "mc_handling1"=>"0.00", - "verify_sign"=>"AxGBlNtIj4ayGxxruDHIY.uLHHMXAyRZ-MtRqGDHKdl-ZMsWaxlb.qz0", - "payer_email"=>"contact@example.com", - "mc_shipping1"=>"0.00", - "tax1"=>"0.00", - "txn_id"=>"7B0631626J114ZZZZ", - "payment_type"=>"instant", - "payer_business_name"=>"chris-creation", - "last_name"=>"Boury", - "mp_desc"=>"Autoriser Experiences cours photo à prélever des frais de service.", - "item_name1"=>"Paiement des frais de service pour Cours Lightroom - les bases - Bordeaux ou en ligne", - "receiver_email"=>"morgane.regnier@photosqware.com", - "payment_fee"=>"", - "mp_cycle_start"=>"21", - "quantity1"=>"1", - "receiver_id"=>"K9D9EQZCWZZZZ", - "pending_reason"=>"paymentreview", - "txn_type"=>"merch_pmt", - "mc_gross_1"=>"14.24", - "mc_currency"=>"EUR", - "residence_country"=>"FR", - "transaction_subject"=>"La place de marché Experiences cours photo a prélevéces frais de service sur une transaction de Cours Lightroom - les bases", - "payment_gross"=>"", - "ipn_track_id"=>"84212dcfffff", - "controller"=>"paypal_ipn", - "action"=>"ipn_hook", + "mp_custom" => "", + "mc_gross" => "14.24", + "invoice" => "#{community.id}-#{transaction.id}-commission", + "mp_currency" => "EUR", + "protection_eligibility" => "Ineligible", + "item_number1" => "0", + "tax" => "0.00", + "payer_id" => "VRQ77S93WZZZZ", + "payment_date" => "04:55:19 Nov 22, 2017 PST", + "mp_id" => "B-92E30987Y6745ZZZZ", + "payment_status" => "Pending", + "charset" => "windows-1252", + "mc_shipping" => "0.00", + "mc_handling" => "0.00", + "first_name" => "Christophe", + "mp_status" => "0", + "mc_fee" => "0.73", + "notify_version" => "3.8", + "custom" => "", + "payer_status" => "unverified", + "business" => "morgane.regnier@example.com", + "num_cart_items" => "1", + "mc_handling1" => "0.00", + "verify_sign" => "AxGBlNtIj4ayGxxruDHIY.uLHHMXAyRZ-MtRqGDHKdl-ZMsWaxlb.qz0", + "payer_email" => "contact@example.com", + "mc_shipping1" => "0.00", + "tax1" => "0.00", + "txn_id" => "7B0631626J114ZZZZ", + "payment_type" => "instant", + "payer_business_name" => "chris-creation", + "last_name" => "Boury", + "mp_desc" => "Autoriser Experiences cours photo à prélever des frais de service.", + "item_name1" => "Paiement des frais de service pour Cours Lightroom - les bases - Bordeaux ou en ligne", + "receiver_email" => "morgane.regnier@photosqware.com", + "payment_fee" => "", + "mp_cycle_start" => "21", + "quantity1" => "1", + "receiver_id" => "K9D9EQZCWZZZZ", + "pending_reason" => "paymentreview", + "txn_type" => "merch_pmt", + "mc_gross_1" => "14.24", + "mc_currency" => "EUR", + "residence_country" => "FR", + "transaction_subject" => "La place de marché Experiences cours photo a prélevéces frais de service sur une transaction de Cours Lightroom - les bases", + "payment_gross" => "", + "ipn_track_id" => "84212dcfffff", + "controller" => "paypal_ipn", + "action" => "ipn_hook" } paypal_ipn_message = FactoryGirl.create(:paypal_ipn_message, body: body, status: 'errored') paypal_payment = FactoryGirl.create(:paypal_payment, @@ -188,63 +188,63 @@ it 'IPN message - fixed find paypal payment' do body = { - "mc_gross"=>"40.50", - "invoice"=>"31089-262964-payment", - "auth_exp"=>"01:52:09 Jan 09, 2018 PST", - "protection_eligibility"=>"Eligible", - "address_status"=>"confirmed", - "item_number1"=>"", - "payer_id"=>"SMVUWVZCWZZZZ", - "tax"=>"0.00", - "address_street"=>"Alba Diagnostics Ltd 1 Bankhead Ave, Bankhead Ind Est", - "payment_date"=>"01:52:09 Dec 11, 2017 PST", - "payment_status"=>"Voided", - "charset"=>"windows-1252", - "address_zip"=>"KY7 6JG", - "mc_shipping"=>"5.50", - "mc_handling"=>"0.00", - "first_name"=>"Stewart", - "transaction_entity"=>"auth", - "address_country_code"=>"GB", - "address_name"=>"Stewart Whitton", - "notify_version"=>"3.8", - "custom"=>"", - "payer_status"=>"unverified", - "business"=>"info@peek-a-boo-signs.co.uk", - "address_country"=>"United Kingdom", - "num_cart_items"=>"1", - "mc_handling1"=>"0.00", - "address_city"=>"Glenrothes, Fife", - "verify_sign"=>"AGXT66oAmwth6Mv574mMl8vl9PeuAJ8SBM.xnUQ4vETFvdkiEyxn18jL", - "payer_email"=>"stewart@example.com", - "mc_shipping1"=>"0.00", - "tax1"=>"0.00", - "parent_txn_id"=>"", - "txn_id"=>"17834969M2791ZZZZ", - "payment_type"=>"instant", - "remaining_settle"=>"0", - "auth_id"=>"17834969M2791ZZZZ", - "last_name"=>"Whitton", - "address_state"=>"Fife", - "item_name1"=>"Wooden Sign \"How to tell time\"", - "receiver_email"=>"info@example.com", - "auth_amount"=>"40.50", - "shipping_discount"=>"0.00", - "quantity1"=>"1", - "insurance_amount"=>"0.00", - "receiver_id"=>"SRVAF3PNHZZZZ", - "txn_type"=>"cart", - "discount"=>"0.00", - "mc_gross_1"=>"35.00", - "mc_currency"=>"GBP", - "residence_country"=>"GB", - "shipping_method"=>"Default", - "transaction_subject"=>"", - "payment_gross"=>"", - "auth_status"=>"Voided", - "ipn_track_id"=>"7cc0a09bbbbbb", - "controller"=>"paypal_ipn", - "action"=>"ipn_hook" + "mc_gross" => "40.50", + "invoice" => "31089-262964-payment", + "auth_exp" => "01:52:09 Jan 09, 2018 PST", + "protection_eligibility" => "Eligible", + "address_status" => "confirmed", + "item_number1" => "", + "payer_id" => "SMVUWVZCWZZZZ", + "tax" => "0.00", + "address_street" => "Alba Diagnostics Ltd 1 Bankhead Ave, Bankhead Ind Est", + "payment_date" => "01:52:09 Dec 11, 2017 PST", + "payment_status" => "Voided", + "charset" => "windows-1252", + "address_zip" => "KY7 6JG", + "mc_shipping" => "5.50", + "mc_handling" => "0.00", + "first_name" => "Stewart", + "transaction_entity" => "auth", + "address_country_code" => "GB", + "address_name" => "Stewart Whitton", + "notify_version" => "3.8", + "custom" => "", + "payer_status" => "unverified", + "business" => "info@peek-a-boo-signs.co.uk", + "address_country" => "United Kingdom", + "num_cart_items" => "1", + "mc_handling1" => "0.00", + "address_city" => "Glenrothes, Fife", + "verify_sign" => "AGXT66oAmwth6Mv574mMl8vl9PeuAJ8SBM.xnUQ4vETFvdkiEyxn18jL", + "payer_email" => "stewart@example.com", + "mc_shipping1" => "0.00", + "tax1" => "0.00", + "parent_txn_id" => "", + "txn_id" => "17834969M2791ZZZZ", + "payment_type" => "instant", + "remaining_settle" => "0", + "auth_id" => "17834969M2791ZZZZ", + "last_name" => "Whitton", + "address_state" => "Fife", + "item_name1" => "Wooden Sign \"How to tell time\"", + "receiver_email" => "info@example.com", + "auth_amount" => "40.50", + "shipping_discount" => "0.00", + "quantity1" => "1", + "insurance_amount" => "0.00", + "receiver_id" => "SRVAF3PNHZZZZ", + "txn_type" => "cart", + "discount" => "0.00", + "mc_gross_1" => "35.00", + "mc_currency" => "GBP", + "residence_country" => "GB", + "shipping_method" => "Default", + "transaction_subject" => "", + "payment_gross" => "", + "auth_status" => "Voided", + "ipn_track_id" => "7cc0a09bbbbbb", + "controller" => "paypal_ipn", + "action" => "ipn_hook" } paypal_ipn_message = FactoryGirl.create(:paypal_ipn_message, body: body, status: 'errored') FactoryGirl.create(:paypal_payment, diff --git a/spec/mailers/community_mailer_spec.rb b/spec/mailers/community_mailer_spec.rb index e57a188de6..38c9e19560 100644 --- a/spec/mailers/community_mailer_spec.rb +++ b/spec/mailers/community_mailer_spec.rb @@ -18,7 +18,7 @@ def find_email_body_for(email) @c1 = FactoryGirl.create(:community) @c1.community_customizations.first.update_attribute(:name, "MarketTestPlace") - @p1 = FactoryGirl.create(:person, :emails => [ FactoryGirl.create(:email, :address => "update_tester@example.com") ]) + @p1 = FactoryGirl.create(:person, :emails => [FactoryGirl.create(:email, :address => "update_tester@example.com")]) @p1.accepted_community = @c1 @l2 = FactoryGirl.create(:listing, :title => "hammer", diff --git a/spec/mailers/person_mailer_spec.rb b/spec/mailers/person_mailer_spec.rb index bd9e6e3888..64e18a8ca6 100644 --- a/spec/mailers/person_mailer_spec.rb +++ b/spec/mailers/person_mailer_spec.rb @@ -28,7 +28,7 @@ it "should send email about a new comment to own listing" do @comment = FactoryGirl.create(:comment) - @comment.author.update_attributes({ "given_name" => "Teppo", "family_name" => "Testaaja" }) + @comment.author.update({ "given_name" => "Teppo", "family_name" => "Testaaja" }) recipient = @comment.listing.author email = MailCarrier.deliver_now(PersonMailer.new_comment_to_own_listing_notification(@comment, @community)) assert !ActionMailer::Base.deliveries.empty? @@ -95,7 +95,7 @@ end it "should send email about a new testimonial" do - @test_person.update_attributes({ "given_name" => "Teppo", "family_name" => "Testaaja" }) + @test_person.update({ "given_name" => "Teppo", "family_name" => "Testaaja" }) transition = FactoryGirl.build(:transaction_transition, to_state: "confirmed") listing = FactoryGirl.build(:listing, @@ -156,7 +156,7 @@ before(:each) do @c1 = FactoryGirl.create(:community) - @p1 = FactoryGirl.create(:person, :emails => [ FactoryGirl.create(:email, :address => "update_tester@example.com") ]) + @p1 = FactoryGirl.create(:person, :emails => [FactoryGirl.create(:email, :address => "update_tester@example.com")]) @p1.accepted_community = @c1 end diff --git a/spec/models/community_spec.rb b/spec/models/community_spec.rb index 1112568eef..a11f49c54b 100644 --- a/spec/models/community_spec.rb +++ b/spec/models/community_spec.rb @@ -1,4 +1,3 @@ -# encoding: utf-8 # == Schema Information # # Table name: communities @@ -158,7 +157,7 @@ def get_listing(created_at, updates_email_at) end before(:each) do - @p1 = FactoryGirl.create(:person, :emails => [ FactoryGirl.create(:email, :address => "update_tester@example.com") ]) + @p1 = FactoryGirl.create(:person, :emails => [FactoryGirl.create(:email, :address => "update_tester@example.com")]) @p1.accepted_community = community @l1 = get_listing(2,2) @l2 = get_listing(3,3) diff --git a/spec/models/location_spec.rb b/spec/models/location_spec.rb index 9a8fef9376..fe9db5453a 100644 --- a/spec/models/location_spec.rb +++ b/spec/models/location_spec.rb @@ -41,29 +41,29 @@ def stub_maps_googleapis results = { - "results"=> - [{"address_components"=> + "results" => + [{"address_components" => [{"long_name"=>"14", "short_name"=>"14", "types"=>["street_number"]}, - {"long_name"=>"Bulevardi", - "short_name"=>"Bulevardi", - "types"=>["route"]}, - {"long_name"=>"Helsinki", - "short_name"=>"HKI", - "types"=>["locality", "political"]}, - {"long_name"=>"Finland", - "short_name"=>"FI", - "types"=>["country", "political"]}, + {"long_name" => "Bulevardi", + "short_name" => "Bulevardi", + "types" => ["route"]}, + {"long_name" => "Helsinki", + "short_name" => "HKI", + "types" => ["locality", "political"]}, + {"long_name" => "Finland", + "short_name" => "FI", + "types" => ["country", "political"]}, {"long_name"=>"00120", "short_name"=>"00120", "types"=>["postal_code"]}], - "formatted_address"=>"Bulevardi 14, 00120 Helsinki, Finland", - "geometry"=> - {"location"=>{"lat"=>60.1651848, "lng"=>24.939939}, - "location_type"=>"ROOFTOP", - "viewport"=> - {"northeast"=>{"lat"=>60.1665337802915, "lng"=>24.9412879802915}, - "southwest"=>{"lat"=>60.16383581970849, "lng"=>24.9385900197085}}}, - "place_id"=>"ChIJ6YBSzMsLkkYRIOsikn7B4eM", - "types"=>["street_address"]}], - "status"=>"OK" + "formatted_address" => "Bulevardi 14, 00120 Helsinki, Finland", + "geometry" => + {"location" => {"lat"=>60.1651848, "lng"=>24.939939}, + "location_type" => "ROOFTOP", + "viewport" => + {"northeast" => {"lat"=>60.1665337802915, "lng"=>24.9412879802915}, + "southwest" => {"lat"=>60.16383581970849, "lng"=>24.9385900197085}}}, + "place_id" => "ChIJ6YBSzMsLkkYRIOsikn7B4eM", + "types" => ["street_address"]}], + "status" => "OK" } stub_request(:get, "http://maps.googleapis.com/maps/api/geocode/json?address=Bulevardi%2014,%20Helsinki,%20Finland") .to_return(status: 200, body: results.to_json, headers: {}) diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 789649f003..14cb031466 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -115,7 +115,7 @@ describe "#update_attributes" do it "should update the attributes" do - @test_person.update_attributes({'given_name' => "Totti", + @test_person.update({'given_name' => "Totti", 'family_name' => "Tester", 'phone_number' => "050-55555555"}) expect(@test_person.family_name).to eq("Tester") @@ -137,7 +137,7 @@ describe "name getters" do before(:each) do - @test_person.update_attributes({'given_name' => "Ripa", 'family_name' => "Riuska"}) + @test_person.update({'given_name' => "Ripa", 'family_name' => "Riuska"}) end it "returns the name of the user" do @@ -164,7 +164,7 @@ end it "should return blank if given name is blank" do - @test_person.update_attributes({'given_name' => "", 'family_name' => ""}) + @test_person.update({'given_name' => "", 'family_name' => ""}) expect(@test_person.given_name).to eq("") end @@ -177,7 +177,7 @@ end it "should return username if given name is blank" do - @test_person.update_attributes({'given_name' => "", 'family_name' => ""}) + @test_person.update({'given_name' => "", 'family_name' => ""}) expect(@test_person.given_name_or_username).to eq(@test_person.username) end diff --git a/spec/requests/landing_pages_spec.rb b/spec/requests/landing_pages_spec.rb index 2ba17ade8a..dc718e846f 100644 --- a/spec/requests/landing_pages_spec.rb +++ b/spec/requests/landing_pages_spec.rb @@ -290,11 +290,11 @@ def expect_controller(url, controller_name, action_name) describe "private marketplaces" do before(:all) { @orig_private = @community.private - @community.update_attributes(private: true) + @community.update(private: true) } after(:all) { - @community.update_attributes(private: @orig_private) + @community.update(private: @orig_private) } it "does not includes max-age header in the response for private marketplaces" do diff --git a/spec/requests/plan_webhook_spec.rb b/spec/requests/plan_webhook_spec.rb index 815997868b..f83aa8b5d2 100644 --- a/spec/requests/plan_webhook_spec.rb +++ b/spec/requests/plan_webhook_spec.rb @@ -187,7 +187,7 @@ member_limit: 300, created_at: Time.utc(2015, 10, 15).in_time_zone, updated_at: Time.utc(2015, 10, 15).in_time_zone, - expires_at: nil, + expires_at: nil }, { marketplace_plan_id: id333, @@ -197,7 +197,7 @@ member_limit: 300, created_at: Time.utc(2015, 11, 15).in_time_zone, updated_at: Time.utc(2015, 11, 15).in_time_zone, - expires_at: nil, + expires_at: nil } ] }.to_json)) @@ -242,7 +242,7 @@ member_limit: 300, created_at: Time.utc(2015, 9, 15).in_time_zone, updated_at: Time.utc(2015, 9, 15).in_time_zone, - expires_at: nil, + expires_at: nil } ], next_after: Time.utc(2015, 10, 15).to_i @@ -263,7 +263,7 @@ member_limit: 300, created_at: Time.utc(2015, 10, 15).in_time_zone, updated_at: Time.utc(2015, 10, 15).in_time_zone, - expires_at: nil, + expires_at: nil }, { marketplace_plan_id: id333, @@ -273,7 +273,7 @@ features: { deletable: true, admin_email: false, whitelabel: false, footer: false }, created_at: Time.utc(2015, 11, 15).in_time_zone, updated_at: Time.utc(2015, 11, 15).in_time_zone, - expires_at: nil, + expires_at: nil } ] }.to_json)) diff --git a/spec/services/email_service/api/addresses_spec.rb b/spec/services/email_service/api/addresses_spec.rb index ed545b88df..dfd83b83d9 100644 --- a/spec/services/email_service/api/addresses_spec.rb +++ b/spec/services/email_service/api/addresses_spec.rb @@ -45,7 +45,7 @@ addresses_wo_ses.create( community_id: 123, address: { name: "Email Sender Name", - email: "hello@mymarketplace.invalid", + email: "hello@mymarketplace.invalid" }) res = addresses_wo_ses.get_sender(community_id: 123) @@ -61,7 +61,7 @@ addresses_wo_ses.create( community_id: 123, address: { name: "Email Sender Name", - email: "hello@mymarketplace.invalid", + email: "hello@mymarketplace.invalid" }) Timecop.travel(1.second.from_now) do @@ -69,7 +69,7 @@ addresses_wo_ses.create( community_id: 123, address: { name: "Email 2 Sender Name", - email: "hello2@mymarketplace.invalid", + email: "hello2@mymarketplace.invalid" }) res = addresses_wo_ses.get_sender(community_id: 123) @@ -86,7 +86,7 @@ it "allows nil name" do addresses_wo_ses.create( community_id: 123, address: { - email: "hello@mymarketplace.invalid", + email: "hello@mymarketplace.invalid" }) res = addresses_wo_ses.get_sender(community_id: 123) @@ -105,7 +105,7 @@ expect(addresses_wo_ses.create( community_id: 1, address: { name: "Hello", - email: "hello@mymarketplace.invalid", + email: "hello@mymarketplace.invalid" }).data[:smtp_format]).to eq("\"Hello\" ") # User input: Hello "Hello" Hello @@ -113,7 +113,7 @@ expect(addresses_wo_ses.create( community_id: 1, address: { name: "Hello \"Hello\" Hello", - email: "hello@mymarketplace.invalid", + email: "hello@mymarketplace.invalid" }).data[:smtp_format]).to eq("\"Hello \\\"Hello\\\" Hello\" ") # User input: Hello \"Hello\" Hello @@ -121,7 +121,7 @@ expect(addresses_wo_ses.create( community_id: 1, address: { name: "Hello \\\"Hello\\\" Hello", - email: "hello@mymarketplace.invalid", + email: "hello@mymarketplace.invalid" }).data[:smtp_format]).to eq("\"Hello \\\\\\\"Hello\\\\\\\" Hello\" ") # User input: Hello \\"Hello\\" Hello @@ -129,7 +129,7 @@ expect(addresses_wo_ses.create( community_id: 1, address: { name: "Hello \\\\\"Hello\\\\\" Hello", - email: "hello@mymarketplace.invalid", + email: "hello@mymarketplace.invalid" }).data[:smtp_format]).to eq("\"Hello \\\\\\\\\\\"Hello\\\\\\\\\\\" Hello\" ") end @@ -186,7 +186,7 @@ created = addresses_wo_ses.create( community_id: 123, address: { name: "Email Sender Name", - email: "hello@mymarketplace.invalid", + email: "hello@mymarketplace.invalid" }).data res = addresses_wo_ses.get_user_defined(community_id: 123) @@ -210,7 +210,7 @@ addresses_wo_ses.create( community_id: 123, address: { name: "Email Sender Name", - email: "hello@mymarketplace.invalid", + email: "hello@mymarketplace.invalid" }) end @@ -219,7 +219,7 @@ created = addresses_wo_ses.create( community_id: 123, address: { name: "Email 2 Sender Name", - email: "hello2@mymarketplace.invalid", + email: "hello2@mymarketplace.invalid" }).data res = addresses_wo_ses.get_user_defined(community_id: 123) diff --git a/spec/services/email_service/ses/synchronize_spec.rb b/spec/services/email_service/ses/synchronize_spec.rb index 0273cc83ce..1b4545bddf 100644 --- a/spec/services/email_service/ses/synchronize_spec.rb +++ b/spec/services/email_service/ses/synchronize_spec.rb @@ -14,10 +14,10 @@ def next_id def get_type(type) { - old_pending: -> () { [:requested, (25 + rand(24)).hours.ago]}, - new_pending: -> () { [:requested, rand(24).hours.ago]}, - verified: -> () { [:verified, nil]}, - none: -> () { [:none, nil]} + old_pending: -> { [:requested, rand(25..48).hours.ago]}, + new_pending: -> { [:requested, rand(24).hours.ago]}, + verified: -> { [:verified, nil]}, + none: -> { [:none, nil]} }[type] end diff --git a/spec/services/feature_flag_service/api/features_spec.rb b/spec/services/feature_flag_service/api/features_spec.rb index 29271379cb..da97a058bd 100644 --- a/spec/services/feature_flag_service/api/features_spec.rb +++ b/spec/services/feature_flag_service/api/features_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 require 'spec_helper' describe FeatureFlagService::API::Features do diff --git a/spec/services/paypal_service/api/accounts_spec.rb b/spec/services/paypal_service/api/accounts_spec.rb index 445955abce..487103d65e 100644 --- a/spec/services/paypal_service/api/accounts_spec.rb +++ b/spec/services/paypal_service/api/accounts_spec.rb @@ -59,14 +59,14 @@ def create_personal_account_new_flow(response_payer_id: nil, request:) person_id: @mid, order_permission_request_token: nil, body: { onboarding_params: - {"merchantId"=> request[:data][:onboarding_params][:merchantId], - "merchantIdInPayPal"=> payer_id, - "permissionsGranted"=> "true", - "accountStatus"=> "BUSINESS_ACCOUNT", - "consentStatus"=> "false", - "productIntentID"=> "addipmt", - "isEmailConfirmed"=> "false", - "returnMessage"=> "To start accepting payments, please log in to PayPal and finish signing up.", + {"merchantId" => request[:data][:onboarding_params][:merchantId], + "merchantIdInPayPal" => payer_id, + "permissionsGranted" => "true", + "accountStatus" => "BUSINESS_ACCOUNT", + "consentStatus" => "false", + "productIntentID" => "addipmt", + "isEmailConfirmed" => "false", + "returnMessage" => "To start accepting payments, please log in to PayPal and finish signing up." }}, flow: :new) end @@ -90,14 +90,14 @@ def create_community_account_new_flow(response_payer_id: nil, request:) community_id: @cid, order_permission_request_token: nil, body: { onboarding_params: - {"merchantId"=> request[:data][:onboarding_params][:merchantId], - "merchantIdInPayPal"=> payer_id, - "permissionsGranted"=> "true", - "accountStatus"=> "BUSINESS_ACCOUNT", - "consentStatus"=> "false", - "productIntentID"=> "addipmt", - "isEmailConfirmed"=> "false", - "returnMessage"=> "To start accepting payments, please log in to PayPal and finish signing up.", + {"merchantId" => request[:data][:onboarding_params][:merchantId], + "merchantIdInPayPal" => payer_id, + "permissionsGranted" => "true", + "accountStatus" => "BUSINESS_ACCOUNT", + "consentStatus" => "false", + "productIntentID" => "addipmt", + "isEmailConfirmed" => "false", + "returnMessage" => "To start accepting payments, please log in to PayPal and finish signing up." }}, flow: :new) end diff --git a/spec/services/paypal_service/data_types/ipn_spec.rb b/spec/services/paypal_service/data_types/ipn_spec.rb index 7bde5c8153..d0e6c9162b 100644 --- a/spec/services/paypal_service/data_types/ipn_spec.rb +++ b/spec/services/paypal_service/data_types/ipn_spec.rb @@ -23,40 +23,40 @@ "notify_version" => "3.8", "mp_desc" => "Grant Test.com permission to charge a transaction fee.", "mp_cycle_start" => "14", - "ipn_track_id" => "e388c4ss1491", + "ipn_track_id" => "e388c4ss1491" } order_created = { - "txn_type"=> "express_checkout", - "payment_date"=>"23:01:12 Sep 30, 2014 PDT", - "last_name"=>"kjh", - "receipt_id"=>"3609-0935-6989-4532", - "residence_country"=>"GB", - "pending_reason"=>"order", - "item_name"=>"desc", - "payment_gross"=>"", - "mc_currency"=>"GBP", - "verify_sign"=>"AWA3gWBJwNK7791rbM2f2XOEyzvbACNyf78ytgUBQNkB-vdmxBoY2Ait", - "payer_status"=>"unverified", - "test_ipn"=>"1", - "tax"=>"0.00", - "payer_email"=>"foobar@barfoo.com", - "txn_id"=>"O-8VG2704956180171B", - "quantity"=>"1", - "receiver_email"=>"dev+paypal-user1@sharetribe.com", - "first_name"=>"ljkh", - "payer_id"=>"6M39X6RCYVUD6", - "receiver_id"=>"URAPMR7WHFAWY", - "item_number"=>"", - "handling_amount"=>"0.00", - "payment_status"=>"Pending", - "shipping"=>"0.00", - "mc_gross"=>"1.20", - "custom"=>"", - "transaction_entity"=>"order", - "charset"=>"windows-1252", - "notify_version"=>"3.8", - "ipn_track_id"=>"d9520dcb18f6" + "txn_type" => "express_checkout", + "payment_date" => "23:01:12 Sep 30, 2014 PDT", + "last_name" => "kjh", + "receipt_id" => "3609-0935-6989-4532", + "residence_country" => "GB", + "pending_reason" => "order", + "item_name" => "desc", + "payment_gross" => "", + "mc_currency" => "GBP", + "verify_sign" => "AWA3gWBJwNK7791rbM2f2XOEyzvbACNyf78ytgUBQNkB-vdmxBoY2Ait", + "payer_status" => "unverified", + "test_ipn" => "1", + "tax" => "0.00", + "payer_email" => "foobar@barfoo.com", + "txn_id" => "O-8VG2704956180171B", + "quantity" => "1", + "receiver_email" => "dev+paypal-user1@sharetribe.com", + "first_name" => "ljkh", + "payer_id" => "6M39X6RCYVUD6", + "receiver_id" => "URAPMR7WHFAWY", + "item_number" => "", + "handling_amount" => "0.00", + "payment_status" => "Pending", + "shipping" => "0.00", + "mc_gross" => "1.20", + "custom" => "", + "transaction_entity" => "order", + "charset" => "windows-1252", + "notify_version" => "3.8", + "ipn_track_id" => "d9520dcb18f6" } payment_review = { @@ -115,45 +115,45 @@ } auth_created = { - "mc_gross"=>"1.20", - "auth_exp"=>"23:50:00 Oct 03, 2014 PDT", - "protection_eligibility"=>"Ineligible", - "payer_id"=>"6M39X6RCYVUD6", - "tax"=>"0.00", - "payment_date"=>"23:04:07 Sep 30, 2014 PDT", - "payment_status"=>"Pending", - "charset"=>"windows-1252", - "first_name"=>"ljkh", - "transaction_entity"=>"auth", - "notify_version"=>"3.8", - "custom"=>"", - "payer_status"=>"unverified", - "quantity"=>"1", - "verify_sign"=>"A2S1fniRGsoquzRDbs4f5rc383f8A9BZtlhOnNThbBpkIOUsU.U6RJlP", - "payer_email"=>"foobar@barfoo.com", - "parent_txn_id"=>"O-8VG2704956180171B", - "txn_id"=>"0L584749FU2628910", - "payment_type"=>"instant", - "remaining_settle"=>"10", - "auth_id"=>"0L584749FU2628910", - "last_name"=>"kjh", - "receiver_email"=>"dev+paypal-user1@sharetribe.com", - "auth_amount"=>"1.20", - "receiver_id"=>"URAPMR7WHFAWY", - "pending_reason"=>"authorization", - "txn_type"=>"express_checkout", - "item_name"=>"desc", - "mc_currency"=>"GBP", - "item_number"=>"", - "residence_country"=>"GB", - "test_ipn"=>"1", - "receipt_id"=>"3609-0935-6989-4532", - "handling_amount"=>"0.00", - "transaction_subject"=>"", - "payment_gross"=>"", - "auth_status"=>"Pending", - "shipping"=>"0.00", - "ipn_track_id"=>"35b2bed5966" + "mc_gross" => "1.20", + "auth_exp" => "23:50:00 Oct 03, 2014 PDT", + "protection_eligibility" => "Ineligible", + "payer_id" => "6M39X6RCYVUD6", + "tax" => "0.00", + "payment_date" => "23:04:07 Sep 30, 2014 PDT", + "payment_status" => "Pending", + "charset" => "windows-1252", + "first_name" => "ljkh", + "transaction_entity" => "auth", + "notify_version" => "3.8", + "custom" => "", + "payer_status" => "unverified", + "quantity" => "1", + "verify_sign" => "A2S1fniRGsoquzRDbs4f5rc383f8A9BZtlhOnNThbBpkIOUsU.U6RJlP", + "payer_email" => "foobar@barfoo.com", + "parent_txn_id" => "O-8VG2704956180171B", + "txn_id" => "0L584749FU2628910", + "payment_type" => "instant", + "remaining_settle" => "10", + "auth_id" => "0L584749FU2628910", + "last_name" => "kjh", + "receiver_email" => "dev+paypal-user1@sharetribe.com", + "auth_amount" => "1.20", + "receiver_id" => "URAPMR7WHFAWY", + "pending_reason" => "authorization", + "txn_type" => "express_checkout", + "item_name" => "desc", + "mc_currency" => "GBP", + "item_number" => "", + "residence_country" => "GB", + "test_ipn" => "1", + "receipt_id" => "3609-0935-6989-4532", + "handling_amount" => "0.00", + "transaction_subject" => "", + "payment_gross" => "", + "auth_status" => "Pending", + "shipping" => "0.00", + "ipn_track_id" => "35b2bed5966" } auth_created_no_order = { @@ -212,97 +212,97 @@ "action" => "ipn_hook" } payment_voided = { - "mc_gross"=>"100.00", - "invoice"=>"2-91", - "auth_exp"=>"23:50:00 Nov 06, 2014 PST", - "protection_eligibility"=>"Ineligible", - "item_number1"=>"", - "payer_id"=>"7LFUVCDKGARH4", - "tax"=>"0.00", - "payment_date"=>"04:15:57 Nov 03, 2014 PST", - "payment_status"=>"Voided", - "charset"=>"windows-1252", - "mc_shipping"=>"0.00", - "mc_handling"=>"0.00", - "first_name"=>"SandboxTest", - "transaction_entity"=>"auth", - "notify_version"=>"3.8", - "custom"=>"", - "payer_status"=>"verified", - "num_cart_items"=>"1", - "mc_handling1"=>"0.00", - "verify_sign"=>"AJUc1Ia4SIzAsHpmMszE5xpkoPoVAFydOpOKQmMLPy9fUgcPT8VPsa-a", - "payer_email"=>"dev+paypal-user2@sharetribe.com", - "mc_shipping1"=>"0.00", - "tax1"=>"0.00", - "parent_txn_id"=>"O-4XS63437S6833583E", - "txn_id"=>"8X37683373099502U", - "payment_type"=>"instant", - "remaining_settle"=>"10", - "auth_id"=>"8X37683373099502U", - "payer_business_name"=>"SandboxTest Account's Test Store", - "last_name"=>"Account", - "item_name1"=>"Testing", - "receiver_email"=>"dev+paypal-user1@sharetribe.com", - "auth_amount"=>"100.00", - "quantity1"=>"1", - "receiver_id"=>"URAPMR7WHFAWY", - "txn_type"=>"cart", - "mc_gross_1"=>"100.00", - "mc_currency"=>"GBP", - "residence_country"=>"GB", - "test_ipn"=>"1", - "transaction_subject"=>"", - "payment_gross"=>"", - "auth_status"=>"Voided", - "ipn_track_id"=>"deb829141b651" + "mc_gross" => "100.00", + "invoice" => "2-91", + "auth_exp" => "23:50:00 Nov 06, 2014 PST", + "protection_eligibility" => "Ineligible", + "item_number1" => "", + "payer_id" => "7LFUVCDKGARH4", + "tax" => "0.00", + "payment_date" => "04:15:57 Nov 03, 2014 PST", + "payment_status" => "Voided", + "charset" => "windows-1252", + "mc_shipping" => "0.00", + "mc_handling" => "0.00", + "first_name" => "SandboxTest", + "transaction_entity" => "auth", + "notify_version" => "3.8", + "custom" => "", + "payer_status" => "verified", + "num_cart_items" => "1", + "mc_handling1" => "0.00", + "verify_sign" => "AJUc1Ia4SIzAsHpmMszE5xpkoPoVAFydOpOKQmMLPy9fUgcPT8VPsa-a", + "payer_email" => "dev+paypal-user2@sharetribe.com", + "mc_shipping1" => "0.00", + "tax1" => "0.00", + "parent_txn_id" => "O-4XS63437S6833583E", + "txn_id" => "8X37683373099502U", + "payment_type" => "instant", + "remaining_settle" => "10", + "auth_id" => "8X37683373099502U", + "payer_business_name" => "SandboxTest Account's Test Store", + "last_name" => "Account", + "item_name1" => "Testing", + "receiver_email" => "dev+paypal-user1@sharetribe.com", + "auth_amount" => "100.00", + "quantity1" => "1", + "receiver_id" => "URAPMR7WHFAWY", + "txn_type" => "cart", + "mc_gross_1" => "100.00", + "mc_currency" => "GBP", + "residence_country" => "GB", + "test_ipn" => "1", + "transaction_subject" => "", + "payment_gross" => "", + "auth_status" => "Voided", + "ipn_track_id" => "deb829141b651" } payment_voided_no_order = { - "mc_gross"=>"100.00", - "invoice"=>"2-91", - "auth_exp"=>"23:50:00 Nov 06, 2014 PST", - "protection_eligibility"=>"Ineligible", - "item_number1"=>"", - "payer_id"=>"7LFUVCDKGARH4", - "tax"=>"0.00", - "payment_date"=>"04:15:57 Nov 03, 2014 PST", - "payment_status"=>"Voided", - "charset"=>"windows-1252", - "mc_shipping"=>"0.00", - "mc_handling"=>"0.00", - "first_name"=>"SandboxTest", - "transaction_entity"=>"auth", - "notify_version"=>"3.8", - "custom"=>"", - "payer_status"=>"verified", - "num_cart_items"=>"1", - "mc_handling1"=>"0.00", - "verify_sign"=>"AJUc1Ia4SIzAsHpmMszE5xpkoPoVAFydOpOKQmMLPy9fUgcPT8VPsa-a", - "payer_email"=>"dev+paypal-user2@sharetribe.com", - "mc_shipping1"=>"0.00", - "tax1"=>"0.00", - "parent_txn_id"=>"", - "txn_id"=>"8X37683373099502U", - "payment_type"=>"instant", - "remaining_settle"=>"10", - "auth_id"=>"8X37683373099502U", - "payer_business_name"=>"SandboxTest Account's Test Store", - "last_name"=>"Account", - "item_name1"=>"Testing", - "receiver_email"=>"dev+paypal-user1@sharetribe.com", - "auth_amount"=>"100.00", - "quantity1"=>"1", - "receiver_id"=>"URAPMR7WHFAWY", - "txn_type"=>"cart", - "mc_gross_1"=>"100.00", - "mc_currency"=>"GBP", - "residence_country"=>"GB", - "test_ipn"=>"1", - "transaction_subject"=>"", - "payment_gross"=>"", - "auth_status"=>"Voided", - "ipn_track_id"=>"deb829141b651" + "mc_gross" => "100.00", + "invoice" => "2-91", + "auth_exp" => "23:50:00 Nov 06, 2014 PST", + "protection_eligibility" => "Ineligible", + "item_number1" => "", + "payer_id" => "7LFUVCDKGARH4", + "tax" => "0.00", + "payment_date" => "04:15:57 Nov 03, 2014 PST", + "payment_status" => "Voided", + "charset" => "windows-1252", + "mc_shipping" => "0.00", + "mc_handling" => "0.00", + "first_name" => "SandboxTest", + "transaction_entity" => "auth", + "notify_version" => "3.8", + "custom" => "", + "payer_status" => "verified", + "num_cart_items" => "1", + "mc_handling1" => "0.00", + "verify_sign" => "AJUc1Ia4SIzAsHpmMszE5xpkoPoVAFydOpOKQmMLPy9fUgcPT8VPsa-a", + "payer_email" => "dev+paypal-user2@sharetribe.com", + "mc_shipping1" => "0.00", + "tax1" => "0.00", + "parent_txn_id" => "", + "txn_id" => "8X37683373099502U", + "payment_type" => "instant", + "remaining_settle" => "10", + "auth_id" => "8X37683373099502U", + "payer_business_name" => "SandboxTest Account's Test Store", + "last_name" => "Account", + "item_name1" => "Testing", + "receiver_email" => "dev+paypal-user1@sharetribe.com", + "auth_amount" => "100.00", + "quantity1" => "1", + "receiver_id" => "URAPMR7WHFAWY", + "txn_type" => "cart", + "mc_gross_1" => "100.00", + "mc_currency" => "GBP", + "residence_country" => "GB", + "test_ipn" => "1", + "transaction_subject" => "", + "payment_gross" => "", + "auth_status" => "Voided", + "ipn_track_id" => "deb829141b651" } payment_completed = { @@ -343,7 +343,7 @@ "transaction_entity" => "auth", "transaction_subject" => "", "txn_id" => "0J90171846752303G", - "txn_type" => "cart", + "txn_type" => "cart" } commission_paid = { @@ -446,226 +446,226 @@ } payment_refunded = { - "mc_gross"=>"-1.20", - "auth_exp"=>"23:50:00 Oct 03, 2014 PDT", - "protection_eligibility"=>"Ineligible", - "payer_id"=>"6M39X6RCYVUD6", - "payment_date"=>"23:24:36 Sep 30, 2014 PDT", - "payment_status"=>"Refunded", - "charset"=>"windows-1252", - "first_name"=>"ljkh", - "transaction_entity"=>"payment", - "mc_fee"=>"-0.04", - "notify_version"=>"3.8", - "reason_code"=>"refund", - "custom"=>"", - "verify_sign"=>"AGu.hbwMxRXoqDiyy-IJNOnULnvNAAs8Pg60O96MreRfhHhWgoCGDYFf", - "payer_email"=>"foobar@barfoo.com", - "parent_txn_id"=>"4BV77412CY217203L", - "txn_id"=>"7HX881531H984174B", - "payment_type"=>"instant", - "remaining_settle"=>"9", - "auth_id"=>"0L584749FU2628910", - "last_name"=>"kjh", - "receiver_email"=>"dev+paypal-user1@sharetribe.com", - "payment_fee"=>"", - "auth_amount"=>"1.20", - "receiver_id"=>"URAPMR7WHFAWY", - "item_name"=>"desc", - "mc_currency"=>"GBP", - "item_number"=>"", - "residence_country"=>"GB", - "test_ipn"=>"1", - "receipt_id"=>"3609-0935-6989-4532", - "handling_amount"=>"0.00", - "transaction_subject"=>"", - "payment_gross"=>"", - "shipping"=>"0.00", - "auth_status"=>"Completed", - "ipn_track_id"=>"be492945b2622" + "mc_gross" => "-1.20", + "auth_exp" => "23:50:00 Oct 03, 2014 PDT", + "protection_eligibility" => "Ineligible", + "payer_id" => "6M39X6RCYVUD6", + "payment_date" => "23:24:36 Sep 30, 2014 PDT", + "payment_status" => "Refunded", + "charset" => "windows-1252", + "first_name" => "ljkh", + "transaction_entity" => "payment", + "mc_fee" => "-0.04", + "notify_version" => "3.8", + "reason_code" => "refund", + "custom" => "", + "verify_sign" => "AGu.hbwMxRXoqDiyy-IJNOnULnvNAAs8Pg60O96MreRfhHhWgoCGDYFf", + "payer_email" => "foobar@barfoo.com", + "parent_txn_id" => "4BV77412CY217203L", + "txn_id" => "7HX881531H984174B", + "payment_type" => "instant", + "remaining_settle" => "9", + "auth_id" => "0L584749FU2628910", + "last_name" => "kjh", + "receiver_email" => "dev+paypal-user1@sharetribe.com", + "payment_fee" => "", + "auth_amount" => "1.20", + "receiver_id" => "URAPMR7WHFAWY", + "item_name" => "desc", + "mc_currency" => "GBP", + "item_number" => "", + "residence_country" => "GB", + "test_ipn" => "1", + "receipt_id" => "3609-0935-6989-4532", + "handling_amount" => "0.00", + "transaction_subject" => "", + "payment_gross" => "", + "shipping" => "0.00", + "auth_status" => "Completed", + "ipn_track_id" => "be492945b2622" } payment_refunded_2 = { - "mp_custom"=>"", - "mc_gross"=>"-0.64", - "invoice"=>"56276-com", - "mp_currency"=>"EUR", - "protection_eligibility"=>"Ineligible", - "item_number1"=>"0", - "payer_id"=>"XW9NUKKUJACWC", - "payment_date"=>"05:25:00 Nov 10, 2014 PST", - "mp_id"=>"B-AOUSH3A4979771B", + "mp_custom" => "", + "mc_gross" => "-0.64", + "invoice" => "56276-com", + "mp_currency" => "EUR", + "protection_eligibility" => "Ineligible", + "item_number1" => "0", + "payer_id" => "XW9NUKKUJACWC", + "payment_date" => "05:25:00 Nov 10, 2014 PST", + "mp_id" => "B-AOUSH3A4979771B", "payment_status" => "Refunded", - "charset"=>"windows-1252", - "mc_shipping"=>"0.00", - "mc_handling"=>"0.00", - "first_name"=>"Payer", - "mp_status"=>"0", - "mc_fee"=>"-0.37", - "notify_version"=>"3.8", - "reason_code"=>"refund", - "custom"=>"", - "business"=>"business@sharetribe.com", - "mc_handling1"=>"0.00", - "verify_sign"=>"AAh-gjasoneuth1123345BYSjRRxpMh.TZTW6.sXma", - "payer_email"=>"payer@ex.com", - "mc_shipping1"=>"0.00", - "tax1"=>"0.00", - "parent_txn_id"=>"47AOU05AUAOU349131H", - "txn_id"=>"12344567", - "payment_type"=>"instant", - "last_name"=>"PayerS", - "mp_desc"=>"Grant RealMoneyPaypalMarketplace permission to charge a transaction fee.", - "item_name1"=>"Commission payment for %{listing_title}", - "receiver_email"=>"res@ex.com", - "payment_fee"=>"", - "mp_cycle_start"=>"10", - "quantity1"=>"1", - "receiver_id"=>"ABCDEC10FE", - "mc_gross_1"=>"0.64", - "mc_currency"=>"EUR", - "residence_country"=>"FI", - "transaction_subject"=>"Marketplace %{service_name} took this commission from transaction regarding %{listing_title}", - "payment_gross"=>"", - "ipn_track_id"=>"baf19293942b40"} + "charset" => "windows-1252", + "mc_shipping" => "0.00", + "mc_handling" => "0.00", + "first_name" => "Payer", + "mp_status" => "0", + "mc_fee" => "-0.37", + "notify_version" => "3.8", + "reason_code" => "refund", + "custom" => "", + "business" => "business@sharetribe.com", + "mc_handling1" => "0.00", + "verify_sign" => "AAh-gjasoneuth1123345BYSjRRxpMh.TZTW6.sXma", + "payer_email" => "payer@ex.com", + "mc_shipping1" => "0.00", + "tax1" => "0.00", + "parent_txn_id" => "47AOU05AUAOU349131H", + "txn_id" => "12344567", + "payment_type" => "instant", + "last_name" => "PayerS", + "mp_desc" => "Grant RealMoneyPaypalMarketplace permission to charge a transaction fee.", + "item_name1" => "Commission payment for %{listing_title}", + "receiver_email" => "res@ex.com", + "payment_fee" => "", + "mp_cycle_start" => "10", + "quantity1" => "1", + "receiver_id" => "ABCDEC10FE", + "mc_gross_1" => "0.64", + "mc_currency" => "EUR", + "residence_country" => "FI", + "transaction_subject" => "Marketplace %{service_name} took this commission from transaction regarding %{listing_title}", + "payment_gross" => "", + "ipn_track_id" => "baf19293942b40"} billing_agreement_created = { - "txn_type"=>"mp_signup", - "last_name"=>"Account", - "mp_currency"=>"USD", - "residence_country"=>"US", - "mp_status"=>"0", - "mp_custom"=>"", - "mp_pay_type"=>"instant", - "verify_sign"=>"Ai1GUBsAVJLTrgWjhBLUx4LnD5C4ASJgGq5Jhwo7k-eq6ymSzkNPce3s", - "payer_status"=>"verified", - "test_ipn"=>"1", - "payer_email"=>"dev+paypal_us@sharetribe.com", - "first_name"=>"SandboxTest", - "payer_id"=>"P6S3ZMLQ25AYU", - "reason_code"=>"mp_2001", - "payer_business_name"=>"SandboxTest Account's Test Store", - "mp_id"=>"B-80N6310848330024M", - "charset"=>"windows-1252", - "notify_version"=>"3.8", - "mp_desc"=>"Grant Sharetribe permission to charge a transaction fee.", - "mp_cycle_start"=>"14", - "ipn_track_id"=>"8eb38a4d6fac0" + "txn_type" => "mp_signup", + "last_name" => "Account", + "mp_currency" => "USD", + "residence_country" => "US", + "mp_status" => "0", + "mp_custom" => "", + "mp_pay_type" => "instant", + "verify_sign" => "Ai1GUBsAVJLTrgWjhBLUx4LnD5C4ASJgGq5Jhwo7k-eq6ymSzkNPce3s", + "payer_status" => "verified", + "test_ipn" => "1", + "payer_email" => "dev+paypal_us@sharetribe.com", + "first_name" => "SandboxTest", + "payer_id" => "P6S3ZMLQ25AYU", + "reason_code" => "mp_2001", + "payer_business_name" => "SandboxTest Account's Test Store", + "mp_id" => "B-80N6310848330024M", + "charset" => "windows-1252", + "notify_version" => "3.8", + "mp_desc" => "Grant Sharetribe permission to charge a transaction fee.", + "mp_cycle_start" => "14", + "ipn_track_id" => "8eb38a4d6fac0" } billing_agreement_cancelled = { - "txn_type"=>"mp_cancel", - "last_name"=>"Account", - "mp_currency"=>"USD", - "residence_country"=>"GB", - "mp_status"=>"1", - "mp_custom"=>"", - "verify_sign"=>"ASVYRST0Jt3HL5ZvdLlfhfgxqvNbAjF-ZOgA2kiZUDAEcVV2IHG6RutL", - "payer_status"=>"verified", - "test_ipn"=>"1", - "payer_email"=>"dev+paypal-user1@sharetribe.com", - "first_name"=>"SandboxTest", - "payer_id"=>"URAPMR7WHFAWY", - "reason_code"=>"mp_2002", - "payer_business_name"=>"SandboxTest Account's Test Store", - "mp_id"=>"B-5WU95213TP0919018", - "charset"=>"windows-1252", - "notify_version"=>"3.8", - "mp_desc"=>"commissions", - "mp_cycle_start"=>"1", - "ipn_track_id"=>"67e92d1e16ac5" + "txn_type" => "mp_cancel", + "last_name" => "Account", + "mp_currency" => "USD", + "residence_country" => "GB", + "mp_status" => "1", + "mp_custom" => "", + "verify_sign" => "ASVYRST0Jt3HL5ZvdLlfhfgxqvNbAjF-ZOgA2kiZUDAEcVV2IHG6RutL", + "payer_status" => "verified", + "test_ipn" => "1", + "payer_email" => "dev+paypal-user1@sharetribe.com", + "first_name" => "SandboxTest", + "payer_id" => "URAPMR7WHFAWY", + "reason_code" => "mp_2002", + "payer_business_name" => "SandboxTest Account's Test Store", + "mp_id" => "B-5WU95213TP0919018", + "charset" => "windows-1252", + "notify_version" => "3.8", + "mp_desc" => "commissions", + "mp_cycle_start" => "1", + "ipn_track_id" => "67e92d1e16ac5" } #This one captured in multi-currency situation #If some other pending reason is captured, compare fields payment_pending_ext = { - "mc_gross"=>"100.00", - "invoice"=>"2-41", - "auth_exp"=>"23:50:00 Oct 30, 2014 PDT", - "protection_eligibility"=>"Ineligible", - "item_number1"=>"", - "payer_id"=>"7LFUVCDKGARH4", - "tax"=>"0.00", - "payment_date"=>"07:05:21 Oct 27, 2014 PDT", - "payment_status"=>"Pending", - "charset"=>"windows-1252", - "mc_shipping"=>"0.00", - "mc_handling"=>"0.00", - "first_name"=>"SandboxTest", - "transaction_entity"=>"payment", - "notify_version"=>"3.8", - "custom"=>"", - "payer_status"=>"verified", - "num_cart_items"=>"1", - "verify_sign"=>"Arsl7-LMI7rFwHLn2AZcRGMd.BLwAJFH7WGQjWjJjDuIVjPXV4-qgzMZ", - "payer_email"=>"dev+paypal-user2@sharetribe.com", - "parent_txn_id"=>"999243345J942435W", - "txn_id"=>"60J56194US3230833", - "payment_type"=>"instant", - "remaining_settle"=>"9", - "auth_id"=>"999243345J942435W", - "payer_business_name"=>"SandboxTest Account's Test Store", - "last_name"=>"Account", - "item_name1"=>"Testing", - "receiver_email"=>"dev+paypal-user1@sharetribe.com", - "auth_amount"=>"100.00", - "quantity1"=>"1", - "receiver_id"=>"URAPMR7WHFAWY", - "pending_reason"=>"multi_currency", - "txn_type"=>"cart", - "mc_gross_1"=>"100.00", - "mc_currency"=>"USD", - "residence_country"=>"GB", - "test_ipn"=>"1", - "transaction_subject"=>"", - "payment_gross"=>"100.00", - "auth_status"=>"Completed", - "ipn_track_id"=>"7119fe92afd3c" + "mc_gross" => "100.00", + "invoice" => "2-41", + "auth_exp" => "23:50:00 Oct 30, 2014 PDT", + "protection_eligibility" => "Ineligible", + "item_number1" => "", + "payer_id" => "7LFUVCDKGARH4", + "tax" => "0.00", + "payment_date" => "07:05:21 Oct 27, 2014 PDT", + "payment_status" => "Pending", + "charset" => "windows-1252", + "mc_shipping" => "0.00", + "mc_handling" => "0.00", + "first_name" => "SandboxTest", + "transaction_entity" => "payment", + "notify_version" => "3.8", + "custom" => "", + "payer_status" => "verified", + "num_cart_items" => "1", + "verify_sign" => "Arsl7-LMI7rFwHLn2AZcRGMd.BLwAJFH7WGQjWjJjDuIVjPXV4-qgzMZ", + "payer_email" => "dev+paypal-user2@sharetribe.com", + "parent_txn_id" => "999243345J942435W", + "txn_id" => "60J56194US3230833", + "payment_type" => "instant", + "remaining_settle" => "9", + "auth_id" => "999243345J942435W", + "payer_business_name" => "SandboxTest Account's Test Store", + "last_name" => "Account", + "item_name1" => "Testing", + "receiver_email" => "dev+paypal-user1@sharetribe.com", + "auth_amount" => "100.00", + "quantity1" => "1", + "receiver_id" => "URAPMR7WHFAWY", + "pending_reason" => "multi_currency", + "txn_type" => "cart", + "mc_gross_1" => "100.00", + "mc_currency" => "USD", + "residence_country" => "GB", + "test_ipn" => "1", + "transaction_subject" => "", + "payment_gross" => "100.00", + "auth_status" => "Completed", + "ipn_track_id" => "7119fe92afd3c" } payment_denied = { - "mc_gross"=>"23.00", - "invoice"=>"1816-56274", - "auth_exp"=>"23:50:02 Nov 13, 2014 PST", - "protection_eligibility"=>"Ineligible", - "item_number1"=>"", - "payer_id"=>"XXXSNUI6KNJRCWC", - "tax"=>"0.00", - "payment_date"=>"04:46:57 Nov 10, 2014 PST", - "payment_status"=>"Denied", - "charset"=>"windows-1252", - "mc_shipping"=>"0.00", - "mc_handling"=>"0.00", - "first_name"=>"Payer", - "transaction_entity"=>"payment", - "notify_version"=>"3.8", - "custom"=>"", - "payer_status"=>"verified", - "num_cart_items"=>"1", - "mc_handling1"=>"0.00", - "verify_sign"=>"AU-csK8ARzBek50hhiQq3LGyRaZJAVBhODYeBFjL3FdAK5LW3DmMUZ6D", - "payer_email"=>"payer@sharetribe.com", - "mc_shipping1"=>"0.00", - "tax1"=>"0.00", - "parent_txn_id"=>"00000ABCDECEC", - "txn_id"=>"4BASUNHUSNH", - "payment_type"=>"instant", - "remaining_settle"=>"9", - "auth_id"=>"0ASUNH5413802", - "last_name"=>"Last", - "item_name1"=>"Svenks Rally Car", - "receiver_email"=>"receiver@sharetribe.com", - "auth_amount"=>"23.00", - "quantity1"=>"1", - "receiver_id"=>"HTLXESTNHJ5W", - "txn_type"=>"cart", - "mc_gross_1"=>"23.00", - "mc_currency"=>"SEK", - "residence_country"=>"FI", - "transaction_subject"=>"", - "payment_gross"=>"", - "auth_status"=>"Completed", - "ipn_track_id"=>"1239845790gdaho" + "mc_gross" => "23.00", + "invoice" => "1816-56274", + "auth_exp" => "23:50:02 Nov 13, 2014 PST", + "protection_eligibility" => "Ineligible", + "item_number1" => "", + "payer_id" => "XXXSNUI6KNJRCWC", + "tax" => "0.00", + "payment_date" => "04:46:57 Nov 10, 2014 PST", + "payment_status" => "Denied", + "charset" => "windows-1252", + "mc_shipping" => "0.00", + "mc_handling" => "0.00", + "first_name" => "Payer", + "transaction_entity" => "payment", + "notify_version" => "3.8", + "custom" => "", + "payer_status" => "verified", + "num_cart_items" => "1", + "mc_handling1" => "0.00", + "verify_sign" => "AU-csK8ARzBek50hhiQq3LGyRaZJAVBhODYeBFjL3FdAK5LW3DmMUZ6D", + "payer_email" => "payer@sharetribe.com", + "mc_shipping1" => "0.00", + "tax1" => "0.00", + "parent_txn_id" => "00000ABCDECEC", + "txn_id" => "4BASUNHUSNH", + "payment_type" => "instant", + "remaining_settle" => "9", + "auth_id" => "0ASUNH5413802", + "last_name" => "Last", + "item_name1" => "Svenks Rally Car", + "receiver_email" => "receiver@sharetribe.com", + "auth_amount" => "23.00", + "quantity1" => "1", + "receiver_id" => "HTLXESTNHJ5W", + "txn_type" => "cart", + "mc_gross_1" => "23.00", + "mc_currency" => "SEK", + "residence_country" => "FI", + "transaction_subject" => "", + "payment_gross" => "", + "auth_status" => "Completed", + "ipn_track_id" => "1239845790gdaho" } payment_completed_2 = { diff --git a/spec/services/paypal_service/ipn_spec.rb b/spec/services/paypal_service/ipn_spec.rb index bf559ec912..62e10fc39d 100644 --- a/spec/services/paypal_service/ipn_spec.rb +++ b/spec/services/paypal_service/ipn_spec.rb @@ -10,11 +10,11 @@ @ipn_service = PaypalService::IPN.new(@events) @billing_agreement_created = { - :type=>:billing_agreement_created, - :billing_agreement_id=>"B-80N6310848330024M", - :payer_id=>"P6S3ZMLQ25AYU", - :payer_email=>"dev+paypal_us@sharetribe.com", - :payer_status=>"verified" + :type => :billing_agreement_created, + :billing_agreement_id => "B-80N6310848330024M", + :payer_id => "P6S3ZMLQ25AYU", + :payer_email => "dev+paypal_us@sharetribe.com", + :payer_status => "verified" } @billing_agreement_cancelled = { @@ -106,7 +106,7 @@ @order_created_msg = { type: :order_created, - order_date: "2014-10-01 09:04:07 +0300", + order_date: "2014-10-01 09:04:07 +0300", order_id: "O-2ES620817J8424036", payer_email: "foobar@barfoo.com", payer_id: "7LFUVCDKGARH4", @@ -147,9 +147,9 @@ receiver_id: "XAOENU6KNJRCWC", payment_status: "Completed", pending_reason: :none, - receipt_id: nil, - authorization_total: Money.new(120, "GBP"), - payment_total: Money.new(120, "GBP"), + receipt_id: nil, + authorization_total: Money.new(120, "GBP"), + payment_total: Money.new(120, "GBP"), fee_total: nil } @@ -395,45 +395,45 @@ context "async handling" do before(:each) do @auth_created_params = { - "mc_gross"=>"1.20", - "auth_exp"=>"23:50:00 Oct 03, 2014 PDT", - "protection_eligibility"=>"Ineligible", - "payer_id"=>"7LFUVCDKGARH", - "tax"=>"0.00", - "payment_date"=>"23:04:07 Sep 30, 2014 PDT", - "payment_status"=>"Pending", - "charset"=>"windows-1252", - "first_name"=>"ljkh", - "transaction_entity"=>"auth", - "notify_version"=>"3.8", - "custom"=>"", - "payer_status"=>"unverified", - "quantity"=>"1", - "verify_sign"=>"A2S1fniRGsoquzRDbs4f5rc383f8A9BZtlhOnNThbBpkIOUsU.U6RJlP", - "payer_email"=>"foobar@barfoo.com", - "parent_txn_id"=>"O-2ES620817J8424036", - "txn_id"=>"0L584749FU2628910", - "payment_type"=>"instant", - "remaining_settle"=>"10", - "auth_id"=>"0L584749FU2628910", - "last_name"=>"kjh", - "receiver_email"=>"dev+paypal-user1@sharetribe.com", - "auth_amount"=>"1.20", - "receiver_id"=>"URAPMR7WHFAWY", - "pending_reason"=>"authorization", - "txn_type"=>"express_checkout", - "item_name"=>"desc", - "mc_currency"=>"GBP", - "item_number"=>"", - "residence_country"=>"GB", - "test_ipn"=>"1", - "receipt_id"=>"3609-0935-6989-4532", - "handling_amount"=>"0.00", - "transaction_subject"=>"", - "payment_gross"=>"", - "auth_status"=>"Pending", - "shipping"=>"0.00", - "ipn_track_id"=>"35b2bed5966" + "mc_gross" => "1.20", + "auth_exp" => "23:50:00 Oct 03, 2014 PDT", + "protection_eligibility" => "Ineligible", + "payer_id" => "7LFUVCDKGARH", + "tax" => "0.00", + "payment_date" => "23:04:07 Sep 30, 2014 PDT", + "payment_status" => "Pending", + "charset" => "windows-1252", + "first_name" => "ljkh", + "transaction_entity" => "auth", + "notify_version" => "3.8", + "custom" => "", + "payer_status" => "unverified", + "quantity" => "1", + "verify_sign" => "A2S1fniRGsoquzRDbs4f5rc383f8A9BZtlhOnNThbBpkIOUsU.U6RJlP", + "payer_email" => "foobar@barfoo.com", + "parent_txn_id" => "O-2ES620817J8424036", + "txn_id" => "0L584749FU2628910", + "payment_type" => "instant", + "remaining_settle" => "10", + "auth_id" => "0L584749FU2628910", + "last_name" => "kjh", + "receiver_email" => "dev+paypal-user1@sharetribe.com", + "auth_amount" => "1.20", + "receiver_id" => "URAPMR7WHFAWY", + "pending_reason" => "authorization", + "txn_type" => "express_checkout", + "item_name" => "desc", + "mc_currency" => "GBP", + "item_number" => "", + "residence_country" => "GB", + "test_ipn" => "1", + "receipt_id" => "3609-0935-6989-4532", + "handling_amount" => "0.00", + "transaction_subject" => "", + "payment_gross" => "", + "auth_status" => "Pending", + "shipping" => "0.00", + "ipn_track_id" => "35b2bed5966" }.with_indifferent_access SyncDelayedJobObserver.reset! diff --git a/spec/services/plan_service/api/api.rb b/spec/services/plan_service/api/api.rb index 274ad93137..ba1174f29d 100644 --- a/spec/services/plan_service/api/api.rb +++ b/spec/services/plan_service/api/api.rb @@ -35,7 +35,7 @@ def self.default_test_environment() { active: false, jwt_secret: "test_secret", - external_plan_service_login_url: "http://external.plan.service.com", + external_plan_service_login_url: "http://external.plan.service.com" } end diff --git a/spec/services/plan_service/api/plans_spec.rb b/spec/services/plan_service/api/plans_spec.rb index 661e7bbcbd..20592d940a 100644 --- a/spec/services/plan_service/api/plans_spec.rb +++ b/spec/services/plan_service/api/plans_spec.rb @@ -23,7 +23,7 @@ plans_api.create_initial_trial( community_id: 123, plan: { status: :trial, - expires_at: expires_at, + expires_at: expires_at }) res = plans_api.get_current(community_id: 123) @@ -53,7 +53,7 @@ status: :active, features: { whitelabel: true, admin_email: true }, member_limit: 100000, - expires_at: expires_at, + expires_at: expires_at }) res = plans_api.get_current(community_id: 123) @@ -80,7 +80,7 @@ community_id: 123, plan: { status: :active, features: { whitelabel: true, admin_email: true }, - member_limit: 1000, + member_limit: 1000 }) res = plans_api.get_current(community_id: 123) @@ -106,7 +106,8 @@ expect { plans_api.create( community_id: 123, plan: { expires_at: 1.month.from_now - }) }.to raise_error(ArgumentError) + }) + } .to raise_error(ArgumentError) end it "returns error if plan can not be found" do @@ -119,17 +120,19 @@ community_id: 123, plan: { status: :active, - member_limit: 1000, - }) }.to raise_error(ArgumentError) + member_limit: 1000 + }) + } .to raise_error(ArgumentError) end it "raises error if status is missing"do expect { plans_api.create( community_id: 123, plan: { - features: {whitelabel: :true}, - member_limit: 1000, - }) }.to raise_error(ArgumentError) + features: {whitelabel: true}, + member_limit: 1000 + }) + } .to raise_error(ArgumentError) end end end @@ -177,7 +180,7 @@ community_id: 111, plan: { status: :hold, features: { deletable: false, admin_email: true, whitelabel: true }, - expires_at: nil, # plan never expires + expires_at: nil # plan never expires }).data expect(plan[:expired]).to eq(false) @@ -188,7 +191,7 @@ community_id: 111, plan: { status: :hold, features: { deletable: false, admin_email: true, whitelabel: true }, - expires_at: 1.month.from_now, + expires_at: 1.month.from_now }).data expect(plan[:expired]).to eq(false) @@ -199,7 +202,7 @@ community_id: 111, plan: { status: :hold, features: { deletable: false, admin_email: true, whitelabel: true }, - expires_at: 1.month.ago, + expires_at: 1.month.ago }).data expect(plan[:expired]).to eq(true) @@ -212,7 +215,7 @@ community_id: 111, plan: { status: :active, features: { deletable: false, admin_email: true, whitelabel: true }, - expires_at: nil, # plan never expires + expires_at: nil # plan never expires }).data expect(plan[:expired]).to eq(false) @@ -224,7 +227,7 @@ community_id: 111, plan: { status: :trial, features: { deletable: true, admin_email: false, whitelabel: false }, - expires_at: Time.now - 1.day, + expires_at: Time.now - 1.day }).data expect(plan[:expired]).to eq(true) diff --git a/spec/services/result.rb b/spec/services/result.rb index d36cab35db..eafb881719 100644 --- a/spec/services/result.rb +++ b/spec/services/result.rb @@ -69,9 +69,9 @@ def expect_error(result, expected_error_msg, expected_error_data=nil) end it "throws error if lambda results something else than result" do - expect { Result.all(->() { success })}.not_to raise_error - expect { Result.all(->() { error })}.not_to raise_error - expect { Result.all(->() { "a string" })}.to raise_error(ArgumentError, "Lambda must return Result") + expect { Result.all(-> { success })}.not_to raise_error + expect { Result.all(-> { error })}.not_to raise_error + expect { Result.all(-> { "a string" })}.to raise_error(ArgumentError, "Lambda must return Result") end end diff --git a/spec/services/transaction_service/order.rb b/spec/services/transaction_service/order.rb index eee288ce09..9d2a6d36ea 100644 --- a/spec/services/transaction_service/order.rb +++ b/spec/services/transaction_service/order.rb @@ -78,7 +78,7 @@ it "calculates the order total (item total + shipping total)" do listing = FactoryGirl.create(:listing, price: Money.new(25_000, "EUR"), - shipping_price: Money.new(2_000, "EUR"), + shipping_price: Money.new(2_000, "EUR"), shipping_price_additional: Money.new(500, "EUR"), community_id: community.id) tx_params = {quantity: 5, delivery: :shipping} diff --git a/spec/services/transaction_service/paypal_events_spec.rb b/spec/services/transaction_service/paypal_events_spec.rb index 82cfd25455..1ab0247ab4 100644 --- a/spec/services/transaction_service/paypal_events_spec.rb +++ b/spec/services/transaction_service/paypal_events_spec.rb @@ -156,7 +156,7 @@ def create_test_transaction(opts) order_total: Money.new(22000, "EUR"), authorization_id: SecureRandom.uuid, authorization_date: Time.now, - authorization_total: Money.new(22000, "EUR"), + authorization_total: Money.new(22000, "EUR") }) end @@ -180,7 +180,7 @@ def create_test_transaction(opts) order_total: Money.new(22000, "EUR"), authorization_id: SecureRandom.uuid, authorization_date: Time.now, - authorization_total: Money.new(22000, "EUR"), + authorization_total: Money.new(22000, "EUR") }) end @@ -210,7 +210,7 @@ def create_test_transaction(opts) pending_reason: "authorization", order_id: SecureRandom.uuid, order_date: Time.now, - order_total: Money.new(22000, "EUR"), + order_total: Money.new(22000, "EUR") }) @voided_payment_no_msg = payment_store.update(community_id: @cid, transaction_id: @transaction_no_msg.id, data: { pending_reason: :none, @@ -224,7 +224,7 @@ def create_test_transaction(opts) pending_reason: "authorization", order_id: SecureRandom.uuid, order_date: Time.now, - order_total: Money.new(22000, "EUR"), + order_total: Money.new(22000, "EUR") }) @voided_payment_with_msg = payment_store.update(community_id: @cid, transaction_id: @transaction_with_msg.id, data: { pending_reason: :none, @@ -299,7 +299,7 @@ def create_test_transaction(opts) pending_reason: "authorization", order_id: SecureRandom.uuid, order_date: Time.now, - order_total: Money.new(22000, "EUR"), + order_total: Money.new(22000, "EUR") }) @authorized_payment = payment_store.update(community_id: @cid, transaction_id: @transaction_with_msg.id, data: { @@ -334,7 +334,7 @@ def create_test_transaction(opts) pending_reason: "authorization", order_id: SecureRandom.uuid, order_date: Time.now, - order_total: Money.new(22000, "EUR"), + order_total: Money.new(22000, "EUR") }) @authorized_payment = payment_store.update(community_id: @cid, transaction_id: @transaction_with_msg.id, data: { @@ -372,7 +372,7 @@ def create_test_transaction(opts) pending_reason: "authorization", order_id: SecureRandom.uuid, order_date: Time.now, - order_total: Money.new(22000, "EUR"), + order_total: Money.new(22000, "EUR") }) @authorized_payment = payment_store.update(community_id: @cid, transaction_id: @transaction_with_msg.id, data: { diff --git a/spec/services/transaction_service/store/payment_settings_spec.rb b/spec/services/transaction_service/store/payment_settings_spec.rb index 41b4a96ae2..5b383f1cb5 100644 --- a/spec/services/transaction_service/store/payment_settings_spec.rb +++ b/spec/services/transaction_service/store/payment_settings_spec.rb @@ -15,7 +15,7 @@ commission_from_buyer: nil, minimum_buyer_transaction_fee_cents: nil, minimum_buyer_transaction_fee_currency: nil, - key_encryption_padding: true, + key_encryption_padding: true } expect( payment_settings.create( diff --git a/spec/services/translation_service/api/translation_spec.rb b/spec/services/translation_service/api/translation_spec.rb index 38928e66c4..59cc764e05 100644 --- a/spec/services/translation_service/api/translation_spec.rb +++ b/spec/services/translation_service/api/translation_spec.rb @@ -13,27 +13,27 @@ @translation_fi = "aa fi" @locale_sv = "sv-SE" @translations1 = - [ { locale: @locale_en, - translation: @translation_en + [{ locale: @locale_en, + translation: @translation_en }, - { locale: @locale_fi, - translation: @translation_fi - } - ] + { locale: @locale_fi, + translation: @translation_fi + } +] @translations_with_keys = @translations1.map { |translation| {translation_key: @translation_key1}.merge(translation) } @translations_groups = - [ { translation_key: @translation_key1, - translations: @translations1 + [{ translation_key: @translation_key1, + translations: @translations1 } - ] +] @translation_groups_with_keys = - [ { translation_key: @translation_key1, - translations: @translations_with_keys + [{ translation_key: @translation_key1, + translations: @translations_with_keys } - ] +] @creation_hash = { community_id: @community_id, translation_groups: @translations_groups @@ -51,7 +51,7 @@ end it "POST request with community_id and wrong structure in params" do - expect { TranslationsAPI.create(@community_id, [translations: [{locale: @locale_sv}] ]) }.to raise_error(ArgumentError) + expect { TranslationsAPI.create(@community_id, [translations: [{locale: @locale_sv}]]) }.to raise_error(ArgumentError) end it "POST request with community_id and correct params" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c37f630016..c375cb3d78 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,7 +13,7 @@ if $LOADED_FEATURES.grep(/spec\/spec_helper\.rb/).any? begin raise "foo" - rescue => e + rescue StandardError => e puts <<-MSG =================================================== It looks like spec_helper.rb has been loaded @@ -35,7 +35,7 @@ # This file is copied to ~/spec when you run 'ruby script/generate rspec' # from the project root directory. ENV["RAILS_ENV"] ||= 'test' - require File.expand_path("../../config/environment", __FILE__) + require File.expand_path('../config/environment', __dir__) require 'rspec/rails' require "email_spec" require './spec/support/webmock' diff --git a/spec/support/database_cleanup.rb b/spec/support/database_cleanup.rb index a891f714cc..ba62d436c2 100644 --- a/spec/support/database_cleanup.rb +++ b/spec/support/database_cleanup.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../test/helper_modules', __FILE__) -include TestHelpers +require File.expand_path('../../test/helper_modules', __dir__) +include TestHelpers # rubocop:disable Style/MixinUsage RSpec.configure do |config| clean_db = -> { diff --git a/spec/support/omniauth.rb b/spec/support/omniauth.rb index f04ce5e942..f00bebfb21 100644 --- a/spec/support/omniauth.rb +++ b/spec/support/omniauth.rb @@ -95,7 +95,7 @@ def oauth_google_data hd: 'ithouse.lv', email: 'john@ithouse.lv', iat: 1474618935, - exp: 1474622535, + exp: 1474622535 }, raw_info: { kind: 'plus#personOpenIdConnect', @@ -109,7 +109,7 @@ def oauth_google_data email: 'john@ithouse.lv', email_verified: 'true', locale: 'lv', - hd: 'ithouse.lv', + hd: 'ithouse.lv' } } } @@ -117,145 +117,145 @@ def oauth_google_data # rubocop:disable Metrics/MethodLength def oauth_linkedin_data - {"provider"=>"linkedin", - "uid"=>"50k-SSSS99", - "info"=> - {"email"=>"devel@example.com", - "first_name"=>"Tony", - "last_name"=>"Testmen", - "picture_url"=> + {"provider" => "linkedin", + "uid" => "50k-SSSS99", + "info" => + {"email" => "devel@example.com", + "first_name" => "Tony", + "last_name" => "Testmen", + "picture_url" => "https://media.licdn.com/dms/image/C5603AQEK2H8SiE59Jw/profile-displayphoto-shrink_800_800/0?e=1553126400&v=beta&t=9Zg8_GZwAKl_Za2CF5IgC-gD2XvHjupCm_8wqdQjvVk"}, - "credentials"=> - {"token"=> + "credentials" => + {"token" => "12345678-DGT50OyLxmjzY9SssMxeBSEpDC2R25vr68hVy3HwRcU5jDmLhg2UKsPDWBCoQo9XyE4BG84xFNLZ3RDUzAoEJLVGBAxh99cLWjSc9ghODpIwfv3A6rLn4yx3Cs1IR2L9ofWtOoXmUVWoKfM2Mj4Bj_OHoVzt47wCxWQfq1gL28Ro8IP4qMrheWCr2TzX1QHHs0XdhytStcos3C_D6XmhhpFTMaHL5W06ej7eIn5dJJIr_xNu-u7LtgDTU0h3v0wMlkmcXFKnY_iZZ3SldyLJs-6E00YonU6unhuxLz5Zzj2hEZ1gNVEgEvQqCS6EDTiNfUTfu1PBIYPIqqqqQQQQ", - "expires_at"=>1552727705, - "expires"=>true}, - "extra"=> - {"raw_info"=> - {"firstName"=> - {"localized"=>{"en_US"=>"Tony"}, - "preferredLocale"=>{"country"=>"US", "language"=>"en"}}, - "lastName"=> - {"localized"=>{"en_US"=>"Testmen"}, - "preferredLocale"=>{"country"=>"US", "language"=>"en"}}, - "profilePicture"=> - {"displayImage"=>"urn:li:digitalmediaAsset:C5603AQEK2H8SiE59Jw", - "displayImage~"=> - {"elements"=> - [{"artifact"=> + "expires_at" => 1552727705, + "expires" => true}, + "extra" => + {"raw_info" => + {"firstName" => + {"localized" => {"en_US"=>"Tony"}, + "preferredLocale" => {"country"=>"US", "language"=>"en"}}, + "lastName" => + {"localized" => {"en_US"=>"Testmen"}, + "preferredLocale" => {"country"=>"US", "language"=>"en"}}, + "profilePicture" => + {"displayImage" => "urn:li:digitalmediaAsset:C5603AQEK2H8SiE59Jw", + "displayImage~" => + {"elements" => + [{"artifact" => "urn:li:digitalmediaMediaArtifact:(urn:li:digitalmediaAsset:C5603AQEK2H8SiE59Jw,urn:li:digitalmediaMediaArtifactClass:profile-displayphoto-shrink_100_100)", - "authorizationMethod"=>"PUBLIC", - "data"=> - {"com.linkedin.digitalmedia.mediaartifact.StillImage"=> - {"storageSize"=>{"width"=>100, "height"=>100}, - "storageAspectRatio"=> - {"widthAspect"=>1.0, - "heightAspect"=>1.0, - "formatted"=>"1.00:1.00"}, - "mediaType"=>"image/jpeg", - "rawCodecSpec"=>{"name"=>"jpeg", "type"=>"image"}, - "displaySize"=>{"uom"=>"PX", "width"=>100.0, "height"=>100.0}, - "displayAspectRatio"=> - {"widthAspect"=>1.0, - "heightAspect"=>1.0, - "formatted"=>"1.00:1.00"}}}, - "identifiers"=> - [{"identifier"=> + "authorizationMethod" => "PUBLIC", + "data" => + {"com.linkedin.digitalmedia.mediaartifact.StillImage" => + {"storageSize" => {"width"=>100, "height"=>100}, + "storageAspectRatio" => + {"widthAspect" => 1.0, + "heightAspect" => 1.0, + "formatted" => "1.00:1.00"}, + "mediaType" => "image/jpeg", + "rawCodecSpec" => {"name"=>"jpeg", "type"=>"image"}, + "displaySize" => {"uom"=>"PX", "width"=>100.0, "height"=>100.0}, + "displayAspectRatio" => + {"widthAspect" => 1.0, + "heightAspect" => 1.0, + "formatted" => "1.00:1.00"}}}, + "identifiers" => + [{"identifier" => "https://media.licdn.com/dms/image/C5603AQEK2H8SiE59Jw/profile-displayphoto-shrink_100_100/0?e=1553126400&v=beta&t=eHikoEd4N3NbHu90XtlQD8VM6oX9guudosWLpjD1XjA", - "file"=> + "file" => "urn:li:digitalmediaFile:(urn:li:digitalmediaAsset:C5603AQEK2H8SiE59Jw,urn:li:digitalmediaMediaArtifactClass:profile-displayphoto-shrink_100_100,0)", - "index"=>0, - "mediaType"=>"image/jpeg", - "identifierType"=>"EXTERNAL_URL", - "identifierExpiresInSeconds"=>1553126400}]}, - {"artifact"=> + "index" => 0, + "mediaType" => "image/jpeg", + "identifierType" => "EXTERNAL_URL", + "identifierExpiresInSeconds" => 1553126400}]}, + {"artifact" => "urn:li:digitalmediaMediaArtifact:(urn:li:digitalmediaAsset:C5603AQEK2H8SiE59Jw,urn:li:digitalmediaMediaArtifactClass:profile-displayphoto-shrink_200_200)", - "authorizationMethod"=>"PUBLIC", - "data"=> - {"com.linkedin.digitalmedia.mediaartifact.StillImage"=> - {"storageSize"=>{"width"=>200, "height"=>200}, - "storageAspectRatio"=> - {"widthAspect"=>1.0, - "heightAspect"=>1.0, - "formatted"=>"1.00:1.00"}, - "mediaType"=>"image/jpeg", - "rawCodecSpec"=>{"name"=>"jpeg", "type"=>"image"}, - "displaySize"=>{"uom"=>"PX", "width"=>200.0, "height"=>200.0}, - "displayAspectRatio"=> - {"widthAspect"=>1.0, - "heightAspect"=>1.0, - "formatted"=>"1.00:1.00"}}}, - "identifiers"=> - [{"identifier"=> + "authorizationMethod" => "PUBLIC", + "data" => + {"com.linkedin.digitalmedia.mediaartifact.StillImage" => + {"storageSize" => {"width"=>200, "height"=>200}, + "storageAspectRatio" => + {"widthAspect" => 1.0, + "heightAspect" => 1.0, + "formatted" => "1.00:1.00"}, + "mediaType" => "image/jpeg", + "rawCodecSpec" => {"name"=>"jpeg", "type"=>"image"}, + "displaySize" => {"uom"=>"PX", "width"=>200.0, "height"=>200.0}, + "displayAspectRatio" => + {"widthAspect" => 1.0, + "heightAspect" => 1.0, + "formatted" => "1.00:1.00"}}}, + "identifiers" => + [{"identifier" => "https://media.licdn.com/dms/image/C5603AQEK2H8SiE59Jw/profile-displayphoto-shrink_200_200/0?e=1553126400&v=beta&t=S7WhbAux-oy5a4nUt_p46xRCO-o25PHAExFVG2R8FDE", - "file"=> + "file" => "urn:li:digitalmediaFile:(urn:li:digitalmediaAsset:C5603AQEK2H8SiE59Jw,urn:li:digitalmediaMediaArtifactClass:profile-displayphoto-shrink_200_200,0)", - "index"=>0, - "mediaType"=>"image/jpeg", - "identifierType"=>"EXTERNAL_URL", - "identifierExpiresInSeconds"=>1553126400}]}, - {"artifact"=> + "index" => 0, + "mediaType" => "image/jpeg", + "identifierType" => "EXTERNAL_URL", + "identifierExpiresInSeconds" => 1553126400}]}, + {"artifact" => "urn:li:digitalmediaMediaArtifact:(urn:li:digitalmediaAsset:C5603AQEK2H8SiE59Jw,urn:li:digitalmediaMediaArtifactClass:profile-displayphoto-shrink_400_400)", - "authorizationMethod"=>"PUBLIC", - "data"=> - {"com.linkedin.digitalmedia.mediaartifact.StillImage"=> - {"storageSize"=>{"width"=>400, "height"=>400}, - "storageAspectRatio"=> - {"widthAspect"=>1.0, - "heightAspect"=>1.0, - "formatted"=>"1.00:1.00"}, - "mediaType"=>"image/jpeg", - "rawCodecSpec"=>{"name"=>"jpeg", "type"=>"image"}, - "displaySize"=>{"uom"=>"PX", "width"=>400.0, "height"=>400.0}, - "displayAspectRatio"=> - {"widthAspect"=>1.0, - "heightAspect"=>1.0, - "formatted"=>"1.00:1.00"}}}, - "identifiers"=> - [{"identifier"=> + "authorizationMethod" => "PUBLIC", + "data" => + {"com.linkedin.digitalmedia.mediaartifact.StillImage" => + {"storageSize" => {"width"=>400, "height"=>400}, + "storageAspectRatio" => + {"widthAspect" => 1.0, + "heightAspect" => 1.0, + "formatted" => "1.00:1.00"}, + "mediaType" => "image/jpeg", + "rawCodecSpec" => {"name"=>"jpeg", "type"=>"image"}, + "displaySize" => {"uom"=>"PX", "width"=>400.0, "height"=>400.0}, + "displayAspectRatio" => + {"widthAspect" => 1.0, + "heightAspect" => 1.0, + "formatted" => "1.00:1.00"}}}, + "identifiers" => + [{"identifier" => "https://media.licdn.com/dms/image/C5603AQEK2H8SiE59Jw/profile-displayphoto-shrink_400_400/0?e=1553126400&v=beta&t=o7XXBfFBhd2Y_Tufd1Y4EjndAxrxSDg6MUmpEdMByS0", - "file"=> + "file" => "urn:li:digitalmediaFile:(urn:li:digitalmediaAsset:C5603AQEK2H8SiE59Jw,urn:li:digitalmediaMediaArtifactClass:profile-displayphoto-shrink_400_400,0)", - "index"=>0, - "mediaType"=>"image/jpeg", - "identifierType"=>"EXTERNAL_URL", - "identifierExpiresInSeconds"=>1553126400}]}, - {"artifact"=> + "index" => 0, + "mediaType" => "image/jpeg", + "identifierType" => "EXTERNAL_URL", + "identifierExpiresInSeconds" => 1553126400}]}, + {"artifact" => "urn:li:digitalmediaMediaArtifact:(urn:li:digitalmediaAsset:C5603AQEK2H8SiE59Jw,urn:li:digitalmediaMediaArtifactClass:profile-displayphoto-shrink_800_800)", - "authorizationMethod"=>"PUBLIC", - "data"=> - {"com.linkedin.digitalmedia.mediaartifact.StillImage"=> - {"storageSize"=>{"width"=>800, "height"=>800}, - "storageAspectRatio"=> - {"widthAspect"=>1.0, - "heightAspect"=>1.0, - "formatted"=>"1.00:1.00"}, - "mediaType"=>"image/jpeg", - "rawCodecSpec"=>{"name"=>"jpeg", "type"=>"image"}, - "displaySize"=>{"uom"=>"PX", "width"=>800.0, "height"=>800.0}, - "displayAspectRatio"=> - {"widthAspect"=>1.0, - "heightAspect"=>1.0, - "formatted"=>"1.00:1.00"}}}, - "identifiers"=> - [{"identifier"=> + "authorizationMethod" => "PUBLIC", + "data" => + {"com.linkedin.digitalmedia.mediaartifact.StillImage" => + {"storageSize" => {"width"=>800, "height"=>800}, + "storageAspectRatio" => + {"widthAspect" => 1.0, + "heightAspect" => 1.0, + "formatted" => "1.00:1.00"}, + "mediaType" => "image/jpeg", + "rawCodecSpec" => {"name"=>"jpeg", "type"=>"image"}, + "displaySize" => {"uom"=>"PX", "width"=>800.0, "height"=>800.0}, + "displayAspectRatio" => + {"widthAspect" => 1.0, + "heightAspect" => 1.0, + "formatted" => "1.00:1.00"}}}, + "identifiers" => + [{"identifier" => "https://media.licdn.com/dms/image/C5603AQEK2H8SiE59Jw/profile-displayphoto-shrink_800_800/0?e=1553126400&v=beta&t=9Zg8_GZwAKl_Za2CF5IgC-gD2XvHjupCm_8wqdQjvVk", - "file"=> + "file" => "urn:li:digitalmediaFile:(urn:li:digitalmediaAsset:C5603AQEK2H8SiE59Jw,urn:li:digitalmediaMediaArtifactClass:profile-displayphoto-shrink_800_800,0)", - "index"=>0, - "mediaType"=>"image/jpeg", - "identifierType"=>"EXTERNAL_URL", - "identifierExpiresInSeconds"=>1553126400}]}], - "paging"=>{"count"=>10, "start"=>0, "links"=>[]}}}, - "id"=>"50k-SSSS99"}}} + "index" => 0, + "mediaType" => "image/jpeg", + "identifierType" => "EXTERNAL_URL", + "identifierExpiresInSeconds" => 1553126400}]}], + "paging" => {"count"=>10, "start"=>0, "links"=>[]}}}, + "id" => "50k-SSSS99"}}} end def stub_linkedin_image_request stub_request(:get, "https://media.licdn.com/dms/image/C5603AQEK2H8SiE59Jw/profile-displayphoto-shrink_800_800/0?e=1553126400&t=9Zg8_GZwAKl_Za2CF5IgC-gD2XvHjupCm_8wqdQjvVk&v=beta") .with(headers: { - 'Accept'=>'*/*', - 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', - 'User-Agent'=>'Ruby' + 'Accept' => '*/*', + 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent' => 'Ruby' }) .to_return(status: 200, body: png_image, headers: {'Content-Type'=>'image/png'}) end @@ -263,9 +263,9 @@ def stub_linkedin_image_request def stub_google_image_request stub_request(:get, "https://lh3.googleusercontent.com/-BILLeKNfUNs/AAAAAAAAAAI/AAAAAAAAAAA/bk9ax13dM2E/photo.jpg") .with(headers: { - 'Accept'=>'*/*', - 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', - 'User-Agent'=>'Ruby' + 'Accept' => '*/*', + 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent' => 'Ruby' }) .to_return(status: 200, body: png_image, headers: {'Content-Type'=>'image/png'}) end diff --git a/spec/support/webmock.rb b/spec/support/webmock.rb index 0fab05681d..1aa3687aba 100644 --- a/spec/support/webmock.rb +++ b/spec/support/webmock.rb @@ -1,5 +1,5 @@ require 'webmock' -include WebMock::API +include WebMock::API # rubocop:disable Style/MixinUsage WebMock.enable! require 'webmock/rspec' diff --git a/spec/utils/context_runner_spec.rb b/spec/utils/context_runner_spec.rb index 41e369682c..43528519ef 100644 --- a/spec/utils/context_runner_spec.rb +++ b/spec/utils/context_runner_spec.rb @@ -5,7 +5,7 @@ describe ContextRunner do - module EnterMW # :nodoc: + module EnterMW def enter(ctx) enters = ctx[:enters] || [] enters << name @@ -14,7 +14,7 @@ def enter(ctx) end end - module LeaveMW # :nodoc: + module LeaveMW def leave(ctx) leaves = ctx[:leaves] || [] leaves << name @@ -23,7 +23,7 @@ def leave(ctx) end end - module ErrorRaiseMW # :nodoc: + module ErrorRaiseMW def error(ctx) errors = ctx[:errors] || [] errors << name @@ -32,7 +32,7 @@ def error(ctx) end end - module ErrorResolveMW # :nodoc: + module ErrorResolveMW def error(ctx) errors = ctx[:errors] || [] errors << name @@ -42,19 +42,19 @@ def error(ctx) end end - module EnterRaiseMW # :nodoc: + module EnterRaiseMW def enter(ctx) raise StandardError.new("middleware enter failed") end end - module LeaveRaiseMW # :nodoc + module LeaveRaiseMW def leave(ctx) raise StandardError.new("middleware leave failed") end end - class TestMiddlewareEL # :nodoc: + class TestMiddlewareEL include EnterMW include LeaveMW @@ -64,7 +64,7 @@ def initialize(name) end end - class TestMiddlewareE # :nodoc: + class TestMiddlewareE include EnterMW attr_reader :name @@ -73,7 +73,7 @@ def initialize(name) end end - class TestMiddlewareL # :nodoc: + class TestMiddlewareL include LeaveMW attr_reader :name diff --git a/spec/utils/entity_utils_spec.rb b/spec/utils/entity_utils_spec.rb index 0de0124251..e35322c557 100644 --- a/spec/utils/entity_utils_spec.rb +++ b/spec/utils/entity_utils_spec.rb @@ -256,7 +256,7 @@ it "#define_builder :callable validator" do entity = EntityUtils.define_builder([:say_so, :callable]) - expect{entity.call({say_so: -> () { "Yes, that's the way it is." }})} + expect{entity.call({say_so: -> { "Yes, that's the way it is." }})} .to_not raise_error expect{entity.call({say_so: nil})} diff --git a/spec/utils/marketplace_router_spec.rb b/spec/utils/marketplace_router_spec.rb index b113372d3f..e2249b2e22 100644 --- a/spec/utils/marketplace_router_spec.rb +++ b/spec/utils/marketplace_router_spec.rb @@ -23,11 +23,11 @@ def expect_target(reason:, request: {}, community: {}, paths: {}, other: {}, con deleted: false, closed: false, domain: "www.marketplace.com", - ident: "marketplace", + ident: "marketplace" } default_paths = { community_not_found: {route_name: :not_found}, - new_community: {route_name: :new_community}, + new_community: {route_name: :new_community} } default_configs = { app_domain: "sharetribe.com" @@ -52,7 +52,7 @@ def expect_target(reason:, request: {}, community: {}, paths: {}, other: {}, con community: { use_domain: true, deleted: false, - domain: "www.marketplace.com", + domain: "www.marketplace.com" }).to eq(reason: :use_domain, url: "https://www.marketplace.com/listings", status: :moved_permanently) end @@ -60,12 +60,12 @@ def expect_target(reason:, request: {}, community: {}, paths: {}, other: {}, con expect_target( reason: :use_domain, request: { - port_string: ":3333", + port_string: ":3333" }, community: { domain: "www.marketplace.com", deleted: false, - use_domain: true, + use_domain: true }).to eq(reason: :use_domain, url: "https://www.marketplace.com:3333/listings", status: :moved_permanently) end @@ -75,7 +75,7 @@ def expect_target(reason:, request: {}, community: {}, paths: {}, other: {}, con community: { domain: "www.marketplace.com", deleted: true, - use_domain: true, + use_domain: true }).to eq(reason: :deleted, route_name: :not_found, status: :moved_permanently) end @@ -85,7 +85,7 @@ def expect_target(reason:, request: {}, community: {}, paths: {}, other: {}, con community: { domain: "www.marketplace.com", closed: true, - use_domain: true, + use_domain: true }).to eq(reason: :closed, route_name: :not_found, status: :moved_permanently) end @@ -93,13 +93,13 @@ def expect_target(reason:, request: {}, community: {}, paths: {}, other: {}, con expect_target( reason: :deleted, community: { - deleted: true, + deleted: true }, request: { host: "www.marketplace.com" }, paths: { - community_not_found: {url: "https://redirect.site.com"}, + community_not_found: {url: "https://redirect.site.com"} }).to eq(reason: :deleted, url: "https://redirect.site.com?utm_source=www.marketplace.com&utm_medium=redirect&utm_campaign=dl-auto-redirect", status: :moved_permanently) @@ -109,13 +109,13 @@ def expect_target(reason:, request: {}, community: {}, paths: {}, other: {}, con expect_target( reason: :closed, community: { - closed: true, + closed: true }, request: { host: "www.marketplace.com" }, paths: { - community_not_found: {url: "https://redirect.site.com"}, + community_not_found: {url: "https://redirect.site.com"} }).to eq(reason: :closed, url: "https://redirect.site.com?utm_source=www.marketplace.com&utm_medium=redirect&utm_campaign=qc-auto-redirect", status: :moved_permanently) @@ -143,7 +143,7 @@ def expect_target(reason:, request: {}, community: {}, paths: {}, other: {}, con reason: :no_marketplaces, community: nil, other: { - no_communities: true, + no_communities: true }).to eq(reason: :no_marketplaces, route_name: :new_community, status: :found) end @@ -151,11 +151,11 @@ def expect_target(reason:, request: {}, community: {}, paths: {}, other: {}, con expect_target( reason: :www_ident, request: { - host: "www.marketplace.sharetribe.com", + host: "www.marketplace.sharetribe.com" }, community: { ident: "marketplace", - domain: nil, + domain: nil }, configs: { app_domain: "sharetribe.com" @@ -167,7 +167,7 @@ def expect_target(reason:, request: {}, community: {}, paths: {}, other: {}, con expect_target( reason: :use_domain, request: { - host: "www.marketplace.sharetribe.com", + host: "www.marketplace.sharetribe.com" }, community: { ident: "marketplace", @@ -181,7 +181,7 @@ def expect_target(reason:, request: {}, community: {}, paths: {}, other: {}, con expect_target( reason: :use_ident, request: { - host: "www.marketplace.com", + host: "www.marketplace.com" }, community: { ident: "marketplace", @@ -201,11 +201,11 @@ def expect_reason(opts = {}) deleted: false, closed: false, domain: "www.marketplace.com", - ident: "marketplace", + ident: "marketplace" }, host: "marketplace.sharetribe.com", no_communities: false, - app_domain: "sharetribe.com", + app_domain: "sharetribe.com" } reason = MarketplaceRouter.redirect_reason(defaults.deep_merge(opts)) @@ -221,7 +221,7 @@ def expect_reason(opts = {}) expect_reason( community: { deleted: false, - use_domain: false, + use_domain: false }).to eq(nil) end @@ -230,7 +230,7 @@ def expect_reason(opts = {}) community: { use_domain: true, deleted: false, - domain: "www.marketplace.com", + domain: "www.marketplace.com" }).to eq(:use_domain) end @@ -239,7 +239,7 @@ def expect_reason(opts = {}) community: { deleted: false, domain: "www.marketplace.com", - use_domain: false, + use_domain: false }).to eq(nil) end @@ -248,7 +248,7 @@ def expect_reason(opts = {}) community: { domain: "www.marketplace.com", deleted: true, - use_domain: true, + use_domain: true }).to eq(:deleted) end @@ -257,7 +257,7 @@ def expect_reason(opts = {}) community: { domain: "www.marketplace.com", closed: true, - use_domain: true, + use_domain: true }).to eq(:closed) end @@ -274,7 +274,7 @@ def expect_reason(opts = {}) host: "www.marketplace.sharetribe.com", community: { ident: "marketplace", - domain: nil, + domain: nil }, app_domain: "sharetribe.com").to eq(:www_ident) end diff --git a/spec/utils/service_client/middleware/jwt_authenticator_spec.rb b/spec/utils/service_client/middleware/jwt_authenticator_spec.rb index 12c4b67ca4..59a08e7926 100644 --- a/spec/utils/service_client/middleware/jwt_authenticator_spec.rb +++ b/spec/utils/service_client/middleware/jwt_authenticator_spec.rb @@ -43,7 +43,7 @@ def token_data(token) ctx = authenticator.enter({req: {headers: {}}, opts: {auth_context: auth_context}}) expect(token_data(req_token(ctx))).to eq({"marketplaceId" => m_id.to_s, - "actorId" => a_id.to_s}) + "actorId" => a_id.to_s}) end it "fails with a missing auth context" do @@ -68,7 +68,7 @@ def token_data(token) m_id = UUIDUtils.create a_id = UUIDUtils.create - default_auth_context = ->() { + default_auth_context = -> { { marketplace_id: m_id, actor_id: a_id @@ -81,7 +81,7 @@ def token_data(token) ctx = authenticator.enter({req: {headers: {}}, opts: {}}) expect(token_data(req_token(ctx))).to eq({"marketplaceId" => m_id.to_s, - "actorId" => a_id.to_s}) + "actorId" => a_id.to_s}) end end diff --git a/spec/utils/service_client/middleware/timing_spec.rb b/spec/utils/service_client/middleware/timing_spec.rb index f2a17fd85e..a60fd848d6 100644 --- a/spec/utils/service_client/middleware/timing_spec.rb +++ b/spec/utils/service_client/middleware/timing_spec.rb @@ -10,7 +10,7 @@ describe "#enter" do - let(:timing) { ServiceClient::Middleware::Timing.new(->() { started_at }) } + let(:timing) { ServiceClient::Middleware::Timing.new(-> { started_at }) } it "adds started_at timestamp" do ctx = timing.enter({}) @@ -20,7 +20,7 @@ describe "#error/#leave" do - let(:timing) { ServiceClient::Middleware::Timing.new(->() { end_at }) } + let(:timing) { ServiceClient::Middleware::Timing.new(-> { end_at }) } it "leave adds duration" do ctx = timing.leave({started_at: started_at}) diff --git a/spec/view_utils/listing_form_view_utils_spec.rb b/spec/view_utils/listing_form_view_utils_spec.rb index 12f83b2334..d796607457 100644 --- a/spec/view_utils/listing_form_view_utils_spec.rb +++ b/spec/view_utils/listing_form_view_utils_spec.rb @@ -63,7 +63,7 @@ def validate(params, shape_opts, unit, valid_until_enabled = false) def expect_valid(params, shape_opts, unit = nil, valid_until_enabled = false) validate_res = validate(params, shape_opts, unit, valid_until_enabled) - expect(validate_res.success).to eq(true), ->() {validate_res.data} + expect(validate_res.success).to eq(true), -> {validate_res.data} end def expect_error(params, shape_opts, errors, unit = nil, valid_until_enabled = false) @@ -110,10 +110,10 @@ def expect_error(params, shape_opts, errors, unit = nil, valid_until_enabled = f it "validates custom units" do shape_units = [{:type=>:hour, :quantity_selector=>:number}, {:type=>:custom, :name_tr_key=>"foo", :selector_tr_key=>"bar", :quantity_selector=>:number}] - req_unit = {:type=>:custom, - :name_tr_key=>"foo", - :selector_tr_key=>"bar", - :quantity_selector=>:number} + req_unit = {:type => :custom, + :name_tr_key => "foo", + :selector_tr_key => "bar", + :quantity_selector => :number} expect_valid({}, {units: shape_units}, req_unit) end end diff --git a/spec/view_utils/shape_service_spec.rb b/spec/view_utils/shape_service_spec.rb index f865b530c6..359ddacf84 100644 --- a/spec/view_utils/shape_service_spec.rb +++ b/spec/view_utils/shape_service_spec.rb @@ -1,9 +1,8 @@ -# coding: utf-8 require 'spec_helper' describe ShapeService do - let(:shape_service) {ShapeService.new([ TransactionProcess.new({:id=>1, :community_id=>1, :author_is_seller=>true, :process=>:none})])} + let(:shape_service) {ShapeService.new([TransactionProcess.new({:id=>1, :community_id=>1, :author_is_seller=>true, :process=>:none})])} def create_shape(opts = {}) defaults = { diff --git a/test/helper_modules.rb b/test/helper_modules.rb index 5ee21c13f0..1bfa79ffb1 100644 --- a/test/helper_modules.rb +++ b/test/helper_modules.rb @@ -223,7 +223,7 @@ def load_default_test_data_to_db_before_test community_id: community1.id, username: "kassi_testperson1", emails: [ - FactoryGirl.build(:email, community_id: community1.id, :address => "kassi_testperson3@example.com") ], + FactoryGirl.build(:email, community_id: community1.id, :address => "kassi_testperson3@example.com")], is_admin: 0, locale: "en", encrypted_password: "$2a$10$WQHcobA3hrTdSDh1jfiMquuSZpM3rXlcMU71bhE1lejzBa3zN7yY2", #"testi" @@ -236,7 +236,7 @@ def load_default_test_data_to_db_before_test community_id: community1.id, username: "kassi_testperson2", emails: [ - FactoryGirl.build(:email, community_id: community1.id, :address => "kassi_testperson4@example.com") ], + FactoryGirl.build(:email, community_id: community1.id, :address => "kassi_testperson4@example.com")], is_admin: false, locale: "en", encrypted_password: "$2a$10$WQHcobA3hrTdSDh1jfiMquuSZpM3rXlcMU71bhE1lejzBa3zN7yY2", #"testi"