Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #279, unify all dialog views under dialog route path
- Loading branch information
Showing
22 changed files
with
130 additions
and
115 deletions.
There are no files selected for viewing
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
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
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,9 @@ | ||
# frozen_string_literal: true | ||
|
||
class Dialog::AlbumsController < DialogController | ||
before_action :require_admin | ||
|
||
def edit | ||
@album = Album.find(params[:id]) | ||
end | ||
end |
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,9 @@ | ||
# frozen_string_literal: true | ||
|
||
class Dialog::ArtistsController < DialogController | ||
before_action :require_admin | ||
|
||
def edit | ||
@artist = Artist.find(params[:id]) | ||
end | ||
end |
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,9 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
class Dialog::PlaylistsController < ApplicationController | ||
layout proc { "dialog" unless turbo_native? } | ||
|
||
class Dialog::PlaylistsController < DialogController | ||
def index | ||
@pagy, @playlists = pagy(Current.user.all_playlists.order(created_at: :desc)) | ||
end | ||
|
||
def new | ||
@playlist = Playlist.new | ||
end | ||
|
||
def edit | ||
@playlist = Current.user.playlists.find(params[:id]) | ||
end | ||
end |
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,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class DialogController < ApplicationController | ||
layout proc { "dialog" unless turbo_native? } | ||
end |
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
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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
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
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
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
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,34 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class Dialog::AlbumsControllerTest < ActionDispatch::IntegrationTest | ||
test "should edit album" do | ||
login users(:admin) | ||
get edit_dialog_album_url(albums(:album1)) | ||
|
||
assert_response :success | ||
end | ||
|
||
test "should only admin can edit album" do | ||
login | ||
|
||
get edit_dialog_album_url(albums(:album1)) | ||
assert_response :forbidden | ||
|
||
patch album_url(albums(:album1)), params: {album: {image: fixture_file_upload("cover_image.jpg", "image/jpeg")}} | ||
assert_response :forbidden | ||
end | ||
|
||
test "should not edit album when is on demo mode" do | ||
with_env("DEMO_MODE" => "true") do | ||
login users(:admin) | ||
|
||
get edit_dialog_album_url(albums(:album1)) | ||
assert_response :forbidden | ||
|
||
patch album_url(albums(:album1)), params: {album: {image: fixture_file_upload("cover_image.jpg", "image/jpeg")}} | ||
assert_response :forbidden | ||
end | ||
end | ||
end |
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,34 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class Dialog::ArtistsControllerTest < ActionDispatch::IntegrationTest | ||
test "should edit album" do | ||
login users(:admin) | ||
get edit_dialog_artist_url(artists(:artist1)) | ||
|
||
assert_response :success | ||
end | ||
|
||
test "should only admin can edit artist" do | ||
login | ||
|
||
get edit_dialog_artist_url(artists(:artist1)) | ||
assert_response :forbidden | ||
|
||
patch artist_url(artists(:artist1)), params: {artist: {image: fixture_file_upload("cover_image.jpg", "image/jpeg")}} | ||
assert_response :forbidden | ||
end | ||
|
||
test "should not edit artist when is on demo mode" do | ||
with_env("DEMO_MODE" => "true") do | ||
login users(:admin) | ||
|
||
get edit_dialog_artist_url(artists(:artist1)) | ||
assert_response :forbidden | ||
|
||
patch artist_url(artists(:artist1)), params: {artist: {image: fixture_file_upload("cover_image.jpg", "image/jpeg")}} | ||
assert_response :forbidden | ||
end | ||
end | ||
end |
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
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