summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-05-11 15:07:31 +0900
committerShinya Maeda <shinya@gitlab.com>2018-05-11 15:07:31 +0900
commit9ccfcf55ba684a4c7b1dfec761e3481f74b746b0 (patch)
treecd4ca2e6ede23c88c1b9d853bde935b5c4883d48 /spec/models
parent6a108b8fbd5f1b5c2d8e6b51bb34cda06fe0e5ee (diff)
parent35816eb7be76aa1a26dcf2f9cfeddf7c60b2da26 (diff)
downloadgitlab-ce-9ccfcf55ba684a4c7b1dfec761e3481f74b746b0.tar.gz
Merge branch 'master' into per-project-pipeline-iid
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/concerns/issuable_spec.rb18
-rw-r--r--spec/models/concerns/sha_attribute_spec.rb10
-rw-r--r--spec/models/project_wiki_spec.rb11
3 files changed, 32 insertions, 7 deletions
diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb
index 05693f067e1..3d3092b8ac9 100644
--- a/spec/models/concerns/issuable_spec.rb
+++ b/spec/models/concerns/issuable_spec.rb
@@ -495,6 +495,14 @@ describe Issuable do
expect(issue.total_time_spent).to eq(1800)
end
+
+ it 'updates issues updated_at' do
+ issue
+
+ Timecop.travel(1.minute.from_now) do
+ expect { spend_time(1800) }.to change { issue.updated_at }
+ end
+ end
end
context 'substracting time' do
@@ -510,9 +518,13 @@ describe Issuable do
context 'when time to substract exceeds the total time spent' do
it 'raise a validation error' do
- expect do
- spend_time(-3600)
- end.to raise_error(ActiveRecord::RecordInvalid)
+ Timecop.travel(1.minute.from_now) do
+ expect do
+ expect do
+ spend_time(-3600)
+ end.to raise_error(ActiveRecord::RecordInvalid)
+ end.not_to change { issue.updated_at }
+ end
end
end
end
diff --git a/spec/models/concerns/sha_attribute_spec.rb b/spec/models/concerns/sha_attribute_spec.rb
index 592feddf1dc..0d3beb6a6e3 100644
--- a/spec/models/concerns/sha_attribute_spec.rb
+++ b/spec/models/concerns/sha_attribute_spec.rb
@@ -36,24 +36,26 @@ describe ShaAttribute do
end
context 'when the table does not exist' do
- it 'allows the attribute to be added' do
+ it 'allows the attribute to be added and issues a warning' do
allow(model).to receive(:table_exists?).and_return(false)
expect(model).not_to receive(:columns)
expect(model).to receive(:attribute)
+ expect(model).to receive(:warn)
model.sha_attribute(:name)
end
end
context 'when the column does not exist' do
- it 'raises ArgumentError' do
+ it 'allows the attribute to be added and issues a warning' do
allow(model).to receive(:table_exists?).and_return(true)
expect(model).to receive(:columns)
- expect(model).not_to receive(:attribute)
+ expect(model).to receive(:attribute)
+ expect(model).to receive(:warn)
- expect { model.sha_attribute(:no_name) }.to raise_error(ArgumentError)
+ model.sha_attribute(:no_name)
end
end
diff --git a/spec/models/project_wiki_spec.rb b/spec/models/project_wiki_spec.rb
index d6c4031329d..f1142832f1a 100644
--- a/spec/models/project_wiki_spec.rb
+++ b/spec/models/project_wiki_spec.rb
@@ -159,6 +159,17 @@ describe ProjectWiki do
expect(page.title).to eq("autre pagé")
end
end
+
+ context 'pages with invalidly-encoded content' do
+ before do
+ create_page("encoding is fun", "f\xFCr".b)
+ end
+
+ it "can find the page" do
+ page = subject.find_page("encoding is fun")
+ expect(page.content).to eq("fr")
+ end
+ end
end
context 'when Gitaly wiki_find_page is enabled' do