forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert
settings/applications
controller spec to system/request spe…
…cs (mastodon#32006)
- Loading branch information
1 parent
aaab6b7
commit 5dfdec6
Showing
7 changed files
with
230 additions
and
220 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
.fields-group | ||
= form.input :name, | ||
label: t('activerecord.attributes.doorkeeper/application.name'), | ||
wrapper: :with_label | ||
|
||
.fields-group | ||
= form.input :website, | ||
label: t('activerecord.attributes.doorkeeper/application.website'), | ||
wrapper: :with_label | ||
|
||
.fields-group | ||
= form.input :redirect_uri, | ||
label: t('activerecord.attributes.doorkeeper/application.redirect_uri'), hint: t('doorkeeper.applications.help.redirect_uri'), | ||
required: true, | ||
wrapper: :with_block_label | ||
|
||
%p.hint= t('doorkeeper.applications.help.native_redirect_uri', native_redirect_uri: content_tag(:code, Doorkeeper.configuration.native_redirect_uri)).html_safe | ||
|
||
.field-group | ||
.input.with_block_label | ||
%label= t('activerecord.attributes.doorkeeper/application.scopes') | ||
%span.hint= t('simple_form.hints.defaults.scopes') | ||
|
||
- Doorkeeper.configuration.scopes.group_by { |s| s.split(':').first }.each_value do |value| | ||
= form.input :scopes, | ||
as: :check_boxes, | ||
collection_wrapper_tag: 'ul', | ||
collection: value.sort, | ||
hint: false, | ||
include_blank: false, | ||
item_wrapper_tag: 'li', | ||
label_method: ->(scope) { safe_join([content_tag(:samp, scope, class: class_for_scope(scope)), content_tag(:span, t("doorkeeper.scopes.#{scope}"), class: 'hint')]) }, | ||
label: false, | ||
required: false, | ||
selected: form.object.scopes.all, | ||
wrapper: :with_block_label |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
- content_for :page_title do | ||
= t('doorkeeper.applications.new.title') | ||
|
||
= simple_form_for @application, url: settings_applications_path do |f| | ||
= render 'fields', f: f | ||
= simple_form_for @application, url: settings_applications_path do |form| | ||
= render form | ||
|
||
.actions | ||
= f.button :button, t('doorkeeper.applications.buttons.submit'), type: :submit | ||
= form.button :button, t('doorkeeper.applications.buttons.submit'), type: :submit |
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
178 changes: 0 additions & 178 deletions
178
spec/controllers/settings/applications_controller_spec.rb
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe 'Settings / Exports' do | ||
let(:user) { Fabricate :user } | ||
|
||
before { sign_in user } | ||
|
||
describe 'GET /settings/application/:id' do | ||
context 'when user does not own application' do | ||
let(:application) { Fabricate :application } | ||
|
||
it 'returns http missing' do | ||
get settings_application_path(application) | ||
|
||
expect(response) | ||
.to have_http_status(404) | ||
end | ||
end | ||
end | ||
|
||
describe 'POST /settings/applications' do | ||
subject { post '/settings/applications', params: params } | ||
|
||
let(:params) do | ||
{ | ||
doorkeeper_application: { | ||
name: 'My New App', | ||
redirect_uri: 'urn:ietf:wg:oauth:2.0:oob', | ||
website: 'http://google.com', | ||
scopes: 'read write follow', | ||
}, | ||
} | ||
end | ||
|
||
it 'supports passing scope values as string' do | ||
expect { subject } | ||
.to change(Doorkeeper::Application, :count).by(1) | ||
expect(response) | ||
.to redirect_to(settings_applications_path) | ||
end | ||
end | ||
end |
Oops, something went wrong.