Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch archived log only if it is archived with tests #1324

Open
wants to merge 1 commit into
base: enterprise-3.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions spec/lib/travis/remote_log_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,35 @@

expect(subject.clear!(user)).to eq(content)
end

context 'when the log is not archived' do
let(:local_content) { 'Content from DB' }

before do
subject.archived_at = nil
subject.archive_verified = false
subject.content = local_content
end

it 'does not fetch archived content' do
expect(subject).not_to receive(:archived_log_content)
from_json = JSON.parse(subject.to_json).fetch('log')
expect(from_json.fetch('body')).to eq(local_content)
end
end

context 'when the log is archived' do
before do
subject.archived_at = Time.now
subject.archive_verified = true
end

it 'fetches archived content' do
expect(subject).to receive(:archived_log_content).and_return(archived_content)
from_json = JSON.parse(subject.to_json).fetch('log')
expect(from_json.fetch('body')).to eq(archived_content)
end
end
end

describe Travis::RemoteLog::Client do
Expand Down