Git Product home page Git Product logo

Comments (4)

sweep-ai avatar sweep-ai commented on May 25, 2024

I'm sorry, but it looks like an error has occured. Try removing and re-adding the sweep label. I'll try again in a minute. If this error persists contact [email protected].


I'm a bot that handles simple bugs and feature requests but I might make mistakes. Please be kind!

from changepack.

sweep-ai avatar sweep-ai commented on May 25, 2024

I'm sorry, but it looks like an error has occured. Try removing and re-adding the sweep label. I'll try again in a minute. If this error persists contact [email protected].


I'm a bot that handles simple bugs and feature requests but I might make mistakes. Please be kind!

from changepack.

sweep-ai avatar sweep-ai commented on May 25, 2024

I'm sorry, but it looks like an error has occured. Try removing and re-adding the sweep label. I'll try again in a minute. If this error persists contact [email protected].


I'm a bot that handles simple bugs and feature requests but I might make mistakes. Please be kind!

from changepack.

sweep-ai avatar sweep-ai commented on May 25, 2024

Hey @nicieja,

I've started working on the PR for writing tests for the SourcesController. The plan is to ensure we have tests that cover the index action and the collection method in the controller. I'll be creating a new file spec/controllers/sources_controller_spec.rb for these tests.

Give me a minute!

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description.

# typed: false
# frozen_string_literal: true
class Source
class OnRepositoryCreated < Handler
on ::Repository::Created
delegate :account_id, :name, :status, to: :event
delegate :id, to: :event, prefix: :repository
sig { override.returns Source }
def run
Source.create(
type: :repository,
repository_id:,
account_id:,
changelog:,
status:,
name:
)
end
sig { returns Changelog }
def changelog
@changelog ||= Account.find(account_id).changelogs.first
end
end

# typed: false
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Source do
subject { build(:source, :repository) }
it { is_expected.to belong_to(:account) }
it { is_expected.to belong_to(:team).optional }
it { is_expected.to belong_to(:repository).optional }
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_presence_of(:type) }
it { is_expected.to validate_uniqueness_of(:team_id).scoped_to(:account_id) }
it { is_expected.to validate_uniqueness_of(:repository_id).scoped_to(:account_id) }
it { is_expected.to validate_inclusion_of(:type).in_array(described_class::TYPES) }

class MigrateSourcesFromRepositories < ActiveRecord::Migration[7.0]
def change
Source.transaction do
Repository.find_each do |repository|
Source.create!(
type: :repository,
account_id: repository.account_id,
repository_id: repository.id,
name: repository.name
)
end
end
end

# typed: false
# frozen_string_literal: true
class RepositoriesController < ApplicationController
include Pullable
private
sig { override.returns Repository }
def resource
@resource ||= authorized(Repository.all).find(id)
end
sig { override.returns T::Locals }
def item
{
locals: { repository: resource }
}
end
sig { override.params(_resource: Repository).returns String }
def after_transition_path_for(_resource)
sources_path
end

# typed: false
# frozen_string_literal: true
class SourcesController < ApplicationController
def index
authorize!
pagy, sources = pagy(collection)
render locals: { sources:, pagy: }
end
private
sig { returns Source::RelationType }
def collection
authorized(Source.includes(:repository, :team).activity.kept)
end
end


I'm a bot that handles simple bugs and feature requests but I might make mistakes. Please be kind!

from changepack.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.