source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
db/migrate/20240115051640_migrate_images_from_albums.rb
Ruby
mit
4,176
master
606
class MigrateImagesFromAlbums < ActiveRecord::Migration[7.1] def up Album.where.not(image: nil).find_each do |album| image_path = Rails.root.join("public", "uploads", "album", "image", album.id.to_s, album.image) image_format = File.extname(image_path).downcase.delete(".") next unless File.exis...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
db/migrate/20240115020448_create_active_storage_tables.active_storage.rb
Ruby
mit
4,176
master
2,138
# This migration comes from active_storage (originally 20170806125915) class CreateActiveStorageTables < ActiveRecord::Migration[7.0] def change # Use Active Record's configured type for primary and foreign keys primary_key_type, foreign_key_type = primary_and_foreign_key_types create_table :active_stora...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
db/migrate/20240202024630_create_solid_cache_entries.solid_cache.rb
Ruby
mit
4,176
master
384
# This migration comes from solid_cache (originally 20230724121448) class CreateSolidCacheEntries < ActiveRecord::Migration[7.0] def change create_table :solid_cache_entries do |t| t.binary :key, null: false, limit: 1024 t.binary :value, null: false, limit: 512.megabytes t.datetime :created_at, ...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
db/migrate/20241018134323_drop_solid_queue_tables.rb
Ruby
mit
4,176
master
4,309
class DropSolidQueueTables < ActiveRecord::Migration[7.2] def change drop_table :solid_queue_blocked_executions do |t| t.integer "job_id", null: false t.string "queue_name", null: false t.integer "priority", default: 0, null: false t.string "concurrency_key", null: false t.datetime "...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
db/migrate/20221115061632_change_hstore_value_to_text.rb
Ruby
mit
4,176
master
276
class ChangeHstoreValueToText < ActiveRecord::Migration[7.0] def up change_column :settings, :values, :text change_column :users, :settings, :text end def down change_column :settings, :values, :hstore change_column :users, :settings, :hstore end end
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/test_helper.rb
Ruby
mit
4,176
master
4,345
# frozen_string_literal: true require "simplecov" SimpleCov.start "rails" do # After upgrading to Rails 7.1, simplecov cannot collect coverage for files in the lib directory. # It seems that the behavior of the Rails test command has changed. I have already tried adding the lib directory to the autoload once path...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/application_system_test_case.rb
Ruby
mit
4,176
master
847
# frozen_string_literal: true require "test_helper" require "capybara/cuprite" SimpleCov.command_name "test:system" class ApplicationSystemTestCase < ActionDispatch::SystemTestCase driven_by :cuprite, screen_size: [ 1400, 900 ], options: { browser_options: { "no-sandbox": nil }, url_blacklist: [ "https://w...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/models/session_test.rb
Ruby
mit
4,176
master
1,686
require "test_helper" class SessionTest < ActiveSupport::TestCase test "should build from user credential" do session = Session.build_from_credential(email: users(:admin).email, password: "foobar") assert session.valid? end test "should build from user credential with deprecated_password_salt" do us...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/models/stream_test.rb
Ruby
mit
4,176
master
2,863
# frozen_string_literal: true require "test_helper" class StreamTest < ActiveSupport::TestCase test "should can transcode flac format" do create_tmp_file(format: "mp3") do |tmp_file_path| stream = Stream.new(songs(:flac_sample)) File.open(tmp_file_path, "w") do |file| stream.each { |data| f...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/models/current_playlist_test.rb
Ruby
mit
4,176
master
219
# frozen_string_literal: true require "test_helper" class CurrentPlaylistTest < ActiveSupport::TestCase test "should not need name" do assert CurrentPlaylist.new(name: nil, user: users(:admin)).valid? end end
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/models/favorite_playlist_test.rb
Ruby
mit
4,176
master
221
# frozen_string_literal: true require "test_helper" class FavoritePlaylistTest < ActiveSupport::TestCase test "should not need name" do assert FavoritePlaylist.new(name: nil, user: users(:admin)).valid? end end
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/models/user_test.rb
Ruby
mit
4,176
master
4,662
# frozen_string_literal: true require "test_helper" class UserTest < ActiveSupport::TestCase # From https://en.wikipedia.org/wiki/Email_address#Examples INVALID_EMAIL_ADDRESSES = [ "Abc.example.com", 'a"b(c)d,e:f;g<h>i[j\k]l@example.com', 'just"not"right@example.com', 'this is"not\allowed@example....
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/models/user_setting_test.rb
Ruby
mit
4,176
master
828
# frozen_string_literal: true require "test_helper" class UserSettingTest < ActiveSupport::TestCase test "should have AVAILABLE_SETTINGS constant" do assert_equal [ :theme ], User::AVAILABLE_SETTINGS end test "should get default value when setting value did not set" do user = users(:visitor1) asse...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/models/setting_test.rb
Ruby
mit
4,176
master
2,999
# frozen_string_literal: true require "test_helper" class SettingTest < ActiveSupport::TestCase include ActiveJob::TestHelper test "should have AVAILABLE_SETTINGS constant" do assert_equal [ :media_path, :discogs_token, :transcode_bitrate, :allow_transcode_lossless, :enable_media_listener, :enable_parallel_m...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/models/media_listener_test.rb
Ruby
mit
4,176
master
302
# frozen_string_literal: true require "test_helper" class MediaListenerTest < ActiveSupport::TestCase test "running listener" do assert_not MediaListener.running? MediaListener.start assert MediaListener.running? MediaListener.stop assert_not MediaListener.running? end end
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/models/playlists_song_test.rb
Ruby
mit
4,176
master
336
# frozen_string_literal: true require "test_helper" class PlaylistsSongTest < ActiveSupport::TestCase test "should reorder songs list" do assert_changes -> { PlaylistsSong.where(playlist_id: 1).pluck(:song_id) }, from: [ 1, 2 ], to: [ 2, 1 ] do playlists_songs(:playlist1_mp3_sample).update(position: 2) ...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/models/media_file_test.rb
Ruby
mit
4,176
master
8,055
# frozen_string_literal: true require "test_helper" class MediaFileTest < ActiveSupport::TestCase test "should get file path array from media_path" do expect_file_paths = [ fixtures_file_path("artist1_album1.flac"), fixtures_file_path("artist2_album3.ogg"), fixtures_file_path("artist1_album2.m...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/models/album_test.rb
Ruby
mit
4,176
master
3,458
# frozen_string_literal: true require "test_helper" class AlbumTest < ActiveSupport::TestCase test "should not have same name album on an artist" do artists(:artist1).albums.create(name: "best") assert_raise ActiveRecord::RecordNotUnique do artists(:artist1).albums.create(name: "best") end end ...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/models/playlist_test.rb
Ruby
mit
4,176
master
2,141
# frozen_string_literal: true require "test_helper" class PlaylistTest < ActiveSupport::TestCase test "should have name" do assert_not Playlist.new(name: nil, user: users(:admin)).valid? end test "should raise error when song already in playlist" do assert_raises(ActiveRecord::RecordNotUnique) do ...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/models/artist_test.rb
Ruby
mit
4,176
master
1,975
# frozen_string_literal: true require "test_helper" class ArtistTest < ActiveSupport::TestCase test "should have default name when name is empty" do artist = Artist.create(name: nil) assert artist.unknown? assert_equal "Unknown Artist", artist.name end test "should have default name when is variou...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/models/media_test.rb
Ruby
mit
4,176
master
5,692
# frozen_string_literal: true require "test_helper" class MediaTest < ActiveSupport::TestCase include ActionCable::TestHelper include ActiveJob::TestHelper setup do clear_media_data end test "should get syncing status" do assert_not Media.syncing? end test "should change syncing status" do ...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/models/song_test.rb
Ruby
mit
4,176
master
3,594
# frozen_string_literal: true require "test_helper" class SongTest < ActiveSupport::TestCase test "should get file format" do assert_equal "mp3", songs(:mp3_sample).format assert_equal "flac", songs(:flac_sample).format assert_equal "ogg", songs(:ogg_sample).format assert_equal "wav", songs(:wav_sam...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/models/integrations/discogs_test.rb
Ruby
mit
4,176
master
3,255
# frozen_string_literal: true require "test_helper" class Integrations::DiscogsTest < ActiveSupport::TestCase setup do @discogs_client = Integrations::Discogs.new("fake_token") @api_response = { results: [ { cover_image: "http://example.com/cover.jpg" } ] } @cover_image_binary = file_fixture("cover_imag...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/models/concerns/searchable_test.rb
Ruby
mit
4,176
master
1,986
# frozen_string_literal: true require "test_helper" class SearchableTest < ActiveSupport::TestCase test "should have search class method when declared search_by on class" do assert_respond_to Album, :search assert_respond_to Artist, :search assert_respond_to Song, :search end test "should support s...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/jobs/media_sync_job_test.rb
Ruby
mit
4,176
master
2,942
# frozen_string_literal: true require "test_helper" class MediaSyncJobTest < ActiveJob::TestCase setup do clear_media_data end test "sync added media" do file_paths = [ fixtures_file_path("artist1_album1.flac") ] mock = Minitest::Mock.new mock.expect(:call, true, [ :added, file_paths ]) M...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/jobs/media_sync_all_job_test.rb
Ruby
mit
4,176
master
5,697
# frozen_string_literal: true require "test_helper" class MediaSyncAllJobTest < ActiveJob::TestCase setup do clear_media_data MediaSyncAllJob.perform_now end test "should create all records in database when synced" do assert_equal 3, Artist.count assert_equal 4, Album.count assert_equal 9, ...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/jobs/attach_cover_image_from_discogs_job_test.rb
Ruby
mit
4,176
master
1,456
# frozen_string_literal: true require "test_helper" class AttachCoverImageFromDiscogsJobTest < ActiveJob::TestCase setup do @discogs_client = Minitest::Mock.new @discogs_client.expect( :cover_image, { io: StringIO.new(file_fixture("cover_image.jpg").read), filename: "cover.jpg",...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/helpers/application_helper_test.rb
Ruby
mit
4,176
master
872
# frozen_string_literal: true require "test_helper" class ApplicationHelperTest < ActionView::TestCase test "format duration" do assert_equal "00:09", format_duration(9) assert_equal "01:30", format_duration(90) assert_equal "15:00", format_duration(900) assert_equal "02:30:00", format_duration(9000...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/lib/black_candy/config_test.rb
Ruby
mit
4,176
master
1,905
# frozen_string_literal: true require "test_helper" class BlackCandy::ConfigTest < ActiveSupport::TestCase test "should get value from ENV" do assert_nil BlackCandy.config.media_path with_env("MEDIA_PATH" => "test_media_path") do assert_equal "test_media_path", BlackCandy.config.media_path end ...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/lib/black_candy/errors_test.rb
Ruby
mit
4,176
master
688
# frozen_string_literal: true require "test_helper" class BlackCandy::ErrorsTest < ActiveSupport::TestCase test "should get info from forbidden error" do error = BlackCandy::Forbidden.new assert_equal "Forbidden", error.type assert_not_empty error.message end test "should get info from invalid cre...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/lib/black_candy/version_test.rb
Ruby
mit
4,176
master
935
# frozen_string_literal: true require "test_helper" class BlackCandy::VersionTest < ActiveSupport::TestCase test "should get version string and link" do with_env("COMMIT_HASH" => "abcdef1234567890") do assert_equal "abcdef1234567890", BlackCandy::Version.commit_hash assert_match(/^v\d+\.\d+\.\d+$/, ...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/stream_controller_test.rb
Ruby
mit
4,176
master
793
# frozen_string_literal: true require "test_helper" class StreamControllerTest < ActionDispatch::IntegrationTest setup do @user = users(:visitor1) login(@user) end test "should get new stream" do get new_stream_url(song_id: songs(:mp3_sample).id) assert_response :success end test "should r...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/errors_controller_test.rb
Ruby
mit
4,176
master
559
# frozen_string_literal: true require "test_helper" class ErrorsControllerTest < ActionDispatch::IntegrationTest test "should get forbidden" do get forbidden_url assert_response :forbidden end test "should get not found" do get not_found_url assert_response :not_found end test "should get ...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/transcoded_stream_controller_test.rb
Ruby
mit
4,176
master
526
# frozen_string_literal: true require "test_helper" class TranscodedStreamControllerTest < ActionDispatch::IntegrationTest setup do @user = users(:visitor1) cache_directory = "#{Stream::TRANSCODE_CACHE_DIRECTORY}/#{songs(:flac_sample).id}" if Dir.exist?(cache_directory) FileUtils.remove_dir(cache...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/search_controller_test.rb
Ruby
mit
4,176
master
228
# frozen_string_literal: true require "test_helper" class SearchControllerTest < ActionDispatch::IntegrationTest test "should get index" do login get search_url(query: "test") assert_response :success end end
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/playlists_controller_test.rb
Ruby
mit
4,176
master
1,390
# frozen_string_literal: true require "test_helper" class PlaylistsControllerTest < ActionDispatch::IntegrationTest test "should get index" do login get playlists_url assert_response :success end test "should create playlist" do playlists_count = Playlist.count login post playlists_ur...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/media_syncing_controller_test.rb
Ruby
mit
4,176
master
686
# frozen_string_literal: true require "test_helper" class MediaSyncingControllerTest < ActionDispatch::IntegrationTest include ActiveJob::TestHelper test "should sync media" do login users(:admin) Media.stub(:syncing?, false) do assert_enqueued_with(job: MediaSyncAllJob) do post media_sync...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/sessions_controller_test.rb
Ruby
mit
4,176
master
1,324
# frozen_string_literal: true require "test_helper" class SessionsControllerTest < ActionDispatch::IntegrationTest setup do @user = users(:visitor1) end test "should get new session" do get new_session_url assert_response :success end test "should redirect to root when user logged in" do l...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/artists_controller_test.rb
Ruby
mit
4,176
master
920
# frozen_string_literal: true require "test_helper" class ArtistsControllerTest < ActionDispatch::IntegrationTest include ActiveJob::TestHelper test "should get index" do login get artists_url assert_response :success end test "should show artist" do login get artist_url(artists(:artist...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/application_controller_test.rb
Ruby
mit
4,176
master
1,281
# frozen_string_literal: true require "test_helper" class DummyController < ApplicationController def index render plain: "OK" end def show redirect_back_with_referer_params(fallback_location: { action: "index" }) end end class ApplicationControllerTest < ActionDispatch::IntegrationTest setup do ...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/libraries_controller_test.rb
Ruby
mit
4,176
master
221
# frozen_string_literal: true require "test_helper" class LibrariesControllerTest < ActionDispatch::IntegrationTest test "should show library" do login get library_path assert_response :success end end
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/home_controller_test.rb
Ruby
mit
4,176
master
209
# frozen_string_literal: true require "test_helper" class HomeControllerTest < ActionDispatch::IntegrationTest test "should get index" do login get root_url assert_response :success end end
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/settings_controller_test.rb
Ruby
mit
4,176
master
1,479
# frozen_string_literal: true require "test_helper" class SettingsControllerTest < ActionDispatch::IntegrationTest include ActiveJob::TestHelper test "should show setting" do login get setting_url assert_response :success end test "should update global setting" do login users(:admin) pa...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/albums_controller_test.rb
Ruby
mit
4,176
master
901
# frozen_string_literal: true require "test_helper" class AlbumsControllerTest < ActionDispatch::IntegrationTest include ActiveJob::TestHelper test "should get index" do login get albums_url assert_response :success end test "should update image for album" do album = albums(:album1) log...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/songs_controller_test.rb
Ruby
mit
4,176
master
211
# frozen_string_literal: true require "test_helper" class SongsControllerTest < ActionDispatch::IntegrationTest test "should get index" do login get songs_url assert_response :success end end
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/users_controller_test.rb
Ruby
mit
4,176
master
3,264
# frozen_string_literal: true require "test_helper" class UsersControllerTest < ActionDispatch::IntegrationTest setup do login users(:admin) end test "should get index" do get users_url assert_response :success end test "should get new user" do get new_user_url assert_response :success...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/albums/filter/years_controller_test.rb
Ruby
mit
4,176
master
241
# frozen_string_literal: true require "test_helper" class Albums::Filter::YearsControllerTest < ActionDispatch::IntegrationTest test "should get index" do login get albums_filter_years_url assert_response :success end end
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/albums/filter/genres_controller_test.rb
Ruby
mit
4,176
master
243
# frozen_string_literal: true require "test_helper" class Albums::Filter::GenresControllerTest < ActionDispatch::IntegrationTest test "should get index" do login get albums_filter_genres_url assert_response :success end end
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/favorite_playlist/songs_controller_test.rb
Ruby
mit
4,176
master
264
# frozen_string_literal: true require "test_helper" class FavoritePlaylistSongsControllerTest < ActionDispatch::IntegrationTest test "should show favorite playlist songs" do login get favorite_playlist_songs_url assert_response :success end end
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/users/settings_controller_test.rb
Ruby
mit
4,176
master
642
# frozen_string_literal: true require "test_helper" class Users::SettingsControllerTest < ActionDispatch::IntegrationTest test "should update user settings" do current_user = users(:visitor1) assert_equal "auto", current_user.theme login current_user patch user_setting_url(current_user), params: { ...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/api/v1/systems_controller_test.rb
Ruby
mit
4,176
master
857
# frozen_string_literal: true require "test_helper" class Api::V1::SystemsControllerTest < ActionDispatch::IntegrationTest test "should get system version" do get api_v1_system_url, as: :json response = @response.parsed_body["version"] assert_response :success assert_equal BlackCandy::Version::MAJO...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/api/v1/stream_controller_test.rb
Ruby
mit
4,176
master
3,430
# frozen_string_literal: true require "test_helper" class Api::V1::StreamControllerTest < ActionDispatch::IntegrationTest setup do @user = users(:visitor1) end test "should get new stream" do get new_api_v1_stream_url(song_id: songs(:mp3_sample).id), headers: api_token_header(@user) assert_response...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/api/v1/transcoded_stream_controller_test.rb
Ruby
mit
4,176
master
3,233
# frozen_string_literal: true require "test_helper" class Api::V1::TranscodedStreamControllerTest < ActionDispatch::IntegrationTest class StreamMock < Stream def initialize(song) super(song) @tmp_cache_file = Tempfile.new([ "", ".#{TRANSCODE_FORMAT}" ]) end def transcode_cache_file_path ...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/api/v1/songs_controller_test.rb
Ruby
mit
4,176
master
1,590
# frozen_string_literal: true require "test_helper" class Api::V1::SongsControllerTest < ActionDispatch::IntegrationTest test "should show song" do get api_v1_song_url(songs(:mp3_sample)), as: :json, headers: api_token_header(users(:visitor1)) response = @response.parsed_body assert_response :success ...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/api/v1/api_controller_test.rb
Ruby
mit
4,176
master
668
# frozen_string_literal: true require "test_helper" class Api::V1::ApiControllerTest < ActionDispatch::IntegrationTest setup do @user = users(:visitor1) @song = songs(:mp3_sample) end test "should not authenticate when use session" do login(@user) get api_v1_song_url(@song), as: :json asse...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/api/v1/authentications_controller_test.rb
Ruby
mit
4,176
master
2,833
# frozen_string_literal: true require "test_helper" class Api::V1::AuthenticationsControllerTest < ActionDispatch::IntegrationTest setup do @user = users(:visitor1) end test "should create authentication without session" do post api_v1_authentication_url, as: :json, params: { session: { e...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/api/v1/current_playlist/songs_controller_test.rb
Ruby
mit
4,176
master
3,559
require "test_helper" class Api::V1::CurrentPlaylist::SongsControllerTest < ActionDispatch::IntegrationTest setup do @user = users(:visitor1) @playlist = @user.current_playlist @playlist.song_ids = [ 1, 2, 3 ] end test "should show all songs" do get api_v1_current_playlist_songs_url, as: :json, ...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/api/v1/current_playlist/songs/playlists_controller_test.rb
Ruby
mit
4,176
master
1,203
require "test_helper" class Api::V1::CurrentPlaylist::Songs::PlaylistsControllerTest < ActionDispatch::IntegrationTest setup do @user = users(:admin) @current_playlist = @user.current_playlist end test "should replace all songs with playlist songs" do playlist = @user.playlists.create(name: "test", ...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/api/v1/current_playlist/songs/albums_controller_test.rb
Ruby
mit
4,176
master
1,021
require "test_helper" class Api::V1::CurrentPlaylist::Songs::AlbumControllerTest < ActionDispatch::IntegrationTest setup do @user = users(:visitor1) @playlist = @user.current_playlist end test "should replace all songs with album songs" do put api_v1_current_playlist_album_url(albums(:album1)), as: ...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/api/v1/favorite_playlist/songs_controller_test.rb
Ruby
mit
4,176
master
1,576
require "test_helper" class Api::V1::FavoritePlaylist::SongsControllerTest < ActionDispatch::IntegrationTest setup do @user = users(:visitor1) @playlist = @user.favorite_playlist @playlist.song_ids = [ 1, 2 ] end test "should add songs to playlist" do post api_v1_favorite_playlist_songs_url, par...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/search/songs_controller_test.rb
Ruby
mit
4,176
master
241
# frozen_string_literal: true require "test_helper" class Search::SongsControllerTest < ActionDispatch::IntegrationTest test "should get index" do login get search_songs_url(query: "test") assert_response :success end end
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/search/albums_controller_test.rb
Ruby
mit
4,176
master
243
# frozen_string_literal: true require "test_helper" class Search::AlbumsControllerTest < ActionDispatch::IntegrationTest test "should get index" do login get search_albums_url(query: "test") assert_response :success end end
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/search/playlists_controller_test.rb
Ruby
mit
4,176
master
249
# frozen_string_literal: true require "test_helper" class Search::PlaylistsControllerTest < ActionDispatch::IntegrationTest test "should get index" do login get search_playlists_url(query: "test") assert_response :success end end
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/search/artists_controller_test.rb
Ruby
mit
4,176
master
245
# frozen_string_literal: true require "test_helper" class Search::ArtistsControllerTest < ActionDispatch::IntegrationTest test "should get index" do login get search_artists_url(query: "test") assert_response :success end end
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/songs/filter/genres_controller_test.rb
Ruby
mit
4,176
master
241
# frozen_string_literal: true require "test_helper" class Songs::Filter::GenresControllerTest < ActionDispatch::IntegrationTest test "should get index" do login get songs_filter_genres_url assert_response :success end end
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/songs/filter/years_controller_test.rb
Ruby
mit
4,176
master
239
# frozen_string_literal: true require "test_helper" class Songs::Filter::YearsControllerTest < ActionDispatch::IntegrationTest test "should get index" do login get songs_filter_years_url assert_response :success end end
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/current_playlist/songs_controller_test.rb
Ruby
mit
4,176
master
1,470
# frozen_string_literal: true require "test_helper" class CurrentPlaylistSongsControllerTest < ActionDispatch::IntegrationTest setup do @user = users(:visitor1) @playlist = @user.current_playlist @playlist.song_ids = [ 1, 2 ] login @user end test "should show current playlist songs" do get...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/current_playlist/songs/playlists_controller_test.rb
Ruby
mit
4,176
master
1,008
require "test_helper" class CurrentPlaylist::Songs::PlaylistsControllerTest < ActionDispatch::IntegrationTest setup do @user = users(:admin) @current_playlist = @user.current_playlist login @user end test "should replace all songs with playlist songs" do playlist = @user.playlists.create(name: ...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/current_playlist/songs/albums_controller_test.rb
Ruby
mit
4,176
master
819
require "test_helper" class CurrentPlaylist::Songs::AlbumControllerTest < ActionDispatch::IntegrationTest setup do @user = users(:visitor1) @playlist = @user.current_playlist login @user end test "should replace all songs with album songs" do put current_playlist_album_url(albums(:album1), shou...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/playlists/songs_controller_test.rb
Ruby
mit
4,176
master
1,829
# frozen_string_literal: true require "test_helper" class Playlists::SongsControllerTest < ActionDispatch::IntegrationTest setup do @playlist = playlists(:playlist1) @user = @playlist.user login @user end test "should show playlist songs" do get playlist_songs_url(@playlist) assert_respons...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/dialog/playlists_controller_test.rb
Ruby
mit
4,176
master
542
# frozen_string_literal: true require "test_helper" class Dialog::PlaylistsControllerTest < ActionDispatch::IntegrationTest test "should get index" do login get dialog_playlists_url assert_response :success end test "should get new playlist" do login get new_dialog_playlist_path asser...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/dialog/artists_controller_test.rb
Ruby
mit
4,176
master
953
# 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...
github
blackcandy-org/blackcandy
https://github.com/blackcandy-org/blackcandy
test/controllers/dialog/albums_controller_test.rb
Ruby
mit
4,176
master
933
# 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 ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
Guardfile
Ruby
mit
4,169
main
365
# frozen_string_literal: true # A sample Guardfile # More info at https://github.com/guard/guard#readme guard 'rspec', version: 2, all_after_pass: false, all_on_start: false, cli: '--color --format nested --fail-fast' do watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
rails_best_practices.gemspec
Ruby
mit
4,169
main
2,185
# frozen_string_literal: true lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'rails_best_practices/version' Gem::Specification.new do |spec| spec.name = 'rails_best_practices' spec.version = RailsBestPractices::VERSION spec.platform = Gem::Pl...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices.rb
Ruby
mit
4,169
main
471
# frozen_string_literal: true require 'code_analyzer' require 'require_all' require 'rails_best_practices/core' require 'rails_best_practices/colorize' require 'rails_best_practices/analyzer' require 'rails_best_practices/lexicals' require 'rails_best_practices/prepares' require 'rails_best_practices/reviews' require ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/cli.rb
Ruby
mit
4,169
main
624
# frozen_string_literal: true module RailsBestPractices class CLI # Run analyze with ruby code # @param [Array] argv command argments # @return [Boolean] return true, if there is no violation. # @example # RailsBestPractices::CLI.run(['-d', '-o', 'path/to/file']) def self.run(argv) op...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/analyzer.rb
Ruby
mit
4,169
main
11,936
# frozen_string_literal: true require 'fileutils' require 'json' require 'ruby-progressbar' module RailsBestPractices # RailsBestPractices Analyzer helps you to analyze your rails code, according to best practices on https://rails-bestpractices. # if it finds any violatioins to best practices, it will give you so...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/colorize.rb
Ruby
mit
4,169
main
215
# frozen_string_literal: true module RailsBestPractices class Colorize def self.red(message) "\e[31m#{message}\e[0m" end def self.green(message) "\e[32m#{message}\e[0m" end end end
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/command.rb
Ruby
mit
4,169
main
433
# frozen_string_literal: true require 'optparse' options = RailsBestPractices::OptionParser.parse! if !ARGV.empty? && !File.exist?(ARGV.first) puts "#{ARGV.first} doesn't exist" exit 1 end if options['generate'] RailsBestPractices::Analyzer.new(ARGV.first).generate else analyzer = RailsBestPractices::Analyzer...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/option_parser.rb
Ruby
mit
4,169
main
5,929
# frozen_string_literal: true require 'optparse' module RailsBestPractices class OptionParser # Usage: rails_best_practices [options] path # -d, --debug debug mode # --silent silent mode # -f, --format FORMAT output format (text, htm...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/prepares.rb
Ruby
mit
4,169
main
1,306
# frozen_string_literal: true require_rel 'prepares' module RailsBestPractices module Prepares class << self def klasses models + mailers + controllers end def models @models ||= Core::Models.new end def model_associations @model_associations ||= Core::Mod...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/inline_disables/comment_ripper.rb
Ruby
mit
4,169
main
371
# frozen_string_literal: true module RailsBestPractices module InlineDisables class CommentRipper < Ripper::SexpBuilder attr_reader :comments def initialize(*arg) super @comments = [] end def on_comment(*arg) # [sexp_type, statement, [lineno, column]] = super ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/inline_disables/inline_disable.rb
Ruby
mit
4,169
main
1,545
# frozen_string_literal: true module RailsBestPractices module InlineDisables class InlineDisable < Core::Check interesting_files ALL_FILES url '#' def initialize(*args) super @disabled_errors = [] end def check(filename, content) comments = CommentRipper.n...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/move_code_into_controller_review.rb
Ruby
mit
4,169
main
1,724
# frozen_string_literal: true module RailsBestPractices module Reviews # Review a view file to make sure there is no finder, finder should be moved to controller. # # See the best practice details here https://rails-bestpractices.com/posts/2010/07/24/move-code-into-controller/ # # Implementation:...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/use_scope_access_review.rb
Ruby
mit
4,169
main
2,382
# frozen_string_literal: true module RailsBestPractices module Reviews # Review a controller to make sure to use scope access instead of manually checking current_user and redirect. # # See the best practice details here https://rails-bestpractices.com/posts/2010/07/20/use-scope-access/ # # Imple...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/keep_finders_on_their_own_model_review.rb
Ruby
mit
4,169
main
1,964
# frozen_string_literal: true module RailsBestPractices module Reviews # Review model files to make sure finders are on their own model. # # See the best practice details here https://rails-bestpractices.com/posts/2010/07/23/keep-finders-on-their-own-model/ # # Implementation: # # Review ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/use_model_association_review.rb
Ruby
mit
4,169
main
2,768
# frozen_string_literal: true module RailsBestPractices module Reviews # review a controller file to make sure to use model association instead of foreign key id assignment. # # See the best practice details here https://rails-bestpractices.com/posts/2010/07/19/use-model-association/ # # Implemen...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/not_rescue_exception_review.rb
Ruby
mit
4,169
main
1,028
# frozen_string_literal: true module RailsBestPractices module Reviews # Review all code to make sure we don't rescue Exception # This is a common mistake by Java or C# devs in ruby. # # See the best practice details here https://rails-bestpractices.com/posts/2012/11/01/don-t-rescue-exception-rescue-...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/remove_unused_methods_in_models_review.rb
Ruby
mit
4,169
main
3,823
# frozen_string_literal: true module RailsBestPractices module Reviews # Find out unused methods in models. # # Implemenation: # # Review process: # remember all method calls, # at end, check if all defined methods are called, # if not, non called methods are unused. class R...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/overuse_route_customizations_review.rb
Ruby
mit
4,169
main
2,343
# frozen_string_literal: true module RailsBestPractices module Reviews # Review config/routes.rb file to make sure there are no overuse route customizations. # # See the best practice details here https://rails-bestpractices.com/posts/2010/07/22/overuse-route-customizations/ # # Implementation: ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/law_of_demeter_review.rb
Ruby
mit
4,169
main
2,826
# frozen_string_literal: true module RailsBestPractices module Reviews # Review to make sure not to avoid the law of demeter. # # See the best practice details here https://rails-bestpractices.com/posts/2010/07/24/the-law-of-demeter/ # # Implementation: # # Review process: # check a...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/use_observer_review.rb
Ruby
mit
4,169
main
3,007
# frozen_string_literal: true module RailsBestPractices module Reviews # Make sure to use observer (sorry we only check the mailer deliver now). # # See the best practice details here https://rails-bestpractices.com/posts/2010/07/24/use-observer/ # # TODO: we need a better solution, any suggestio...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/remove_unused_methods_in_helpers_review.rb
Ruby
mit
4,169
main
1,247
# frozen_string_literal: true module RailsBestPractices module Reviews # Find out unused methods in helpers. # # Implementation: # # Review process: # remember all method calls in helpers. # if they are not called in views, helpers, or controllers # then they are unused methods ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/move_code_into_helper_review.rb
Ruby
mit
4,169
main
2,098
# frozen_string_literal: true module RailsBestPractices module Reviews # Review a view file to make sure there is no complex options_for_select message call. # # See the best practice details here https://rails-bestpractices.com/posts/2010/07/24/move-code-into-helper/ # # TODO: we need a better s...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/move_model_logic_into_model_review.rb
Ruby
mit
4,169
main
1,719
# frozen_string_literal: true module RailsBestPractices module Reviews # Review a controller file to make sure that complex model logic should not exist in controller, should be moved into a model. # # See the best practice details here https://rails-bestpractices.com/posts/2010/07/21/move-model-logic-in...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/remove_empty_helpers_review.rb
Ruby
mit
4,169
main
1,082
# frozen_string_literal: true module RailsBestPractices module Reviews # Review a helper file to make sure it is not an empty moduel. # # See the best practice details here https://rails-bestpractices.com/posts/2011/04/09/remove-empty-helpers/ # # Implementation: # # Review process: #...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/move_finder_to_named_scope_review.rb
Ruby
mit
4,169
main
1,685
# frozen_string_literal: true module RailsBestPractices module Reviews # Review a controller file to make sure there are no complex finder. # # See the best practice details here https://rails-bestpractices.com/posts/2010/07/14/move-finder-to-named_scope/ # # Implementation: # # Review pr...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/use_parentheses_in_method_def_review.rb
Ruby
mit
4,169
main
989
# frozen_string_literal: true module RailsBestPractices module Reviews # Check if method definition has parentheses around parameters. # # Review process: # check def node in all files, # if params node with values, but not wrapped by paren node, # then it should use parentheses around ...
github
flyerhzm/rails_best_practices
https://github.com/flyerhzm/rails_best_practices
lib/rails_best_practices/reviews/review.rb
Ruby
mit
4,169
main
1,861
# frozen_string_literal: true module RailsBestPractices module Reviews # A Review class that takes charge of reviewing one rails best practice. class Review < Core::Check # default url. url '#' # remember use count for the variable in the call or assign node. # # find the varia...