Created
October 21, 2018 20:30
-
-
Save GustavoCaso/8269dafa2a1895fe10e87c49f970f9dd to your computer and use it in GitHub Desktop.
hanami controller handling exception issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
describe Web::Controllers::Repos::MarkAsAbandoned, type: :action do | |
let(:params) { Hash[] } | |
let(:action) { described_class.new } | |
let(:repos_list) { action.repos_list } | |
subject { action.call(params) } | |
describe '#call' do | |
context 'no repo_id params' do | |
it 'returns valid status code' do | |
response = subject | |
expect(response.status).to eq 400 | |
end | |
end | |
end | |
end | |
# F | |
# Failures: | |
# 1) Web::Controllers::Repos::MarkAsAbandoned#call no repo_id params returns valid status code | |
# Failure/Error: subject { action.call(params) } | |
# Web::Controllers::Repos::MissingRepoIdError: | |
# You must provide the repo_id paramater |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GIT | |
remote: git://github.com/davydovanton/dry-system-hanami.git | |
revision: ae0506d4a858921936843501462cb36f55a9c3b0 | |
specs: | |
dry-system-hanami (0.1.0) | |
GEM | |
remote: https://rubygems.org/ | |
specs: | |
addressable (2.5.2) | |
public_suffix (>= 2.0.2, < 4.0) | |
better_errors (2.4.0) | |
coderay (>= 1.0.0) | |
erubi (>= 1.0.0) | |
rack (>= 0.9.0) | |
binding_of_caller (0.8.0) | |
debug_inspector (>= 0.0.1) | |
bootsnap (1.2.1) | |
msgpack (~> 1.0) | |
byebug (10.0.1) | |
capybara (2.18.0) | |
addressable | |
mini_mime (>= 0.1.3) | |
nokogiri (>= 1.3.3) | |
rack (>= 1.0.0) | |
rack-test (>= 0.5.4) | |
xpath (>= 2.0, < 4.0) | |
codeclimate-test-reporter (1.0.8) | |
simplecov (<= 0.13) | |
coderay (1.1.2) | |
concurrent-ruby (1.0.5) | |
connection_pool (2.2.1) | |
crack (0.4.3) | |
safe_yaml (~> 1.0.0) | |
debug_inspector (0.0.3) | |
diff-lcs (1.3) | |
docile (1.1.5) | |
domain_name (0.5.20170404) | |
unf (>= 0.0.5, < 1.0.0) | |
dotenv (2.2.1) | |
dry-auto_inject (0.4.6) | |
dry-container (>= 0.3.4) | |
dry-configurable (0.7.0) | |
concurrent-ruby (~> 1.0) | |
dry-container (0.6.0) | |
concurrent-ruby (~> 1.0) | |
dry-configurable (~> 0.1, >= 0.1.3) | |
dry-core (0.4.5) | |
concurrent-ruby (~> 1.0) | |
dry-equalizer (0.2.0) | |
dry-inflector (0.1.1) | |
dry-initializer (1.4.1) | |
dry-logic (0.4.2) | |
dry-container (~> 0.2, >= 0.2.6) | |
dry-core (~> 0.2) | |
dry-equalizer (~> 0.2) | |
dry-struct (0.3.1) | |
dry-configurable (~> 0.1) | |
dry-core (~> 0.3) | |
dry-equalizer (~> 0.2) | |
dry-types (~> 0.9, >= 0.9.0) | |
ice_nine (~> 0.11) | |
dry-system (0.9.2) | |
concurrent-ruby (~> 1.0) | |
dry-auto_inject (>= 0.4.0) | |
dry-configurable (~> 0.7, >= 0.7.0) | |
dry-container (~> 0.6) | |
dry-core (>= 0.3.1) | |
dry-equalizer (~> 0.2) | |
dry-inflector (~> 0.1) | |
dry-struct (~> 0.3) | |
dry-types (0.11.1) | |
concurrent-ruby (~> 1.0) | |
dry-configurable (~> 0.1) | |
dry-container (~> 0.3) | |
dry-core (~> 0.2, >= 0.2.1) | |
dry-equalizer (~> 0.2) | |
dry-logic (~> 0.4, >= 0.4.0) | |
inflecto (~> 0.0.0, >= 0.0.2) | |
dry-validation (0.11.0) | |
concurrent-ruby (~> 1.0) | |
dry-configurable (~> 0.1, >= 0.1.3) | |
dry-core (~> 0.2, >= 0.2.1) | |
dry-equalizer (~> 0.2) | |
dry-logic (~> 0.4, >= 0.4.0) | |
dry-types (~> 0.11.0) | |
erubi (1.7.1) | |
faraday (0.12.2) | |
multipart-post (>= 1.2, < 3) | |
ffi (1.9.23) | |
foreman (0.63.0) | |
dotenv (>= 0.7) | |
thor (>= 0.13.6) | |
formatador (0.2.5) | |
guard (2.14.2) | |
formatador (>= 0.2.4) | |
listen (>= 2.7, < 4.0) | |
lumberjack (>= 1.0.12, < 2.0) | |
nenv (~> 0.1) | |
notiffany (~> 0.0) | |
pry (>= 0.9.12) | |
shellany (~> 0.0) | |
thor (>= 0.18.1) | |
guard-rack (2.2.0) | |
ffi | |
guard (~> 2.3) | |
spoon | |
hanami (1.2.0.beta2) | |
bundler | |
concurrent-ruby (~> 1.0) | |
hanami-assets (= 1.2.0.beta2) | |
hanami-cli (= 0.2.0.beta2) | |
hanami-controller (= 1.2.0.beta2) | |
hanami-helpers (= 1.2.0.beta2) | |
hanami-mailer (= 1.2.0.beta2) | |
hanami-router (= 1.2.0.beta2) | |
hanami-utils (= 1.2.0.beta2) | |
hanami-validations (= 1.2.0.beta2) | |
hanami-view (= 1.2.0.beta2) | |
hanami-assets (1.2.0.beta2) | |
hanami-helpers (= 1.2.0.beta2) | |
hanami-utils (= 1.2.0.beta2) | |
tilt (~> 2.0, >= 2.0.2) | |
hanami-cli (0.2.0.beta2) | |
concurrent-ruby (~> 1.0) | |
hanami-utils (= 1.2.0.beta2) | |
hanami-controller (1.2.0.beta2) | |
hanami-utils (= 1.2.0.beta2) | |
rack (~> 2.0) | |
hanami-helpers (1.2.0.beta2) | |
hanami-utils (= 1.2.0.beta2) | |
hanami-mailer (1.2.0.beta2) | |
hanami-utils (= 1.2.0.beta2) | |
mail (~> 2.6) | |
tilt (~> 2.0, >= 2.0.1) | |
hanami-model (1.2.0.beta2) | |
concurrent-ruby (~> 1.0) | |
dry-types (~> 0.11.0) | |
hanami-utils (= 1.2.0.beta2) | |
rom (~> 3.3, >= 3.3.3) | |
rom-repository (~> 1.4) | |
rom-sql (~> 1.3, >= 1.3.5) | |
hanami-pagination (0.2.0) | |
hanami-helpers (~> 1.1) | |
hanami-model (~> 1.0) | |
hanami-reloader (0.2.1) | |
guard-rack (~> 2.2) | |
hanami (~> 1.1) | |
hanami-router (1.2.0.beta2) | |
hanami-utils (= 1.2.0.beta2) | |
http_router (= 0.11.2) | |
rack (~> 2.0) | |
hanami-utils (1.2.0.beta2) | |
concurrent-ruby (~> 1.0) | |
transproc (~> 1.0) | |
hanami-validations (1.2.0.beta2) | |
dry-validation (~> 0.11) | |
hanami-utils (= 1.2.0.beta2) | |
hanami-view (1.2.0.beta2) | |
hanami-utils (= 1.2.0.beta2) | |
tilt (~> 2.0, >= 2.0.1) | |
hanami-webconsole (0.1.0.beta2) | |
better_errors (~> 2.4) | |
binding_of_caller (~> 0.8) | |
hashdiff (0.3.7) | |
hashie (3.5.7) | |
http (3.0.0) | |
addressable (~> 2.3) | |
http-cookie (~> 1.0) | |
http-form_data (>= 2.0.0.pre.pre2, < 3) | |
http_parser.rb (~> 0.6.0) | |
http-cookie (1.0.3) | |
domain_name (~> 0.5) | |
http-form_data (2.1.0) | |
http_parser.rb (0.6.0) | |
http_router (0.11.2) | |
rack (>= 1.0.0) | |
url_mount (~> 0.2.1) | |
ice_nine (0.11.2) | |
inflecto (0.0.2) | |
json (2.1.0) | |
jwt (1.5.6) | |
listen (3.1.5) | |
rb-fsevent (~> 0.9, >= 0.9.4) | |
rb-inotify (~> 0.9, >= 0.9.7) | |
ruby_dep (~> 1.2) | |
lumberjack (1.0.12) | |
mail (2.7.0) | |
mini_mime (>= 0.1.1) | |
method_source (0.9.0) | |
mini_mime (1.0.0) | |
mini_portile2 (2.3.0) | |
msgpack (1.2.4) | |
multi_json (1.13.1) | |
multi_xml (0.6.0) | |
multipart-post (2.0.0) | |
mustermann (1.0.2) | |
nenv (0.3.0) | |
nokogiri (1.8.2) | |
mini_portile2 (~> 2.3.0) | |
notiffany (0.1.1) | |
nenv (~> 0.1) | |
shellany (~> 0.0) | |
oauth2 (1.4.0) | |
faraday (>= 0.8, < 0.13) | |
jwt (~> 1.0) | |
multi_json (~> 1.3) | |
multi_xml (~> 0.5) | |
rack (>= 1.2, < 3) | |
omniauth (1.8.1) | |
hashie (>= 3.4.6, < 3.6.0) | |
rack (>= 1.6.2, < 3) | |
omniauth-github (1.3.0) | |
omniauth (~> 1.5) | |
omniauth-oauth2 (>= 1.4.0, < 2.0) | |
omniauth-oauth2 (1.5.0) | |
oauth2 (~> 1.1) | |
omniauth (~> 1.2) | |
pg (1.0.0) | |
pry (0.11.3) | |
coderay (~> 1.1.0) | |
method_source (~> 0.9.0) | |
pry-byebug (3.6.0) | |
byebug (~> 10.0) | |
pry (~> 0.10) | |
public_suffix (3.0.2) | |
rack (2.0.4) | |
rack-protection (2.0.1) | |
rack | |
rack-test (0.8.3) | |
rack (>= 1.0, < 3) | |
rake (12.3.1) | |
rb-fsevent (0.10.3) | |
rb-inotify (0.9.10) | |
ffi (>= 0.5.0, < 2) | |
redis (4.0.1) | |
rom (3.3.3) | |
concurrent-ruby (~> 1.0) | |
dry-core (~> 0.3) | |
dry-equalizer (~> 0.2) | |
dry-initializer (~> 1.3) | |
dry-types (~> 0.9, >= 0.9.4) | |
rom-mapper (~> 0.5, >= 0.5.1) | |
rom-mapper (0.5.1) | |
dry-core (~> 0.2, >= 0.2.3) | |
dry-equalizer (~> 0.2) | |
transproc (~> 1.0) | |
rom-repository (1.4.0) | |
dry-core (~> 0.3, >= 0.3.1) | |
dry-struct (~> 0.3) | |
rom (~> 3.3) | |
rom-mapper (~> 0.5) | |
rom-sql (1.3.5) | |
dry-core (~> 0.3) | |
dry-equalizer (~> 0.2) | |
dry-types (~> 0.11.0) | |
rom (~> 3.2, >= 3.2.2) | |
sequel (~> 4.43) | |
rspec (3.7.0) | |
rspec-core (~> 3.7.0) | |
rspec-expectations (~> 3.7.0) | |
rspec-mocks (~> 3.7.0) | |
rspec-core (3.7.1) | |
rspec-support (~> 3.7.0) | |
rspec-expectations (3.7.0) | |
diff-lcs (>= 1.2.0, < 2.0) | |
rspec-support (~> 3.7.0) | |
rspec-hanami (0.2.0) | |
hanami | |
rspec | |
rspec-mocks (3.7.0) | |
diff-lcs (>= 1.2.0, < 2.0) | |
rspec-support (~> 3.7.0) | |
rspec-support (3.7.1) | |
ruby_dep (1.5.0) | |
safe_yaml (1.0.4) | |
sass (3.5.6) | |
sass-listen (~> 4.0.0) | |
sass-listen (4.0.0) | |
rb-fsevent (~> 0.9, >= 0.9.4) | |
rb-inotify (~> 0.9, >= 0.9.7) | |
sequel (4.49.0) | |
shellany (0.0.1) | |
sidekiq (5.1.1) | |
concurrent-ruby (~> 1.0) | |
connection_pool (~> 2.2, >= 2.2.0) | |
rack-protection (>= 1.5.0) | |
redis (>= 3.3.5, < 5) | |
simplecov (0.13.0) | |
docile (~> 1.1.0) | |
json (>= 1.8, < 3) | |
simplecov-html (~> 0.10.0) | |
simplecov-html (0.10.2) | |
sinatra (2.0.1) | |
mustermann (~> 1.0) | |
rack (~> 2.0) | |
rack-protection (= 2.0.1) | |
tilt (~> 2.0) | |
slim (3.0.9) | |
temple (>= 0.7.6, < 0.9) | |
tilt (>= 1.3.3, < 2.1) | |
spoon (0.0.6) | |
ffi | |
temple (0.8.0) | |
thor (0.20.0) | |
tilt (2.0.8) | |
transproc (1.0.2) | |
unf (0.1.4) | |
unf_ext | |
unf_ext (0.0.7.5) | |
url_mount (0.2.1) | |
rack | |
webmock (3.3.0) | |
addressable (>= 2.3.6) | |
crack (>= 0.3.2) | |
hashdiff | |
xpath (3.0.0) | |
nokogiri (~> 1.8) | |
PLATFORMS | |
ruby | |
DEPENDENCIES | |
bootsnap | |
capybara | |
codeclimate-test-reporter | |
dotenv (~> 2.0) | |
dry-system | |
dry-system-hanami! | |
foreman | |
hanami (= 1.2.0.beta2) | |
hanami-model (= 1.2.0.beta2) | |
hanami-pagination | |
hanami-reloader | |
hanami-webconsole | |
http | |
omniauth | |
omniauth-github | |
pg | |
pry-byebug | |
rake | |
rspec | |
rspec-hanami | |
sass | |
sidekiq | |
sinatra | |
slim | |
webmock | |
BUNDLED WITH | |
1.16.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Web::Controllers::Repos | |
class MissingRepoIdError < StandardError | |
def initialize | |
super('You must provide the repo_id paramater') | |
end | |
end | |
class MarkAsAbandoned | |
include Web::Action | |
handle_exception Web::Controllers::Repos::MissingRepoIdError => :handle_missing_repo_id_error | |
include Import['services.repos.mark_as_abandoned'] | |
def call(params) | |
raise MissingRepoIdError unless params[:repo_id] | |
mark_as_abandoned.call(current_user, params) | |
redirect_to routes.user_path(current_user.id) | |
end | |
private | |
def handle_missing_repo_id_error(exception) | |
status 400, exception.message | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment