diff options
author | Shinya Maeda <shinya@gitlab.com> | 2019-01-02 04:40:33 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2019-01-04 16:17:02 +0300 |
commit | 66755c9ed506af9f51022a678ed26e5d31ee87ac (patch) | |
tree | ae453c58166702161f7544e74995c43822017deb /app/models/release.rb | |
parent | b4f4edd4eed2e469c2b19a12166232f48eaf2181 (diff) |
Support CURD operation for release asset links
- Add Releases::Links model
- Expose it in release API
- Add integration tests
Diffstat (limited to 'app/models/release.rb')
-rw-r--r-- | app/models/release.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/models/release.rb b/app/models/release.rb index df3dfe1cf2f..2e014fcf882 100644 --- a/app/models/release.rb +++ b/app/models/release.rb @@ -10,6 +10,10 @@ class Release < ActiveRecord::Base # releases prior to 11.7 have no author belongs_to :author, class_name: 'User' + has_many :links, class_name: 'Releases::Link' + + accepts_nested_attributes_for :links, allow_destroy: true + validates :description, :project, :tag, presence: true scope :sorted, -> { order(created_at: :desc) } @@ -26,6 +30,16 @@ class Release < ActiveRecord::Base actual_tag.nil? end + def assets_count + links.size + sources.size + end + + def sources + strong_memoize(:sources) do + Releases::Source.all(project, tag) + end + end + private def actual_sha |