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
afomera/richer_text
https://github.com/afomera/richer_text
lib/richer_text/serialization.rb
Ruby
mit
97
main
433
module RicherText module Serialization extend ActiveSupport::Concern class_methods do def load(content) new(content) if content end def dump(content) case content when nil nil when self content.to_html when RicherText::RichText ...
github
afomera/richer_text
https://github.com/afomera/richer_text
lib/richer_text/text_visitor.rb
Ruby
mit
97
main
1,507
module RicherText class TextVisitor def visit(node) node.accept(self) end def visit_attachment_figure(node) visit_children(node) end def visit_attachment_gallery(node) visit_children(node) end def visit_blockquote(node) visit_children(node) end def visit...
github
afomera/richer_text
https://github.com/afomera/richer_text
lib/richer_text/engine.rb
Ruby
mit
97
main
628
require "rails" require "oembed" module RicherText class Engine < ::Rails::Engine isolate_namespace RicherText initializer "richer_text.attribute" do ActiveSupport.on_load(:active_record) do include RicherText::Attribute end end initializer "richer_text.helper" do ActiveSu...
github
afomera/richer_text
https://github.com/afomera/richer_text
lib/richer_text/nodes/text.rb
Ruby
mit
97
main
352
module RicherText module Nodes class Text < ::RicherText::Node def initialize(json) @marks = json.fetch("marks", []).map { |mark| RicherText::Mark.new(mark) } super(json) end def text json["text"] end def accept(visitor) visitor.visit_text(self, @mar...
github
afomera/richer_text
https://github.com/afomera/richer_text
lib/richer_text/nodes/richer_text_embed.rb
Ruby
mit
97
main
496
module RicherText module Nodes class RicherTextEmbed < ::RicherText::Node def sgid attrs["sgid"] end def html render partial: embeddable.to_embeddable_partial_path, object: embeddable, as: embeddable.model_name.element rescue ActiveRecord::RecordNotFound, NoMethodError ...
github
afomera/richer_text
https://github.com/afomera/richer_text
lib/richer_text/nodes/mention.rb
Ruby
mit
97
main
641
module RicherText module Nodes class Mention < ::RicherText::Node def initialize(json) @marks = json.fetch("marks", []).map { |mark| RicherText::Mark.new(mark) } super(json) end def accept(visitor) visitor.visit_mention(self, @marks) end def user @us...
github
afomera/richer_text
https://github.com/afomera/richer_text
lib/richer_text/nodes/image.rb
Ruby
mit
97
main
262
module RicherText module Nodes class Image < ::RicherText::Node def src @src ||= attrs['src'] end def signed_id @signed_id = attrs['signedId'] end def width attrs['width'] end end end end
github
afomera/richer_text
https://github.com/afomera/richer_text
lib/richer_text/nodes/attachment_figure.rb
Ruby
mit
97
main
284
module RicherText module Nodes class AttachmentFigure < ::RicherText::Node def previewable? @attrs["previewable"] end def url @attrs["url"].presence || @attrs["src"] end def sgid @attrs["sgid"] end end end end
github
afomera/richer_text
https://github.com/afomera/richer_text
lib/richer_text/nodes/iframely_embed.rb
Ruby
mit
97
main
253
module RicherText module Nodes class IframelyEmbed < ::RicherText::Node def href @attrs["href"] end def html "<div class='iframely'> #{@attrs["previewHtml"]} </div>" end end end end
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
osc-ruby.gemspec
Ruby
mit
97
master
512
Gem::Specification.new do |gem| gem.name = "osc-ruby" gem.version = File.read('VERSION') gem.summary = "a ruby client for the OSC protocol" gem.description = "This OSC gem originally created by Tadayoshi Funaba has been updated" gem.authors = "Colin Harris" gem.email = "qzzzq1@gmail.com" gem.homepage ...
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
Rakefile
Ruby
mit
97
master
424
require "rake/testtask" Rake::TestTask.new(:spec) do |t| t.libs << "spec" t.pattern = "spec/**/*_spec.rb" end task :default => :spec require 'rdoc/task' RDoc::Task.new do |rdoc| if File.exist?('VERSION') version = File.read('VERSION') else version = "" end rdoc.rdoc_dir = 'rdoc' rdoc.title = ...
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
lib/osc-ruby.rb
Ruby
mit
97
master
363
require 'socket' require 'thread' # core extensions require 'osc-ruby/core_ext/time' # jus the basics require 'osc-ruby/osc_types' require 'osc-ruby/osc_packet' require 'osc-ruby/message' require 'osc-ruby/bundle' require 'osc-ruby/address_pattern' # now we gettin fancy require 'osc-ruby/server' require 'osc-ruby/c...
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
lib/osc-ruby/em_server.rb
Ruby
mit
97
master
1,245
require 'eventmachine' module OSC Channel = EM::Channel.new class Connection < EventMachine::Connection def receive_data(data) ip_info = get_peername[2,6].unpack("nC4") Channel << OSC::OSCPacket.messages_from_network(data, ip_info) end end class EMServer def initialize(port = 3333) ...
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
lib/osc-ruby/network_packet.rb
Ruby
mit
97
master
566
module OSC class NetworkPacket def initialize(str) @str = str.force_encoding("BINARY") @index = 0 end def to_s @str end def rem @str.length - @index end def eof? rem <= 0 end def skip(n) @index += n end def skip_padding skip((4...
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
lib/osc-ruby/osc_packet.rb
Ruby
mit
97
master
3,103
require File.join(File.dirname( __FILE__ ), 'network_packet') require 'ostruct' module OSC class UnknownType < StandardError; end class OSCPacket def self.messages_from_network(string, ip_info=nil) messages = [] osc = new(string) if osc.bundle? osc.get_string time = osc.get_...
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
lib/osc-ruby/bundle.rb
Ruby
mit
97
master
856
module OSC class Bundle attr_accessor :timetag def initialize(timetag=nil, *args) @timetag = timetag @args = args end def encode() s = OSCString.new('#bundle').encode s << encode_timetag(@timetag) s << @args.collect do |x| x2 = x.encode; [x2.size].pack('N') + x2...
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
lib/osc-ruby/osc_types.rb
Ruby
mit
97
master
825
require File.join(File.dirname(__FILE__), "osc_argument") module OSC class OSCInt32 < OSCArgument def tag 'i' end def encode [@val].pack('N').force_encoding("BINARY") end end class OSCFloat32 < OSCArgument def tag 'f' end def encode [@val].pack('g').force_en...
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
lib/osc-ruby/osc_argument.rb
Ruby
mit
97
master
319
module OSC class OSCArgument def initialize(val) @val = val end attr_accessor :val def to_i() @val.to_i end def to_f() @val.to_f end def to_s() @val.to_s end private def padding(s) s + ("\000" * ((4 - (s.size % 4)) % 4)) end end end
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
lib/osc-ruby/server.rb
Ruby
mit
97
master
1,677
module OSC class Server def initialize(port) @socket = UDPSocket.new @socket.bind('', port) @matchers = [] @queue = Queue.new end def run start_dispatcher start_detector end def stop @socket.close end def add_method(address_pattern, &proc) ...
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
lib/osc-ruby/message.rb
Ruby
mit
97
master
992
module OSC class Message attr_accessor :address attr_accessor :time attr_accessor :ip_address attr_accessor :ip_port def self.new_with_time(address, time, tags=nil, *args) message = new(address, tags, *args) message.time = time message end def initialize(address, *args)...
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
lib/osc-ruby/broadcast_client.rb
Ruby
mit
97
master
525
require 'ipaddr' module OSC class BroadcastClient BROADCAST_ADDRESS = '<broadcast>' attr_reader :port def initialize(port, local_ip = nil) @port = port @so = UDPSocket.new @so.setsockopt Socket::SOL_SOCKET, Socket::SO_BROADCAST, true if local_ip @so.setsockopt Socket::I...
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
lib/osc-ruby/address_pattern.rb
Ruby
mit
97
master
1,422
module OSC class AddressPattern def initialize(pattern) @pattern = pattern generate_regex_from_pattern end def match?(address) !!(@re.nil? || @re.match(address)) end private def generate_regex_from_pattern case @pattern when nil @re = @pattern wh...
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
spec/unit/network_packet_spec.rb
Ruby
mit
97
master
950
require File.join(File.dirname(__FILE__) , '..', 'spec_helper') describe OSC::NetworkPacket do before :each do @empty = OSC::NetworkPacket.new("") @simple = OSC::NetworkPacket.new("abc") end it "should know if it's at the end of the stream" do _(@empty.eof?).must_equal(true) end it "should kno...
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
spec/unit/osc_complex_packets_spec.rb
Ruby
mit
97
master
1,146
require File.join( File.dirname(__FILE__) , '..', 'spec_helper' ) describe OSC::OSCPacket do before :each do @complex_packet = "#bundle\000\316\034\315T\000\003\030\370\000\000\000$/tuio/2Dobj\000,ss\000source\000\000simulator\000\000\000\000\000\000\030/tuio/2Dobj\000,s\000\000alive\000\000\000\000\000\000\034...
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
spec/unit/osc_packet_unknown_type_spec.rb
Ruby
mit
97
master
341
require File.join(File.dirname(__FILE__) , '..', 'spec_helper') describe OSC::OSCPacket do it 'something' do class OSC::BadType < OSC::OSCInt32; def tag() 'Z'; end end sent_msg = OSC::Message.new("/badtype", OSC::BadType.new(42)) _ {OSC::OSCPacket.messages_from_network(sent_msg.encode)}.must_raise OSC::...
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
spec/unit/osc_simple_packets_spec.rb
Ruby
mit
97
master
3,287
require File.join(File.dirname(__FILE__) , '..', 'spec_helper') describe OSC::OSCPacket do before :each do @address = "/hi" @first_int = 42 @second_int = 33 @first_float = 42.01 @second_float = 33.01 @first_string = "greetings" @second_string = "how are you?" @first_blob = "this i...
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
spec/unit/osc_types_spec.rb
Ruby
mit
97
master
534
require File.join(File.dirname(__FILE__) , '..', 'spec_helper') describe OSC::OSCInt32 do it "should not blow up" do OSC::OSCInt32.new(1) end end describe OSC::OSCFloat32 do it "should not blow up" do OSC::OSCFloat32.new(1.0) end end describe OSC::OSCDouble64 do it "should not blow up" do OSC::...
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
spec/unit/message_spec.rb
Ruby
mit
97
master
2,254
# some test data for when i unit test this # @simple_packet = "/hi\000,\000\000\000" # @simple_with_integer_arg = "/hi\000,i\000\000\000\000\000*" # @simple_with_two_integer_args = "/hi\000,ii\000\000\000\000*\000\000\000!" # @simple_with_float_arg = "/hi\000,f\000\000B(\n=" # @simple_with_two_float_args = "/hi\000,ff\...
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
spec/unit/address_pattern_spec.rb
Ruby
mit
97
master
2,829
require File.join(File.dirname(__FILE__) , '..', 'spec_helper') describe OSC::AddressPattern do # it "..." do # ap = OSC::AddressPattern.new("/bob/test/**") # ap.match?("/bob/test/monkey").should be_true # ap.match?("/bob/test/monkey/shine/rainy/day").should be_true # ap.match?("/bob/test").should ...
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
spec/unit/message_builder_spec.rb
Ruby
mit
97
master
1,202
require File.join( File.dirname(__FILE__) , '..', 'spec_helper' ) describe MessageBuilder do before :each do @builder = MessageBuilder.new end it "encodes just the address" do mesg = @builder.with_address("/hi") _(mesg.build.encode).must_equal binary_string("/hi\000,\000\000\000") end it "encod...
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
spec/builders/message_builder.rb
Ruby
mit
97
master
734
class MessageBuilder def initialize @address = "" @tags = [] @values = [] @time = nil end def with_address(addr) @address = addr self end def with_float(float) with_arg("f", float) self end def with_double(double) with_arg("d", double) self end def with_int(...
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
integration-test/chuck/osc_frequency_test.rb
Ruby
mit
97
master
626
system( "chuck --version &>/dev/null" ) # why does chuck say it's a failure when it successfully outputs the version? if $?.exitstatus != 2 STDERR.puts "you must install ChucK for this test to work" exit 1 end chuck_file = File.join(File.dirname(__FILE__), "simple_osc_synth.ck") pid = fork do puts "child proce...
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
examples/broadcast_client.rb
Ruby
mit
97
master
477
$:.unshift File.join( File.dirname( __FILE__ ), '..', 'lib') require 'osc-ruby' require 'rubygems' require 'eventmachine' require 'osc-ruby/em_server' @server = OSC::EMServer.new( 3333 ) @client = OSC::BroadcastClient.new( 3333 ) @server.add_method '/greeting' do | message | puts "#{message.ip_address}:#{message.i...
github
aberant/osc-ruby
https://github.com/aberant/osc-ruby
examples/event_machine_server.rb
Ruby
mit
97
master
524
# compatible with ruby 1.8, 1.9, and jruby $:.unshift File.join( File.dirname( __FILE__ ), '..', 'lib') require 'osc-ruby' require 'rubygems' require 'eventmachine' require 'osc-ruby/em_server' @server = OSC::EMServer.new( 3333 ) @client = OSC::Client.new( 'localhost', 3333 ) @server.add_method '/greeting' do | mess...
github
alphagov/signon
https://github.com/alphagov/signon
Gemfile
Ruby
mit
97
main
1,249
source "https://rubygems.org" gem "rails", "8.1.3" gem "activejob-retry" gem "addressable" gem "ancestry" gem "bootsnap", require: false gem "browser" gem "csv" gem "dartsass-rails" gem "devise" gem "devise-encryptable" gem "devise_invitable" gem "devise_zxcvbn", "~> 1.1" gem "doorkeeper" gem "json" gem "kaminari" ge...
github
alphagov/signon
https://github.com/alphagov/signon
Rakefile
Ruby
mit
97
main
421
# Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path("config/application", __dir__) Signon::Application.load_tasks begin require "pact/tasks" rescue LoadError # Pact isn't available i...
github
alphagov/signon
https://github.com/alphagov/signon
db/schema.rb
Ruby
mit
97
main
10,406
# This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # This file is the source Rails uses to define your schema when running `bin/rai...
github
alphagov/signon
https://github.com/alphagov/signon
db/seeds.rb
Ruby
mit
97
main
7,303
return if Rails.env.test? gds = Organisation.create!( name: "Government Digital Service", content_id: Organisation::GDS_ORG_CONTENT_ID, organisation_type: :ministerial_department, slug: "government-digital-service", ) User.create!( name: "Test Superadmin", email: "test.superadmin@gov.uk", password: "6fe...
github
alphagov/signon
https://github.com/alphagov/signon
db/migrate/20240423105028_remove_user_application_permissions_with_deleted_supported_permission.rb
Ruby
mit
97
main
1,047
class RemoveUserApplicationPermissionsWithDeletedSupportedPermission < ActiveRecord::Migration[7.1] def change return unless SupportedPermission.find_by(id: 2316).nil? user_application_permissions_to_destroy = UserApplicationPermission.where(supported_permission_id: 2316) initiator = User.find_by(email: ...
github
alphagov/signon
https://github.com/alphagov/signon
db/migrate/20240809112119_index_event_logs_columns.rb
Ruby
mit
97
main
218
class IndexEventLogsColumns < ActiveRecord::Migration[7.1] def change change_table :event_logs, bulk: true do add_index :event_logs, :application_id add_index :event_logs, :event_id end end end
github
alphagov/signon
https://github.com/alphagov/signon
db/migrate/20240429130154_remove_user_permissions_with_deleted_permission.rb
Ruby
mit
97
main
1,116
class RemoveUserPermissionsWithDeletedPermission < ActiveRecord::Migration[7.1] def change undeleted_permission = 1152 return unless SupportedPermission.find_by(id: undeleted_permission).nil? user_application_permissions_to_destroy = UserApplicationPermission.where(supported_permission_id: undeleted_perm...
github
alphagov/signon
https://github.com/alphagov/signon
test/test_helper.rb
Ruby
mit
97
main
4,622
ENV["RAILS_ENV"] = "test" ENV["GOVUK_ENVIRONMENT"] = "test" require "simplecov" SimpleCov.start "rails" require File.expand_path("../config/environment", __dir__) require "rails/test_help" require "shoulda/context" require "webmock/minitest" require "minitest/autorun" require "mocha/minitest" GovukTest.configure C...
github
alphagov/signon
https://github.com/alphagov/signon
test/presenters/api/user_presenter_test.rb
Ruby
mit
97
main
1,159
require "test_helper" class Api::UserPresenterTest < ActiveSupport::TestCase context "#present" do setup do @user = build(:user, organisation: build(:organisation)) end should "return a presented version of the user" do presented_user = Api::UserPresenter.present(@user) assert_equal p...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/suspensions_controller_test.rb
Ruby
mit
97
main
4,209
require "test_helper" class SuspensionsControllerTest < ActionController::TestCase context "organisation admin" do should "be unable to control suspension of a user outside their organisation" do user = create(:suspended_user, reason_for_suspension: "Negligence") organisation_admin = create(:organisa...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/passwords_controller_test.rb
Ruby
mit
97
main
3,266
require "test_helper" class PasswordsControllerTest < ActionController::TestCase setup do request.env["devise.mapping"] = Devise.mappings[:user] @original_password = "81de3dc67c6abddd2a52147899b45cce" @user = create(:user, password: @original_password) @token_received_in_email = @user.__send__(:send_...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/batch_invitations_controller_test.rb
Ruby
mit
97
main
7,629
require "test_helper" class BatchInvitationsControllerTest < ActionController::TestCase include ActiveJob::TestHelper def users_csv(filename = "users.csv") Rack::Test::UploadedFile.new(Rails.root.join("test/controllers/fixtures/#{filename}")) end setup do @user = create(:admin_user) sign_in @user...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/oauth_users_controller_test.rb
Ruby
mit
97
main
4,460
require "test_helper" class OauthUsersControllerTest < ActionController::TestCase context "GET show (as OAuth client application)" do setup do @application = create(:application) end should "fetching json profile with a valid oauth token should succeed" do user = create(:user) user.gra...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/two_step_verification_exemptions_controller_test.rb
Ruby
mit
97
main
4,737
require "test_helper" class TwoStepVerificationExemptionsControllerTest < ActionController::TestCase setup do @gds = create(:gds_organisation) @organisation = create(:organisation) end def assert_user_has_been_exempted_from_2sv(user, reason, expiry_date = nil) user.reload assert_not user.requir...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/batch_invitation_permissions_controller_test.rb
Ruby
mit
97
main
5,326
require "test_helper" class BatchInvitationPermissionsControllerTest < ActionController::TestCase include ActiveJob::TestHelper setup do @user = create(:admin_user) sign_in @user @app = create(:application, name: "Profound Publisher", with_non_delegated_supported_permissions: %w[reader]) @batch_...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/api_users_controller_test.rb
Ruby
mit
97
main
5,992
require "test_helper" class ApiUsersControllerTest < ActionController::TestCase context "as admin user" do setup do @admin = create(:admin_user) sign_in @admin end should "not be able to access API user's list" do get :index assert_not_authorised end should "not be able...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/sessions_controller_test.rb
Ruby
mit
97
main
895
require "test_helper" class SessionsControllerTest < ActionController::TestCase setup do @request.env["devise.mapping"] = Devise.mappings[:user] @user = create(:user) end should "sign in user if credentials are valid" do post :create, params: { user: { email: @user.email, password: @user.password } ...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/root_controller_test.rb
Ruby
mit
97
main
4,070
require "test_helper" class RootControllerTest < ActionController::TestCase def setup create(:application, name: "Support") end test "visiting root#accessibility_statement should succeed" do get :accessibility_statement assert_equal "200", response.code end test "visiting root#index should requ...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/doorkeeper_applications_controller_test.rb
Ruby
mit
97
main
2,887
require "test_helper" class DoorkeeperApplicationsControllerTest < ActionController::TestCase setup do @user = create(:superadmin_user) sign_in @user end context "GET index" do should "list applications in separate tabs for Active, API-only & Retired" do create(:application, name: "My first ap...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/signin_required_authorizations_controller_test.rb
Ruby
mit
97
main
3,129
require "test_helper" class SigninRequiredAuthorizationsControllerTest < ActionController::TestCase def default_scopes_exist(*scopes) Doorkeeper.configuration.stubs(default_scopes: Doorkeeper::OAuth::Scopes.from_array(scopes)) end setup do @application = create(:application) @user = create(:user, wi...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/two_step_verification_controller_test.rb
Ruby
mit
97
main
766
require "test_helper" class TwoStepVerificationControllerTest < ActionController::TestCase setup do request.env["devise.mapping"] = Devise.mappings[:user] @controller = Devise::TwoStepVerificationController.new @user = create(:user) sign_in @user end context "when user is not logged in" do ...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/user_research_recruitment_controller_test.rb
Ruby
mit
97
main
1,370
require "test_helper" class UserResearchRecruitmentControllerTest < ActionController::TestCase attr_reader :choice context "#update" do should "require users to be signed in" do put :update assert_not_authenticated end context "when user clicks the button to dismiss the banner" do ...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/users_controller_test.rb
Ruby
mit
97
main
14,489
require "test_helper" class UsersControllerTest < ActionController::TestCase include ActiveJob::TestHelper context "GET index" do context "signed in as Admin user" do setup do @user = create(:admin_user, email: "admin@gov.uk") sign_in @user end should "display 'Create user' ...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/authorisations_controller_test.rb
Ruby
mit
97
main
13,104
require "test_helper" class AuthorisationsControllerTest < ActionController::TestCase setup do @api_user = create(:api_user) end context "GET new" do context "signed in as Superadmin user" do setup do @superadmin = create(:superadmin_user) sign_in @superadmin @application ...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/invitations_controller_test.rb
Ruby
mit
97
main
21,858
require "test_helper" class InvitationsControllerTest < ActionController::TestCase setup do request.env["devise.mapping"] = Devise.mappings[:user] end context "GET new" do context "when inviter is signed in as an admin" do setup do sign_in create(:admin_user) end should "allow...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/organisations_controller_test.rb
Ruby
mit
97
main
3,559
require "test_helper" class OrganisationsControllerTest < ActionController::TestCase setup do @user = create(:admin_user) sign_in @user end context "GET index" do should "list organisations in separate tabs for active and closed" do active_organisation = create(:organisation) closed_orga...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/supported_permissions_controller_test.rb
Ruby
mit
97
main
4,634
require "test_helper" class SupportedPermissionsControllerTest < ActionController::TestCase setup do @user = create(:superadmin_user) sign_in @user end context "GET index" do should "render the permissions list" do app = create(:application, name: "My first app", with_delegated_supported_permi...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/confirmations_controller_test.rb
Ruby
mit
97
main
4,378
require "test_helper" class ConfirmationsControllerTest < ActionController::TestCase setup do request.env["devise.mapping"] = Devise.mappings[:user] @user = create(:user_with_pending_email_change) @confirmation_token = token_sent_to(@user) end context "GET new" do should "be disabled" do g...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/account/permissions_controller_test.rb
Ruby
mit
97
main
20,268
require "test_helper" class Account::PermissionsControllerTest < ActionController::TestCase context "#show" do context "when a user can view their permissions" do %w[govuk_admin publishing_manager].each do |role_group| context "as a #{role_group}" do setup do @application = cr...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/account/roles_controller_test.rb
Ruby
mit
97
main
785
require "test_helper" class Account::RolesControllerTest < ActionController::TestCase setup do @superadmin_user = create(:superadmin_user) sign_in @superadmin_user end context "GET edit" do should "display form with current role" do get :edit assert_select "form[action='#{account_role_p...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/account/applications_controller_test.rb
Ruby
mit
97
main
4,164
require "test_helper" class Account::ApplicationsControllerTest < ActionController::TestCase context "#show" do setup do @application = create(:application) end should "prevent unauthenticated users" do get :show, params: { id: @application.id } assert_redirected_to "/users/sign_in" ...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/account/organisations_controller_test.rb
Ruby
mit
97
main
913
require "test_helper" class Account::OrganisationsControllerTest < ActionController::TestCase setup do @organisation = create(:organisation) create(:organisation) @superadmin_user = create(:superadmin_user) sign_in @superadmin_user end context "GET edit" do should "display form with current ...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/account/passwords_controller_test.rb
Ruby
mit
97
main
3,124
require "test_helper" class Account::PasswordsControllerTest < ActionController::TestCase setup do @original_password = "bf3b2cc3bb659ad6e740533b06c0b899" @user = create(:user, password: @original_password) sign_in @user end context "GET edit" do should "display form" do get :edit a...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/account/emails_controller_test.rb
Ruby
mit
97
main
4,362
require "test_helper" class Account::EmailsControllerTest < ActionController::TestCase include ActiveJob::TestHelper context "GET edit" do setup do @user = create(:user, email: "old@email.com") sign_in @user end should "display form with current email address" do get :edit as...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/account/signin_permissions_controller_test.rb
Ruby
mit
97
main
4,573
require "test_helper" class Account::SigninPermissionsControllerTest < ActionController::TestCase context "#create" do should "prevent unauthenticated users" do application = create(:application) post :create, params: { application_id: application.id } assert_redirected_to "/users/sign_in" ...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/users/unlockings_controller_test.rb
Ruby
mit
97
main
4,726
require "test_helper" class Users::UnlockingsControllerTest < ActionController::TestCase context "GET edit" do context "signed in as Admin user" do setup do @admin = create(:admin_user) sign_in(@admin) end should "display form with submit button & cancel link" do user =...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/users/roles_controller_test.rb
Ruby
mit
97
main
7,308
require "test_helper" class Users::RolesControllerTest < ActionController::TestCase context "GET edit" do context "signed in as Superadmin user" do setup do @superadmin = create(:superadmin_user) sign_in(@superadmin) end should "display form with role field" do user = c...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/users/two_step_verification_resets_controller_test.rb
Ruby
mit
97
main
4,546
require "test_helper" class Users::TwoStepVerificationResetsControllerTest < ActionController::TestCase include ActiveJob::TestHelper context "GET edit" do context "signed in as Admin user" do setup do @admin = create(:admin_user) sign_in(@admin) end should "display form wit...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/users/signin_permissions_controller_test.rb
Ruby
mit
97
main
12,006
require "test_helper" class Users::SigninPermissionsControllerTest < ActionController::TestCase context "#create" do should "call the UserUpdate service to grant the user access to the application" do current_user = create(:admin_user) sign_in current_user user = create(:user) applicatio...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/users/invitation_resends_controller_test.rb
Ruby
mit
97
main
5,181
require "test_helper" class Users::InvitationResendsControllerTest < ActionController::TestCase include ActiveJob::TestHelper include ActionMailer::TestHelper context "GET edit" do context "signed in as Admin user" do setup do @admin = create(:admin_user) sign_in(@admin) end ...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/users/two_step_verification_mandations_controller_test.rb
Ruby
mit
97
main
5,516
require "test_helper" class Users::TwoStepVerificationMandationsControllerTest < ActionController::TestCase include ActiveJob::TestHelper include ActionMailer::TestHelper context "GET edit" do context "signed in as Admin user" do setup do @admin = create(:admin_user) sign_in(@admin) ...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/users/permissions_controller_test.rb
Ruby
mit
97
main
25,262
require "test_helper" class Users::PermissionsControllerTest < ActionController::TestCase context "#show" do context "when a user can view another's permissions" do %w[govuk_admin publishing_manager].each do |role_group| context "as a #{role_group}" do setup do @application = ...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/users/emails_controller_test.rb
Ruby
mit
97
main
16,749
require "test_helper" class Users::EmailsControllerTest < ActionController::TestCase include ActiveJob::TestHelper include ActionMailer::TestHelper context "GET edit" do context "signed in as Superadmin user" do setup do @superadmin = create(:superadmin_user) sign_in(@superadmin) ...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/users/applications_controller_test.rb
Ruby
mit
97
main
5,533
require "test_helper" class Users::ApplicationsControllerTest < ActionController::TestCase context "#show" do setup do @application = create(:application) @user = create(:user) end should "prevent unauthenticated users" do get :show, params: { user_id: @user, id: @application.id } ...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/users/names_controller_test.rb
Ruby
mit
97
main
8,901
require "test_helper" class Users::NamesControllerTest < ActionController::TestCase context "GET edit" do context "signed in as Admin user" do setup do @superadmin = create(:superadmin_user) sign_in(@superadmin) end should "display breadcrumb links back to edit user page & user...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/users/organisations_controller_test.rb
Ruby
mit
97
main
6,727
require "test_helper" class Users::OrganisationsControllerTest < ActionController::TestCase attr_reader :organisation setup do @organisation = create(:organisation) end context "GET edit" do context "signed in as Admin user" do setup do @admin = create(:admin_user) sign_in(@admi...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/api_users/permissions_controller_test.rb
Ruby
mit
97
main
14,224
require "test_helper" class ApiUsers::PermissionsControllerTest < ActionController::TestCase context "#edit" do context "when the granting user is authorised to edit another's permissions" do should "render a page with checkboxes for the grantable permissions and a hidden field for the signin permission so...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/api_users/applications_controller_test.rb
Ruby
mit
97
main
4,361
require "test_helper" class ApiUsers::ApplicationsControllerTest < ActionController::TestCase context "#index" do should "prevent unauthenticated users" do api_user = create(:api_user) get :index, params: { api_user_id: api_user } assert_not_authenticated end should "prevent unauthor...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/doorkeeper/tokens_controller_test.rb
Ruby
mit
97
main
463
require "test_helper" class Doorkeeper::TokensControllerTest < ActionController::TestCase should "handle OAuth v1 requests to create a token" do assert_recognizes({ controller: "doorkeeper/tokens", action: "create" }, { path: "oauth/access_token", method: :post }) end should "handle OAuth v2 requests to cre...
github
alphagov/signon
https://github.com/alphagov/signon
test/controllers/api/users_controller_test.rb
Ruby
mit
97
main
2,727
require "test_helper" class Api::UsersControllerTest < ActionController::TestCase setup do @application = create(:application) end context "as admin user" do setup do @admin = create(:admin_user) sign_in @admin end should "not be able to access the API endpoint" do get :index ...
github
alphagov/signon
https://github.com/alphagov/signon
test/factories/oauth_applications.rb
Ruby
mit
97
main
1,900
FactoryBot.define do factory :application, class: Doorkeeper::Application do transient do with_non_delegated_supported_permissions { [] } with_non_delegated_supported_permissions_not_grantable_from_ui { [] } with_delegated_supported_permissions { [] } with_delegated_supported_permissions_n...
github
alphagov/signon
https://github.com/alphagov/signon
test/factories/supported_permission.rb
Ruby
mit
97
main
319
FactoryBot.define do factory :supported_permission, aliases: [:non_delegated_supported_permission] do sequence(:name) { |n| "Permission ##{n}" } association :application, factory: :application end factory :delegated_supported_permission, parent: :supported_permission do delegated { true } end end
github
alphagov/signon
https://github.com/alphagov/signon
test/factories/batch_invitation.rb
Ruby
mit
97
main
550
FactoryBot.define do factory :batch_invitation do association :user, factory: :admin_user trait :with_organisation do association :organisation, factory: :organisation end trait :in_progress do outcome { nil } has_permissions end trait :has_permissions do after(:crea...
github
alphagov/signon
https://github.com/alphagov/signon
test/factories/two_step_verification_exemption.rb
Ruby
mit
97
main
245
FactoryBot.define do factory :two_step_verification_exemption do reason { "a very good reason" } expiry_day { Time.zone.tomorrow.day } expiry_month { Time.zone.tomorrow.month } expiry_year { Time.zone.tomorrow.year } end end
github
alphagov/signon
https://github.com/alphagov/signon
test/factories/users.rb
Ruby
mit
97
main
4,428
FactoryBot.define do factory :user, aliases: [:normal_user] do transient do with_permissions { {} } with_signin_permissions_for { [] } end sequence(:email) { |n| "user#{n}@example.com" } password { "this 1s 4 v3333ry s3cur3 p4ssw0rd.!Z" } confirmed_at { 1.day.ago } sequence(:name)...
github
alphagov/signon
https://github.com/alphagov/signon
test/factories/organisation.rb
Ruby
mit
97
main
411
FactoryBot.define do factory :organisation do sequence(:slug) { |n| "ministry-of-funk-#{n}000" } sequence(:name) { |n| "Ministry of Funk #{n}000" } content_id { SecureRandom.uuid } organisation_type { "Ministerial Department" } end factory :gds_organisation, parent: :organisation do content_i...
github
alphagov/signon
https://github.com/alphagov/signon
test/factories/oauth_access_grants.rb
Ruby
mit
97
main
224
FactoryBot.define do factory :access_grant, class: Doorkeeper::AccessGrant do sequence(:resource_owner_id) { |n| n } application expires_in { 2.hours } redirect_uri { "https://app.com/callback" } end end
github
alphagov/signon
https://github.com/alphagov/signon
test/policies/organisation_policy_scope_test.rb
Ruby
mit
97
main
2,444
require "test_helper" class OrganisationPolicyScopeTest < ActiveSupport::TestCase setup do @parent_organisation = create(:organisation) @child_organisation_one = create(:organisation, parent: @parent_organisation) @child_organisation_two = create(:organisation, parent: @parent_organisation) @grandchi...
github
alphagov/signon
https://github.com/alphagov/signon
test/policies/user_policy_scope_test.rb
Ruby
mit
97
main
9,125
require "test_helper" class UserPolicyScopeTest < ActiveSupport::TestCase setup do @parent_organisation = create(:organisation) @child_organisation = create(:organisation, parent: @parent_organisation) @other_organisation = create(:organisation) @super_admin_in_org = create(:superadmin_user, organis...
github
alphagov/signon
https://github.com/alphagov/signon
test/policies/organisation_policy_test.rb
Ruby
mit
97
main
2,591
require "test_helper" require "support/policy_helpers" class OrganisationPolicyTest < ActiveSupport::TestCase include PolicyHelpers context "index" do should "allow only for superadmins and admins" do assert permit?(create(:superadmin_user), User, :index) assert permit?(create(:admin_user), User, ...
github
alphagov/signon
https://github.com/alphagov/signon
test/policies/api_user_policy_test.rb
Ruby
mit
97
main
1,210
require "test_helper" require "support/policy_helpers" class ApiUserPolicyTest < ActiveSupport::TestCase include PolicyHelpers %i[new create index edit update manage_tokens suspension].each do |permission_name| context permission_name do should "allow only for superadmins" do assert permit?(crea...
github
alphagov/signon
https://github.com/alphagov/signon
test/policies/authorisation_policy_test.rb
Ruby
mit
97
main
663
require "test_helper" require "support/policy_helpers" class AuthorisationPolicyTest < ActiveSupport::TestCase include PolicyHelpers %i[new create edit revoke].each do |permission_name| context permission_name do should "allow only for superadmins" do assert permit?(create(:superadmin_user), Use...
github
alphagov/signon
https://github.com/alphagov/signon
test/policies/user_policy_test.rb
Ruby
mit
97
main
11,549
require "test_helper" require "support/policy_helpers" class UserPolicyTest < ActiveSupport::TestCase include PolicyHelpers setup do @parent_organisation = create :organisation @child_organisation = create(:organisation, parent: @parent_organisation) @super_org_admin = create(:super_organisation_admin...
github
alphagov/signon
https://github.com/alphagov/signon
test/policies/supported_permission_policy_scope_test.rb
Ruby
mit
97
main
6,482
require "test_helper" class SupportedPermissionPolicyScopeTest < ActiveSupport::TestCase setup do @delegated_signin_app_one = create(:application, with_delegated_supported_permissions: [SupportedPermission::SIGNIN_NAME]) @delegated_signin_app_two = create(:application, with_delegated_supported_permissions: [...
github
alphagov/signon
https://github.com/alphagov/signon
test/policies/batch_invitation_policy_test.rb
Ruby
mit
97
main
984
require "test_helper" require "support/policy_helpers" class BatchInvitationPolicyTest < ActiveSupport::TestCase include PolicyHelpers context "new" do should "allow superadmins and admins to create new batch uploads" do assert permit?(create(:superadmin_user), BatchInvitation.new, :new) assert pe...
github
alphagov/signon
https://github.com/alphagov/signon
test/policies/application_policy_test.rb
Ruby
mit
97
main
703
require "test_helper" require "support/policy_helpers" class ApplicationPolicyTest < ActiveSupport::TestCase include PolicyHelpers %i[index edit update manage_supported_permissions users_with_access].each do |permission_name| context permission_name do should "allow only for superadmins" do asse...