Use flash info

pull/6813/head
Oliver Günther 6 years ago
parent a62fdba6bd
commit 8a783d2b1c
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 4
      app/controllers/my_controller.rb
  2. 9
      spec/controllers/my_controller_spec.rb

@ -132,7 +132,7 @@ class MyController < ApplicationController
def generate_rss_key
if request.post?
token = Token::Rss.create!(user: current_user)
flash[:notice] = [
flash[:info] = [
t('my.access_token.notice_reset_token', type: 'RSS'),
"<strong>#{token.plain_value}</strong>".html_safe,
t('my.access_token.token_value_warning')
@ -149,7 +149,7 @@ class MyController < ApplicationController
def generate_api_key
if request.post?
token = Token::Api.create!(user: current_user)
flash[:notice] = [
flash[:info] = [
t('my.access_token.notice_reset_token', type: 'API'),
"<strong>#{token.plain_value}</strong>".html_safe,
t('my.access_token.token_value_warning')

@ -30,6 +30,7 @@ require 'spec_helper'
describe MyController, type: :controller do
let(:user) { FactoryBot.create(:user) }
before(:each) do
login_as(user)
end
@ -221,7 +222,7 @@ describe MyController, type: :controller do
post :generate_rss_key
expect(user.reload.rss_token).to be_present
expect(flash[:notice]).to be_present
expect(flash[:info]).to be_present
expect(flash[:error]).not_to be_present
expect(response).to redirect_to action: :access_token
@ -239,7 +240,7 @@ describe MyController, type: :controller do
expect(new_token.value).not_to eq(key.value)
expect(new_token.value).to eq(user.rss_key)
expect(flash[:notice]).to be_present
expect(flash[:info]).to be_present
expect(flash[:error]).not_to be_present
expect(response).to redirect_to action: :access_token
end
@ -255,7 +256,7 @@ describe MyController, type: :controller do
new_token = user.reload.api_token
expect(new_token).to be_present
expect(flash[:notice]).to be_present
expect(flash[:info]).to be_present
expect(flash[:error]).not_to be_present
expect(response).to redirect_to action: :access_token
@ -273,7 +274,7 @@ describe MyController, type: :controller do
new_token = user.reload.api_token
expect(new_token).not_to eq(key)
expect(new_token.value).not_to eq(key.value)
expect(flash[:notice]).to be_present
expect(flash[:info]).to be_present
expect(flash[:error]).not_to be_present
expect(response).to redirect_to action: :access_token

Loading…
Cancel
Save