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
osunyorg/admin
https://github.com/osunyorg/admin
test/mailers/previews/notification_mailer_preview.rb
Ruby
mit
48
main
1,444
# Preview all emails at http://localhost:3000/rails/mailers/notification_mailer class NotificationMailerPreview < BaseMailerPreview # Preview this email at http://localhost:3000/rails/mailers/notification_mailer/import def import NotificationMailer.import(organizations_import) end # Preview this email ...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/models/hugo_test.rb
Ruby
mit
48
main
1,205
require "test_helper" # Pour tester juste ce jeu `rake test TEST=test/models/hugo_test.rb` class HugoTest < ActiveSupport::TestCase test "pages" do website = communication_websites(:website_with_github) # FIXME les permalinks ne sont pas calculés, tous les path sont faux # Home page_l10n = communicat...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/models/communication/website/git_file_test.rb
Ruby
mit
48
main
4,671
# == Schema Information # # Table name: communication_website_git_files # # id :uuid not null, primary key # about_type :string not null, indexed => [about_id] # previous_path :string # previous_sha :string # created_at :datetime not null # updated_at :datetime ...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/models/communication/website/dependency_test.rb
Ruby
mit
48
main
5,516
require "test_helper" # rails test test/models/communication/website/dependency_test.rb class Communication::Website::DependencyTest < ActiveSupport::TestCase include ActiveJob::TestHelper def test_page_dependencies # Par défaut, 2 dépendances : # - la localisation FR de la page # - la configuration C...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/models/communication/website/permalink_test.rb
Ruby
mit
48
main
9,176
require "test_helper" # rails test test/models/communication/website/permalink_test.rb class Communication::Website::PermalinkTest < ActiveSupport::TestCase def test_page_permalink # Créer une page et sa localisation FR page = website_with_github.pages.new( university_id: default_university.id, ...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/models/communication/website/connection_test.rb
Ruby
mit
48
main
12,927
# == Schema Information # # Table name: communication_website_connections # # id :uuid not null, primary key # direct_source_type :string indexed => [direct_source_id] # indirect_object_type :string not null, indexed => [indirect_object_id] # created_at ...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/models/communication/website/page_test.rb
Ruby
mit
48
main
1,543
require "test_helper" # rails test test/models/communication/website/page_test.rb class Communication::Website::PageTest < ActiveSupport::TestCase def test_create_without_slug page = Communication::Website::Page.new(new_page_params) assert page.save assert page.localizations.first.slug.present? asse...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/models/communication/website/agenda/event_test.rb
Ruby
mit
48
main
2,502
require "test_helper" class Communication::Website::Agenda::EventTest < ActiveSupport::TestCase test "valid cal file with specific dates and hours" do event = new_event( from_day: Date.tomorrow, to_day: Date.tomorrow + 1.day ) assert(event.valid?) event_l10n = event.localizations.first ...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/controllers/users/registrations_controller_test.rb
Ruby
mit
48
main
877
require "test_helper" class Users::RegistrationsControllerTest < ActionDispatch::IntegrationTest ActiveHashcash.bits = 2 def test_extranet_create host! default_extranet.host default_extranet.connect(olivia) post user_registration_path, params: { user: { email: olivia.email, first...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/controllers/extranet/account_controller_test.rb
Ruby
mit
48
main
1,067
require "test_helper" # rails test test/controllers/extranet/account_controller_test.rb class Extranet::AccountControllerTest < ActionDispatch::IntegrationTest include ExtranetSetup def test_show get account_path(lang: french) assert_response(:success) end def test_edit get edit_account_path(lang...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/controllers/extranet/organizations_controller_test.rb
Ruby
mit
48
main
402
require "test_helper" class Extranet::OrganizationsControllerTest < ActionDispatch::IntegrationTest include ExtranetSetup def test_search get search_organizations_path(term: "Organisation de test", lang: french) assert_response(:success) results = JSON.parse(response.body) assert_equal(1, results....
github
osunyorg/admin
https://github.com/osunyorg/admin
test/controllers/extranet/home_controller_test.rb
Ruby
mit
48
main
803
require "test_helper" class Extranet::HomeControllerTest < ActionDispatch::IntegrationTest # root_path has no language and goes to "redirect_to_default_language" action. # index is extranet_root_path with lang parameter. def test_root_unknown_context host! "example.com" get(root_path) assert_respons...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/controllers/extranet/pages_controller_test.rb
Ruby
mit
48
main
503
require "test_helper" class Extranet::PagesControllerTest < ActionDispatch::IntegrationTest include ExtranetSetup def test_terms get terms_path(lang: french) assert_response(:success) end def test_cookies_policy get cookies_policy_path(lang: french) assert_response(:success) end def test...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/controllers/extranet/account/personal_data_controller_test.rb
Ruby
mit
48
main
796
require "test_helper" class Extranet::Account::PersonalDataControllerTest < ActionDispatch::IntegrationTest include ExtranetSetup def test_edit get edit_account_personal_data_path(lang: french) assert_response(:success) end def test_update alumnus_person_l10n = alumnus_person.localization_for(fre...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/controllers/extranet/account/experiences_controller_test.rb
Ruby
mit
48
main
2,229
require "test_helper" class Extranet::Account::ExperiencesControllerTest < ActionDispatch::IntegrationTest include ExtranetSetup def test_new get new_account_experience_path(lang: french) assert_response(:success) end def test_create assert_difference("alumnus.experiences.count") do post ac...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/controllers/extranet/alumni/organizations_controller_test.rb
Ruby
mit
48
main
410
require "test_helper" class Extranet::Alumni::OrganizationsControllerTest < ActionDispatch::IntegrationTest include ExtranetSetup def test_index get alumni_university_organizations_path(lang: french) assert_response(:success) end def test_show get alumni_university_organization_path(university_or...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/controllers/extranet/alumni/persons_controller_test.rb
Ruby
mit
48
main
372
require "test_helper" class Extranet::Alumni::PersonsControllerTest < ActionDispatch::IntegrationTest include ExtranetSetup def test_index get alumni_university_persons_path(lang: french) assert_response(:success) end def test_show get alumni_university_person_path(university_people(:alumnus), la...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/controllers/extranet/alumni/cohorts_controller_test.rb
Ruby
mit
48
main
377
require "test_helper" class Extranet::Alumni::CohortsControllerTest < ActionDispatch::IntegrationTest include ExtranetSetup def test_index get alumni_education_cohorts_path(lang: french) assert_response(:success) end def test_show get alumni_education_cohort_path(education_cohorts(:default_cohort...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/controllers/extranet/alumni/academic_years_controller_test.rb
Ruby
mit
48
main
400
require "test_helper" class Extranet::Alumni::AcademicYearsControllerTest < ActionDispatch::IntegrationTest include ExtranetSetup def test_index get alumni_education_academic_years_path(lang: french) assert_response(:success) end def test_show get alumni_education_academic_year_path(education_aca...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/controllers/server/universities_controller_test.rb
Ruby
mit
48
main
2,179
require "test_helper" class Server::UniversitiesControllerTest < ActionDispatch::IntegrationTest include ServerSetup def test_index get server_universities_path assert_response(:success) end def test_show get server_university_path(universities(:default_university)) assert_response(:success) ...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/controllers/server/blocks_controller_test.rb
Ruby
mit
48
main
341
require "test_helper" class Server::BlocksControllerTest < ActionDispatch::IntegrationTest include ServerSetup def test_index get server_blocks_path assert_response(:success) end def test_show block = communication_blocks(:olivia_in_noesya) get(server_block_path(block.id)) assert_response...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/controllers/server/languages_controller_test.rb
Ruby
mit
48
main
1,758
require "test_helper" class Server::LanguagesControllerTest < ActionDispatch::IntegrationTest include ServerSetup def test_index get server_languages_path assert_response(:success) end def test_show get server_language_path(languages(:fr)) assert_response(:success) end def test_new g...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/controllers/server/dashboard_controller_test.rb
Ruby
mit
48
main
246
require "test_helper" class Server::DashboardControllerTest < ActionDispatch::IntegrationTest include ServerSetup def test_index VCR.use_cassette(location) do get server_root_path assert_response(:success) end end end
github
osunyorg/admin
https://github.com/osunyorg/admin
test/controllers/server/websites_controller_test.rb
Ruby
mit
48
main
376
require "test_helper" class Server::WebsitesControllerTest < ActionDispatch::IntegrationTest include ServerSetup def test_index get server_websites_path assert_response(:success) end def test_sync_theme_version post(sync_theme_version_server_website_path(communication_websites(:website_with_githu...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/services/contact_details_test.rb
Ruby
mit
48
main
4,758
require "test_helper" class ContactDetailsTest < ActiveSupport::TestCase KINDS = [ :country, :email, :facebook, :github, :instagram, :linkedin, :mastodon, :peertube, :phone, :tiktok, :twitter, :vimeo, :website, :youtube ] test "nil is nil" do KINDS.ea...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/services/git_repository_test.rb
Ruby
mit
48
main
3,439
require "test_helper" class GitRepositoryTest < ActiveSupport::TestCase include ActionMailer::TestHelper # note: this case does not send email anymore, a credential error on GH will just crash the task test "incorrect credentials for github" do website_with_github.update(access_token: 'wrong access token') ...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/services/variant_service_test.rb
Ruby
mit
48
main
8,701
require "test_helper" # rails test test/services/variant_service_test.rb class VariantServiceTest < ActiveSupport::TestCase self.file_fixture_path = File.expand_path("../fixtures/files", __dir__) include ActiveRecord::TestFixtures # L'image de test meure 1486 pixels de large et 836 pixels de haut EXPECTED_P...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/services/video/provider_test.rb
Ruby
mit
48
main
2,388
require "test_helper" class Video::ProviderTest < ActiveSupport::TestCase def test_provider_empty provider = Video::Provider.find('') assert_equal Video::Provider::Default, provider.class end def test_vimeo provider = Video::Provider.find('https://vimeo.com/248482251') assert_equal Video::Provi...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/services/importers/cleaner_test.rb
Ruby
mit
48
main
4,869
require "test_helper" class Importers::CleanerTest < ActiveSupport::TestCase # Prefix unfrozen strings with "+" # Source: https://docs.rubocop.org/rubocop-performance/cops_performance.html#performanceunfreezestring test "convert apostroph" do assert_equal 'Ouverture du CRM pendant les vacances d’Avril', ...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/services/communication/website/agenda/planner_test.rb
Ruby
mit
48
main
9,002
require "test_helper" # rails test test/services/communication/website/agenda/planner_test.rb class Communication::Website::Agenda::PlannerTest < ActiveSupport::TestCase # test_event_time_slot 2024-07-12 08:00 # recurring_time_slot_1 2025-06-01 ...
github
osunyorg/admin
https://github.com/osunyorg/admin
test/support/vcr.rb
Ruby
mit
48
main
629
require 'vcr' VCR.configure do |c| c.cassette_library_dir = 'test/cassettes' c.hook_into :webmock c.allow_http_connections_when_no_cassette = false c.filter_sensitive_data('<TEST_GITHUB_TOKEN>') { ENV['TEST_GITHUB_TOKEN'] } c.filter_sensitive_data('<TEST_GITHUB_REPOSITORY>') { ENV['TEST_GITHUB_REPOSITORY'] }...
github
osunyorg/admin
https://github.com/osunyorg/admin
lib/tasks/auto.rake
Ruby
mit
48
main
1,342
namespace :auto do desc 'Update publications from HAL for all researchers' task update_hal: :environment do # Research::Hal.update_from_api! is synchronous, we use a job for that Research::Hal::UpdateJob.perform_later end desc 'Clean and rebuild every website to enable publications in the future' ta...
github
osunyorg/admin
https://github.com/osunyorg/admin
lib/tasks/app.rake
Ruby
mit
48
main
2,699
namespace :app do desc 'Fix things' task fix: :environment do # Nothing for now end namespace :search do task build_index: :environment do Search::BuildIndexJob.perform_later end end namespace :access_token do desc "Refresh access token for Universities & Websites." task refresh:...
github
osunyorg/admin
https://github.com/osunyorg/admin
spec/rails_helper.rb
Ruby
mit
48
main
3,171
# This file is copied to spec/ when you run 'rails generate rspec:install' require 'spec_helper' ENV['RAILS_ENV'] ||= 'test' require_relative '../config/environment' # Prevent database truncation if the environment is production abort("The Rails environment is running in production mode!") if Rails.env.production? requ...
github
osunyorg/admin
https://github.com/osunyorg/admin
spec/swagger_helper.rb
Ruby
mit
48
main
5,176
# frozen_string_literal: true require 'rails_helper' RSpec.configure do |config| # Specify a root folder where Swagger JSON files are generated # NOTE: If you're using the rswag-api to serve API descriptions, you'll need # to ensure that it's configured to serve Swagger from the same folder config.openapi_roo...
github
osunyorg/admin
https://github.com/osunyorg/admin
spec/support/vcr.rb
Ruby
mit
48
main
659
require 'vcr' VCR.configure do |c| c.cassette_library_dir = 'spec/cassettes' c.hook_into :webmock c.allow_http_connections_when_no_cassette = false c.filter_sensitive_data('<TEST_GITHUB_TOKEN>') { ENV['TEST_GITHUB_TOKEN'] } c.filter_sensitive_data('<TEST_GITHUB_REPOSITORY>') { ENV['TEST_GITHUB_REPOSITORY'] }...
github
osunyorg/admin
https://github.com/osunyorg/admin
spec/requests/osuny/v1/communication/medias_spec.rb
Ruby
mit
48
main
1,951
require 'swagger_helper' RSpec.describe 'Communication::Media' do fixtures :all path '/communication/medias' do post 'Create a media' do tags 'Communication::Website::Media' security [{ api_key: [] }] let("X-Osuny-Token") { university_apps(:default_app).token } consumes 'multipart/for...
github
osunyorg/admin
https://github.com/osunyorg/admin
spec/requests/osuny/v1/communication/websites_spec.rb
Ruby
mit
48
main
1,724
require 'swagger_helper' RSpec.describe 'Communication::Website' do fixtures :all path '/communication/websites' do get 'Lists the websites' do tags 'Communication::Website' security [{ api_key: [] }] let("X-Osuny-Token") { university_apps(:default_app).token } parameter name: :page_n...
github
osunyorg/admin
https://github.com/osunyorg/admin
spec/requests/osuny/v1/communication/blocks/templates_spec.rb
Ruby
mit
48
main
2,207
require 'swagger_helper' RSpec.describe 'Communication::Block::Template' do fixtures :all # path '/communication/blocks/templates' do # get 'Lists available block templates' do # tags 'Communication::Block::Template' # security [{ api_key: [] }] # let("X-Osuny-Token") { university_apps(:defa...
github
osunyorg/admin
https://github.com/osunyorg/admin
spec/requests/osuny/v1/communication/websites/events_spec.rb
Ruby
mit
48
main
28,115
require 'swagger_helper' RSpec.describe 'Communication::Website::Agenda::Event' do fixtures :all path '/communication/websites/{website_id}/agenda/events' do get "Lists a website's events" do tags 'Communication::Website::Agenda::Event' security [{ api_key: [] }] let("X-Osuny-Token") { unive...
github
osunyorg/admin
https://github.com/osunyorg/admin
spec/requests/osuny/v1/communication/websites/posts_spec.rb
Ruby
mit
48
main
21,121
require 'swagger_helper' RSpec.describe 'Communication::Website::Post' do fixtures :all path '/communication/websites/{website_id}/posts' do get "Lists a website's posts" do tags 'Communication::Website::Post' security [{ api_key: [] }] let("X-Osuny-Token") { university_apps(:default_app).to...
github
osunyorg/admin
https://github.com/osunyorg/admin
spec/requests/osuny/v1/communication/websites/pages_spec.rb
Ruby
mit
48
main
23,674
require 'swagger_helper' RSpec.describe 'Communication::Website::Page' do fixtures :all path '/communication/websites/{website_id}/pages' do get "Lists a website's pages" do tags 'Communication::Website::Page' security [{ api_key: [] }] let("X-Osuny-Token") { university_apps(:default_app).to...
github
osunyorg/admin
https://github.com/osunyorg/admin
spec/requests/osuny/v1/communication/websites/pages/categories_spec.rb
Ruby
mit
48
main
20,249
require 'swagger_helper' RSpec.describe 'Communication::Website::Page::Category' do fixtures :all path '/communication/websites/{website_id}/pages/categories' do get "Lists a website's page categories" do tags 'Communication::Website::Page::Category' security [{ api_key: [] }] let("X-Osuny-T...
github
osunyorg/admin
https://github.com/osunyorg/admin
spec/requests/osuny/v1/communication/websites/portfolio/categories_spec.rb
Ruby
mit
48
main
20,561
require 'swagger_helper' RSpec.describe 'Communication::Website::Portfolio::Category' do fixtures :all path '/communication/websites/{website_id}/portfolio/categories' do get "Lists a website's portfolio categories" do tags 'Communication::Website::Portfolio::Category' security [{ api_key: [] }] ...
github
osunyorg/admin
https://github.com/osunyorg/admin
spec/requests/osuny/v1/communication/websites/portfolio/projects_spec.rb
Ruby
mit
48
main
21,545
require 'swagger_helper' RSpec.describe 'Communication::Website::Portfolio::Project' do fixtures :all path '/communication/websites/{website_id}/portfolio/projects' do get "Lists a website's projects" do tags 'Communication::Website::Portfolio::Project' security [{ api_key: [] }] let("X-Osun...
github
osunyorg/admin
https://github.com/osunyorg/admin
spec/requests/osuny/v1/communication/websites/posts/categories_spec.rb
Ruby
mit
48
main
20,249
require 'swagger_helper' RSpec.describe 'Communication::Website::Post::Category' do fixtures :all path '/communication/websites/{website_id}/posts/categories' do get "Lists a website's post categories" do tags 'Communication::Website::Post::Category' security [{ api_key: [] }] let("X-Osuny-T...
github
osunyorg/admin
https://github.com/osunyorg/admin
spec/requests/osuny/v1/communication/websites/agenda/categories_spec.rb
Ruby
mit
48
main
20,470
require 'swagger_helper' # bundle exec rspec spec/requests/osuny/v1/communication/websites/agenda/categories_spec.rb RSpec.describe 'Communication::Website::Agenda::Category' do fixtures :all path '/communication/websites/{website_id}/agenda/categories' do get "Lists a website's agenda categories" do ta...
github
osunyorg/admin
https://github.com/osunyorg/admin
spec/requests/osuny/v1/university/organizations_spec.rb
Ruby
mit
48
main
21,317
require 'swagger_helper' RSpec.describe 'University::Organization' do fixtures :all path '/university/organizations' do get "Lists organizations" do tags 'University::Organization' security [{ api_key: [] }] let("X-Osuny-Token") { university_apps(:default_app).token } parameter name: ...
github
osunyorg/admin
https://github.com/osunyorg/admin
spec/requests/osuny/v1/university/organizations/categories_spec.rb
Ruby
mit
48
main
17,719
require 'swagger_helper' RSpec.describe 'University::Organization::Category' do fixtures :all path '/university/organizations/categories' do get "Lists organization categories" do tags 'University::Organization::Category' security [{ api_key: [] }] let("X-Osuny-Token") { university_apps(:def...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/research.rb
Ruby
mit
48
main
503
module Research extend ActiveModel::Naming extend ActiveModel::Translation def self.table_name_prefix 'research_' end def self.parts [ [University::Person::Localization::Researcher, :admin_research_researchers_path], [Research::Laboratory, :admin_research_laboratories_path], [Resea...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/communication.rb
Ruby
mit
48
main
468
module Communication extend ActiveModel::Naming extend ActiveModel::Translation def self.table_name_prefix 'communication_' end def self.parts [ [University::Person::Localization::Author, :admin_communication_authors_path], [Communication::Website, :admin_communication_websites_path], ...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/search.rb
Ruby
mit
48
main
3,277
# == Schema Information # # Table name: search_index # # id :uuid not null, primary key # about_localization_type :string not null, indexed => [about_localization_id] # about_object_type :string not null, indexed => [about_object_id] # text ...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/education.rb
Ruby
mit
48
main
434
module Education extend ActiveModel::Naming extend ActiveModel::Translation def self.table_name_prefix 'education_' end def self.parts [ [University::Person::Localization::Teacher, :admin_education_teachers_path], [Education::School, :admin_education_schools_path], [Education::Dipl...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/administration.rb
Ruby
mit
48
main
409
module Administration extend ActiveModel::Naming extend ActiveModel::Translation def self.table_name_prefix 'administration_' end def self.parts [ [University::Person::Alumnus, :admin_administration_alumni_path], [Administration::Location, :admin_administration_locations_path], [Ad...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/university.rb
Ruby
mit
48
main
4,683
# == Schema Information # # Table name: universities # # id :uuid not null, primary key # address :string # admin_already_auto_promoted :boolean default(FALSE) # city :string # contribution_amount :float # country ...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/ability.rb
Ruby
mit
48
main
385
# frozen_string_literal: true class Ability include CanCan::Ability def self.for(user) "Ability::#{user.role.classify}".constantize.new user end def initialize(user) @user = user ||= User.new # guest user (not logged in) end protected def managed_websites_ids @managed_websites_ids ||= @us...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/import.rb
Ruby
mit
48
main
2,849
# == Schema Information # # Table name: imports # # id :uuid not null, primary key # kind :integer # number_of_lines :integer # processing_errors :jsonb # status :integer default("pending") # created_at :datetime not null # updated_at ...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/user.rb
Ruby
mit
48
main
4,320
# == Schema Information # # Table name: users # # id :uuid not null, primary key # confirmation_sent_at :datetime # confirmation_token :string uniquely indexed # confirmed_at :datetime # current_sign_in_at :datetime # ...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/language.rb
Ruby
mit
48
main
1,408
# == Schema Information # # Table name: languages # # id :uuid not null, primary key # iso_code :string # name :string # summernote_locale :string # created_at :datetime not null # updated_at :datetime not null # class Language < Appli...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/emergency_message.rb
Ruby
mit
48
main
1,915
# == Schema Information # # Table name: emergency_messages # # id :uuid not null, primary key # content_en :text # content_fr :text # delivered_at :datetime # delivered_count :integer # name :string # role :string # subject_en :string # subject_f...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/with_geolocation.rb
Ruby
mit
48
main
1,270
module WithGeolocation extend ActiveSupport::Concern included do geocoded_by :full_street_address after_save_commit :geocode_in_background_if_necessary end def full_street_address "#{address}, #{zipcode} #{city} #{country}" end def full_address_in(language) l10n = localization_for(langua...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/sluggable.rb
Ruby
mit
48
main
1,683
module Sluggable extend ActiveSupport::Concern # Filenames uses 255 bytes so should have 255 characters max. To be safe, we limit to 100. # Source: https://askubuntu.com/questions/166764/how-long-can-file-names-be/166767#166767 SLUG_MAX_LENGTH = 100 included do validates :slug, presence: true, unless: :...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/contentful.rb
Ruby
mit
48
main
1,466
module Contentful extend ActiveSupport::Concern LARGE_NUMBER_OF_BLOCKS = 5 included do has_many :blocks, as: :about, class_name: 'Communication::Block', dependent: :destroy accepts_nested_attributes_for :blocks, allow_destroy: true end def contents @c...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/with_blobs.rb
Ruby
mit
48
main
507
module WithBlobs extend ActiveSupport::Concern def active_storage_blobs explicit_active_storage_blobs.or inherited_active_storage_blobs end def explicit_active_storage_blobs blobs_with_ids explicit_blob_ids end def inherited_active_storage_blobs blobs_with_ids inherited_blob_ids end prot...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/generates_git_files.rb
Ruby
mit
48
main
631
module GeneratesGitFiles extend ActiveSupport::Concern included do after_save :identify_git_files after_touch :identify_git_files end # Generate will skip if not needed on website def identify_git_files_safely websites.each do |website| website.generate_git_file_for_object(self) web...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/bodyclassed.rb
Ruby
mit
48
main
1,251
# Needs `ancestors`` module Bodyclassed extend ActiveSupport::Concern # La page actuelle a les bodyclass classe1 et classe2 ("classe1 classe2") # Les différents ancêtres ont les classes home, bodyclass et secondclass # -> "page-classe1 page-classe2 ancestor-home ancestor-bodyclass ancestor-secondclass" def b...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/staticable.rb
Ruby
mit
48
main
3,180
module Staticable extend ActiveSupport::Concern def hugo(website) if website.nil? || !can_have_git_file? || !should_sync_to?(website) hugo_nil else hugo_with( hugo_permalink_in_website(website), hugo_path_in_website(website), hugo_file_in_website(website), hugo_s...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/with_hourly_publication.rb
Ruby
mit
48
main
2,074
# L'objet doit être un objet direct et avoir 1 attribut : # - publication_job_id:references { to_table: :good_jobs, on_delete: :nullify } module WithHourlyPublication extend ActiveSupport::Concern included do belongs_to :publication_job, class_name: 'GoodJob::Job', optional: true after_save_commit :manage...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/duplicable.rb
Ruby
mit
48
main
1,613
module Duplicable extend ActiveSupport::Concern def duplicate instance = duplicate_instance duplicate_categories_for(instance) duplicate_localizations_for(instance) instance end def duplicate_blocks(from, to) return unless from.respond_to?(:blocks) from.blocks.ordered.each do |block| ...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/as_category_localization.rb
Ruby
mit
48
main
950
module AsCategoryLocalization extend ActiveSupport::Concern include AsLocalization include AsLocalizedTree include Contentful include HasGitFiles include HeaderCallToAction include Initials include Permalinkable include Sanitizable include Shareable include WithBlobs include WithFeaturedImage ...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/as_indirect_object.rb
Ruby
mit
48
main
3,991
# Ce concern ajoute les éléments nécessaires pour les objets indirects : # - Dépendances et références (avec et via synchro) # - Connexions (en tant que cible) module AsIndirectObject extend ActiveSupport::Concern # Les blocs sont des objets indirects, mais n'ont pas de GitFiles, on n'inclut donc pas HasGitFiles i...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/as_localization.rb
Ruby
mit
48
main
2,769
module AsLocalization extend ActiveSupport::Concern include AsIndirectObject include LibreTranslatable included do belongs_to :language belongs_to :about, class_name: "#{self.module_parent.name}", touch: true # FIXME twice on nested form validates :language_id, u...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/with_university.rb
Ruby
mit
48
main
225
module WithUniversity extend ActiveSupport::Concern included do belongs_to :university validates :university, presence: true scope :in_university, -> (university) { where(university: university) } end end
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/publishable.rb
Ruby
mit
48
main
1,589
# L'objet doit avoir 2 attributs : # - published:boolean # - published_at:datetime module Publishable extend ActiveSupport::Concern PUBLICATION_STATE_PUBLISHED = 'published' PUBLICATION_STATE_PLANNED = 'planned' PUBLICATION_STATE_DRAFT = 'draft' included do scope :draft, -> { where(published: fals...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/has_git_files.rb
Ruby
mit
48
main
979
module HasGitFiles extend ActiveSupport::Concern included do include GeneratesGitFiles has_many :git_files, class_name: "Communication::Website::GitFile", as: :about end def git_path(website) git_path_content_prefix(website) + git_path_relative end def git_path_r...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/with_dependencies.rb
Ruby
mit
48
main
6,637
# Les objets ont souvent besoin de WithDependencies, mais pas toujours : # - les blocks ont des dépendances, mais ne sont pas envoyés sur Git en tant qu'objets, ils passent par leur 'about' # - les menu items passent par le menu # - les templates et les components de blocks passent par les blocks qui passent par les 'a...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/filterable.rb
Ruby
mit
48
main
1,102
# frozen_string_literal: true module Filterable extend ActiveSupport::Concern included do class_attribute :scope_names, instance_accessor: true, default: [] end class_methods do # Keep a registry of scope names def scope(name, body, &block) scope_names << name.to_s super end ...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/with_country.rb
Ruby
mit
48
main
464
module WithCountry extend ActiveSupport::Concern def country_name return if country_iso.blank? country_iso.translations[I18n.locale.to_s] || country_common_name end def country_common_name return if country_iso.blank? country_iso.common_name || country_iso.iso_short_name end private de...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/sanitizable.rb
Ruby
mit
48
main
1,930
module Sanitizable extend ActiveSupport::Concern included do before_validation :sanitize_fields def sanitize_fields attributes_to_sanitize.each do |attribute_name, attribute_type| dangerous_value = public_send attribute_name sanitized_value = Osuny::Sanitizer.sanitize(dangerous_valu...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/as_direct_object.rb
Ruby
mit
48
main
1,506
# Ce concern ajoute les éléments nécessaires pour les objets directs : # - Dépendances et références (avec et via synchro) # - Connexions (en tant que source) module AsDirectObject extend ActiveSupport::Concern include WithDependencies included do belongs_to :website, class_name: 'Communicati...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/backlinkable.rb
Ruby
mit
48
main
3,279
module Backlinkable extend ActiveSupport::Concern BACKLINKS = [ :pages, :posts, :events, :exhibitions, :projects ] def backlinks_for(website) base = {} BACKLINKS.each do |identifier| elements = elements_with_hugo(identifier, website) base[identifier] = elements if eleme...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/pathable.rb
Ruby
mit
48
main
626
module Pathable extend ActiveSupport::Concern included do before_validation :make_path after_save :update_children_paths, if: :saved_change_to_path? def generated_path "#{parent.nil? ? '/' : parent.path}#{slug}/".gsub(/\/+/, '/') end def update_children_paths return unless respond...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/localizable_order_by_name_scope.rb
Ruby
mit
48
main
1,538
# Note: I do not include this scope in the localizable concern as a big number of localized objects has another order method (position, created_at, ...) module LocalizableOrderByNameScope extend ActiveSupport::Concern included do scope :ordered, -> (language) { # Define a raw SQL snippet for the conditio...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/header_call_to_action.rb
Ruby
mit
48
main
387
# frozen_string_literal: true module HeaderCallToAction extend ActiveSupport::Concern def header_cta_url_external?(website) return false if header_cta_url.blank? !header_cta_url_internal?(website) end def header_cta_url_internal?(website) return false if header_cta_url.blank? header_cta_url.st...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/localizable_order_by_title_scope.rb
Ruby
mit
48
main
1,547
# Note: I do not include this scope in the localizable concern as a big number of localized objects has another order method (position, created_at, ...) module LocalizableOrderByTitleScope extend ActiveSupport::Concern included do scope :ordered, -> (language) { # Define a raw SQL snippet for the conditi...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/sso_enabled.rb
Ruby
mit
48
main
674
module SsoEnabled extend ActiveSupport::Concern included do enum :sso_provider, { saml: 0 }, prefix: :with_sso_via validates :sso_cert, :sso_name_identifier_format, :sso_target_url, presence: true, if: :has_sso? validate :sso_mapping_should_have_email, if: :has_sso? end # Setter to serialize data...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/as_category.rb
Ruby
mit
48
main
3,006
module AsCategory extend ActiveSupport::Concern include AsTree include Bodyclassed include Orderable included do belongs_to :parent, class_name: self.name, optional: true has_many :children, class_name: self.name, foreign_key: :par...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/permalinkable.rb
Ruby
mit
48
main
1,681
module Permalinkable extend ActiveSupport::Concern include Sluggable include Staticable included do has_many :permalinks, class_name: "Communication::Website::Permalink", as: :about, dependent: :destroy has_many :aliases, -> { where(is_current:...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/websites_linkable.rb
Ruby
mit
48
main
1,899
# Means there might be a website about this object # https://iut-perigueux.u-bordeaux.fr about a location # https://www.iut.u-bordeaux-montaigne.fr about a school # https://mmibordeaux.com about a program # https://www.degrowthjournal.org about a journal # hthttps://mica.u-bordeaux-montaigne.fr about a laboratory modul...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/with_accessibility.rb
Ruby
mit
48
main
1,436
module WithAccessibility extend ActiveSupport::Concern def accessible? accessibility_errors.empty? end def accessibility_merge(object) return unless object.respond_to?('accessible?') object.accessibility_warnings.each do |message| accessibility_warning message end object.accessibilit...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/as_direct_object_localization.rb
Ruby
mit
48
main
385
module AsDirectObjectLocalization extend ActiveSupport::Concern included do before_validation :set_communication_website_id, on: :create end def federated_in?(website) about.respond_to?(:federated_in?) && about.federated_in?(website) end protected def set_communication_website_id self.comm...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/federated.rb
Ruby
mit
48
main
1,013
# frozen_string_literal: true module Federated extend ActiveSupport::Concern included do has_many :content_federations, class_name: "Communication::Website::ContentFederation", dependent: :destroy, as: :about has_many :destination_websites, thr...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/lifecyclable.rb
Ruby
mit
48
main
1,623
module Lifecyclable extend ActiveSupport::Concern LIFECYCLE_DAYS_BEFORE_DELETION = 30 LIFECYCLE_ALL = 'all' LIFECYCLE_TEMPLATE = 'template' LIFECYCLE_PUBLISHED = 'published' LIFECYCLE_PLANNED = 'planned' LIFECYCLE_DRAFT = 'draft' LIFECYCLE_TRASH = 'trash' LIFECYCLE_STATUSES = [ LIFECYCLE_ALL, ...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/localizable_order_by_slug_scope.rb
Ruby
mit
48
main
1,007
module LocalizableOrderBySlugScope extend ActiveSupport::Concern # Cf LocalizableOrderByNameScope included do scope :ordered, -> (language) { localization_name_select = <<-SQL COALESCE( MAX(CASE WHEN localizations.language_id = '#{language.id}' THEN TRIM(LOWER(UNACCENT(localizations.s...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/localizable.rb
Ruby
mit
48
main
3,171
module Localizable extend ActiveSupport::Concern included do has_many :localizations, foreign_key: :about_id, inverse_of: :about, dependent: :destroy accepts_nested_attributes_for :localizations validates_associated :localizations scope :for_lang...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/orderable.rb
Ruby
mit
48
main
516
module Orderable extend ActiveSupport::Concern included do validates :position, presence: true before_validation :set_position, on: :create, if: -> (object) { object.position.nil? } scope :ordered, -> (language = nil) { order(position: :asc) } end protected def set_position self.position ...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/with_featured_image.rb
Ruby
mit
48
main
1,182
module WithFeaturedImage extend ActiveSupport::Concern included do attr_accessor :featured_image_new_url has_summernote :featured_image_credit has_one_attached_deletable :featured_image validates :featured_image, size: { less_than: 5.megabytes } after_commit :upload_featured_image_later, on:...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/mentionable_by_blocks.rb
Ruby
mit
48
main
564
module MentionableByBlocks extend ActiveSupport::Concern def mentions_by_blocks localizations_mentioning_self + objects_mentioning_self end def objects_mentioning_self @objects_mentioning_self ||= localizations_mentioning_self.collect(&:about).compact.uniq end def localizations_mentioning_sel...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/with_menu_item_target.rb
Ruby
mit
48
main
390
module WithMenuItemTarget extend ActiveSupport::Concern included do has_many :menu_items, as: :about, class_name: 'Communication::Website::Menu::Item', dependent: :destroy has_many :menus, -> { distinct }, through: :menu_items,...
github
osunyorg/admin
https://github.com/osunyorg/admin
app/models/concerns/with_citations.rb
Ruby
mit
48
main
1,143
module WithCitations extend ActiveSupport::Concern def citation_apa(website: nil, locale: nil) citation_for("apa", website: website, locale: locale) end def citation_iso690(website: nil, locale: nil) citation_for("iso690-author-date-fr-no-abstract", website: website, locale: locale) end def citat...